trichview.com Forum Index trichview.com
TRichView support forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[How to] How to print 2 documents in one printing job, etc.

 
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos
View previous topic :: View next topic  
Author Message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:40 pm    Post subject: [How to] How to print 2 documents in one printing job, etc. Reply with quote

Question How to print more than one document in one printing job?
Question How to print two documents on one page?


Code:
Printer.BeginDoc;
RVPrint.StartAt := 0;
RVPrint.TransparentBackground := True;
RVPrint.AssignSource(RichView1);
RVPrint.FormatPages(rvdoALL);
RVPrint.ContinuousPrint;
RVPrint.StartAt := RVPrint.EndAt;
{ // not necessary in the latest verison of TRichView
if RVPrint.rv.Height-RVPrint.StartAt<some safe value then
begin
  Printer.NewPage;
  RVPrint.StartAt := 0;
end;
}
RVPrint.AssignSource(RichView2);
RVPrint.FormatPages(rvdoALL);
RVPrint.ContinuousPrint;
Printer.EndDoc;

This code uses undocumented properties StartAt and EndAt. I think they are self explanatory. It also uses ContinuousPrint method. It's like Print method, but does not start and end a printing job.


Last edited by Sergey Tkachenko on Thu Oct 04, 2007 10:09 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:42 pm    Post subject: Reply with quote

Question How to change paper orientation?

Change Printer.Orientation to poLandscape (or poPortrait) before calling RVPrint.FormatPages.

(Printer is defined in the Printers unit)


Last edited by Sergey Tkachenko on Thu Sep 08, 2005 7:48 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:45 pm    Post subject: Reply with quote

Question How to mix portrait and landscape orientation?

You need to separate your document in two (or more) parts - one with portrait orientation, and one with landscape orientation.
Code:
Printer.BeginDoc;
Printer.Orientation := ...;
RVPrint1.ContinuousPrint;
Printer.NewPage;
Printer.Orientation := ...;
RVPrint2.ContinuousPrint;
Printer.EndDoc;


Last edited by Sergey Tkachenko on Thu Sep 08, 2005 7:48 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:47 pm    Post subject: Reply with quote

Question How to print the chosen pages, for example 1, 3, 4, 5, 23?

Code:
procedure PrintSomePages(const Title: String;
  RVPrint: TRVPrint; const Pages: array of Integer);
var i: Integer;
begin
  Printer.Title := Title;
  Printer.BeginDoc;
  for i := Low(Pages) to High(Pages) do begin
    if i<>Low(Pages) then
      Printer.NewPage;
    RVPrint.rv.DrawPage(Pages[i], Printer.Canvas,False,False);
  end;
  Printer.EndDoc;
end;

Test:
Code:
PrintSomePages('Test', RVPrint1, [1, 3, 4, 5, 23]);


Question How to print only odd or even pages?

Code:
procedure PrintOddOrEvenPages(const Title: String;
  RVPrint: TRVPrint; Odd: Boolean);
var i: Integer;
begin
  Printer.Title := Title;
  Printer.BeginDoc;
  for i := 1 to RVPrint.PagesCount do
    if (Odd and (i mod 2=1)) or (not Odd and (i mod 2=0)) then begin
      if i>2 then
        Printer.NewPage;
      RVPrint.rv.DrawPage(i, Printer.Canvas,False,False);
    end;
  Printer.EndDoc;
end;


Last edited by Sergey Tkachenko on Sat Aug 19, 2006 1:46 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:50 pm    Post subject: Reply with quote

Question How to print without background?

Set RVPrint.TransparentBackground = True. Background color will not be painted.
Call RVPrint.rv.BackgroundBitmap := nil after calling RVPrint.AssignSource. Background bitmap will not be printed.
Back to top
View user's profile Send private message Visit poster's website
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Sep 08, 2005 7:56 pm    Post subject: Reply with quote

Question How to print the selected fragment

There are no functions for printing the selection.
The only way to do it is to copy it to the separate (hidden) RichView and to print it.
Code:
var Stream: TMemoryStream;
// copying the selection
Stream := TMemoryStream.Create;
try
  rvSource.SaveRVFToStream(Stream, True);
  Stream.Position := 0;
  rvHidden.LoadRVFFromStream(Stream);
finally
  Stream.Free;
end;
// printing
RVPrint1.AssignSource(RVHidden);
RVPrint1.FormatPages(rvdoAll);
RVPrint1.Print('Selection', 1, False);
Back to top
View user's profile Send private message Visit poster's website
Benoit B.
Guest





PostPosted: Tue Nov 08, 2005 4:09 pm    Post subject: Reply with quote

Sergey Tkachenko wrote:
Question How to mix portrait and landscape orientation?

You need to separate your document in two (or more) parts - one with portrait orientation, and one with landscape orientation.
Code:
Printer.BeginDoc;
Printer.Orientation := ...;
RVPrint1.ContinuousPrint;
Printer.NewPage;
Printer.Orientation := ...;
RVPrint2.ContinuousPrint;
Printer.EndDoc;



How to do that with Borland C++ Builder 6 please ?
Back to top
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Tue Nov 08, 2005 4:44 pm    Post subject: Reply with quote

Almost exactly the same:
Code:
Printer()->BeginDoc();
Printer()->Orientation = ...;
RVPrint1->ContinuousPrint();
Printer()->NewPage();
Printer()->Orientation = ...;
RVPrint2->ContinuousPrint();
Printer()->EndDoc();

where poPortrait or poLandscape must be used instead of ...

The code above assumes that RVPrint1 and RVPrint2 were already formatted (in the proper page orientation).
If not, the full code will be:
Code:
Printer()->BeginDoc();
Printer()->Orientation = ...;
RVPrint1->FormatPages(TRVDisplayOptions());
RVPrint1->ContinuousPrint();
Printer()->NewPage();
Printer()->Orientation = ...;
RVPrint2->FormatPages(TRVDisplayOptions());
RVPrint2->ContinuousPrint();
Printer()->EndDoc();
Back to top
View user's profile Send private message Visit poster's website
Benoit B.
Guest





PostPosted: Wed Nov 09, 2005 8:22 am    Post subject: Reply with quote

Thanks for your help.
Now it works ! Very Happy
Back to top
YannickM



Joined: 03 Jul 2007
Posts: 5

PostPosted: Tue Jul 03, 2007 2:06 pm    Post subject: Reply with quote

Is there a way to have pages in different orientations in the print preview aswell ?
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Tue Jul 03, 2007 3:28 pm    Post subject: Reply with quote

Assuming that you have 2 documents in 2 RVPrints, one formatted in portrait and one in landscape orientation, you can display preview with different orientations. RVPrintPreview displays only one page at once, so assing the proper RVPrint to RVPrintPreview.RVPrint property when moving to another page. You also need to assign the proper value to Printer.Orientation when switching pages.
Back to top
View user's profile Send private message Visit poster's website
YannickM



Joined: 03 Jul 2007
Posts: 5

PostPosted: Wed Jul 04, 2007 6:55 am    Post subject: Reply with quote

Thanks for the quick response.

I am working with 1 document, and with your suggestion to use 2 RVPrints, I succeeded in mixing portrait and landscape in the print preview.

The only problem I am having now however, is since the RichViewEdit box only allows a document to have an orientation, and not each page independantly, that all the pages have the same size (the same number of lines of text). I cannot detect pagenumbers correctly.

Any ideas ?
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Thu Jul 05, 2007 1:56 pm    Post subject: Reply with quote

Sorry, I do not understand your question.
Do you format 2 different TRichViews, one in portrait and one in landscape orientation?
Back to top
View user's profile Send private message Visit poster's website
YannickM



Joined: 03 Jul 2007
Posts: 5

PostPosted: Mon Jul 09, 2007 6:37 am    Post subject: Reply with quote

No, I have 1 TRichView and I am trying to get portrait and landscape orientation mixed on a page-to-page basis throughout the document. Similar to what you can do in a text editor like Word.

Is this even possible ?
Back to top
View user's profile Send private message
Sergey Tkachenko
Site Admin


Joined: 27 Aug 2005
Posts: 6431

PostPosted: Mon Jul 09, 2007 10:34 am    Post subject: Reply with quote

No, I suggest to format parts of documents having different orientation in different RichViews
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    trichview.com Forum Index -> Examples, Demos All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group