How to use the ReportBuilder device?

Top  Previous  Next

Add unit wppdfRBDev to your project.

 

To enable printing to file set the property AllowPrintToFile of the component TppReport to true. Then the print dialog will offer you the option to save to file with a list of possible file formats. Our device will add the item 'PDF Export (wpCubed GmbH)' to that list. (You can change the name in unit wppdfRBDev).

 

I need to export from different sources to ONE PDF file. Is this possible with wPDF?

 

Yes, and it makes much sense since wPDF is so versatile. In contrast to the usual export devices which are specialized on a certain application wPDF is specialized on a certain format: PDF. We have added a global variable to the unit wppdfRBDev: ppGlobalPDFPrinter.

If this points to an instance of a TWPDFPrinter or TWPDFExport (for WPTools) and that component has started a PDF file already (BeginDoc) the exported pages will go into this file as well. At the end the file will not be closed automatically.

 

Example:

 

procedure TForm1.StartPDFFile(Sender: TObject);

begin

 WPPDFPrinter1.FileName := 'c:\allout.pdf';

 WPPDFPrinter1.AutoLaunch := TRUE;

 WPPDFPrinter1.BeginDoc;

 ppGlobalPDFPrinter := WPPDFPrinter1;

end;

 

procedure TForm1.ClosePDFFile(Sender: TObject);

begin

 WPPDFPrinter1.EndDoc;

end;

 

Now export a 2 page WPTools letter and then any other report to the PDF file.

 

procedure TForm1.StartPDFFile(Sender: TObject);

begin

 WPPDFExport1.FileName := 'c:\allout.pdf';

 WPPDFExport1.AutoLaunch := TRUE;

 WPPDFExport1.BeginDoc;

 // Now export our WPTools Text

 WPPDFExport1.Source := WPRichText1;

 WPPDFExport1.Print;

 

 ppGlobalPDFPrinter := WPPDFExport1;

end;

 

procedure TForm1.ClosePDFFile(Sender: TObject);

begin

 WPPDFExport1.EndDoc;

end;

 

Note: Since the PDF file will not be valid without a WPPDFExport1.EndDoc; please don't forget to execute this function, the latest in Form.OnClose.

 

You can check if a PDFFrinter has already started a file by checking the property 'Printing'. In this case you should not call BeginDoc and EndDoc if you want to create a combined PDF file.