Print and Merge Suite
The Print and Merge Suite is an extention to Report Builder reports, from Digital Metaphors, and a PDF Viewer written using Developer Express VCL components.
The Print and Merge Suite consists of 3 runtime components:
- TDuplicatePrinter Hooks into one or more report. On copy 2 and following TDuplicatePrinter will add a Watermark to your reports, saying "Duplicate"
If you want some thing else written construct DuplicatePrinter like this:
with TDuplicatePrinter.Create(ppReport1) do CopyText := 'Copy';
You'll find two demos using TDuplicatePrinter
Hooks into one or more report, on prinjting it will merge it into one print, and give you the possibility to print it to PDF, RTF or DOC.
Example of use:
TPrintAndMerge created with Self (the form) inorder for using all ppReports on the form
with TPrintAndMerge.Create(Self, ChangeFileExt(Application.ExeName, '.pdf')) do try PrintToPDF; finally Free; end;
TPrintAndMerge created with an array of ppReports, inorder for only using those
with TPrintAndMerge.Create([ppReport1, ppReport2], ChangeFileExt(Application.ExeName, '.pdf')) do try PrintToPDF; finally Free; end;
TPDFViewer can be used for showing a PDF file. Either from at file:
or a Stream:
You'll find a simple demo showing how to use it.
Also included is a mega demo using all of the above in one demo. Watermark, Merge and PDF Viewer in one demo.
And the code
uses DuplicatePrinterU, PrintAndMergeU, PDFViewerU; procedure TFormMain.Button1Click(Sender: TObject); begin ppReport1.PrinterSetup.Copies := StrToIntDef(Edit1.Text, 2); ppReport2.PrinterSetup.Copies := StrToIntDef(Edit2.Text, 2); ppReport3.PrinterSetup.Copies := StrToIntDef(Edit3.Text, 2); with TPrintAndMerge.Create(Self) do try PrintToPDF; TPDFViewer.LoadFromStream(OutputStream); finally Free; end; end; procedure TFormMain.DuplicatePrintersOnGetWatermarkText(Sender: TppReport; Copy: integer; var Text: string); begin if Copy = 1 then Text := '' else Text := 'Copy ' + (Copy - 1).ToString; end; procedure TFormMain.FormCreate(Sender: TObject); begin with TDuplicatePrinters.Create(Self) do OnGetWatermarkText := DuplicatePrintersOnGetWatermarkText; end;
So even though we merged 3 reports into 1 PDF file, adding a Watermark to page 2 following on each report and showing the PDF (loaded form a stream), only approx 30 lines of code is needed inorder for achieving this.