How to create a PDF file without display of a file save dialog? |
Top Previous Next |
It is easy to add PDF export to the ReportBuilder demo application
a) we need a check box:
b) modify the uses clause
uses .... wppdfRBDev, wppdfr1;
c) modify the procedure PrintReport()
var ... pdf : TppwPDFDevice;
...
if cbxPrintToPDF.checked then begin with TOpenDialog.Create(nil) do try Filter := 'PDF Files (*.PDF)|*.PDF'; FileName := 'c:\rb.pdf'; if Execute then begin pdf := TppwPDFDevice.Create(Self); pdf.Filename := FileName; pdf.PDFPrinter.FontMode := wpUseTrueTypeFonts; pdf.PDFPrinter.AutoLaunch := true; pdf.Publisher := lForm.Report.Publisher; lForm.Report.PrintToDevices; pdf.Free; end; finally Free; end; end else if cbxPrintToArchive.Checked then ...
It is also possible to create a report as a stream, here "OutputStream":
var pdf : TppwPDFDevice; begin WPPDFPrinter1.AutoLaunch:=False; WPPDFPrinter1.InMemoryMode:=True; WPPDFPrinter1.Stream:= OutputStream; pdf := TppwPDFDevice.Create(Self); pdf.PDFPrinter.FontMode := wpUseTrueTypeFonts; pdf.Publisher := ppReport1.Publisher; //some_Report.Publisher; WPPDFPrinter1.BeginDoc; ppGlobalPDFPrinter:=WPPDFPrinter1; ppReport1.PrintToDevices; WPPDFPrinter1.EndDoc; pdf.Free; end |