Page 1 of 1

How to compose a document from multiple documents?

Posted: Mon Feb 16, 2009 4:44 pm
by Stefaan
I have a document with fields, that must be replaced with values. Several documents will be created by using different values. All these documents should come in a large document, with each document beginning on a new page. This resulting document must be shown in a print preview and be printed. What is the best way to create such composite document?

There's a demo on that topic on http://www.trichview.com/forums/viewtopic.php?t=87 but its targeted at TRichViewEdit and TRVPrint. I'm using TSRichViewEdit and TSRVPrint.

Posted: Mon Feb 16, 2009 5:16 pm
by Sergey Tkachenko
Use TSRVPrint to print several documents on one printing job.
TSRVPrint.PrintFramesEx prints one page.

Code: Select all

var FirstPage: Boolean;

FirstPage := True;
Printer.BeginDoc;
for i := 0 to DocumentCount-1 do begin
  <prepare the i-th document here>
  for j := 1 to SRichViewEdit.PageCount do begin
    if FirstPage then 
      FirstPage := False
    else
      Printer.NewPage;
    SRVPrint1.PrintFramesEx(j);
  end;
Printer.EndDoc;

Posted: Tue Feb 17, 2009 8:46 am
by Stefaan
Thanks for your answer. Is it possible to show a print preview of the composite document to the user before printing?

Posted: Tue Feb 17, 2009 11:17 am
by proxy3d
Yes. For this purpose you need to display pages. For page drawing, it is necessary to use function:

Code: Select all

    procedure DrawPage(PageNo, PageWd, PageHt, OffX, OffY: Integer;
      CanvasPage: TCanvas; PageNoVisible, ClipMargins, Printing: Boolean);
Description of parametres of function look in the help.