eDocEngine VCL
Create documents and reports in 18 formats
Compatibility
Delphi C++Builder

Export From ReportBuilder To PDF And Other Formats

Interactive and programmatic export from ReportBuilder using Gnostice eDocEngine VCL.
By V. Subhash

eDocEngine has "report-export interface components" for providing multiple output format support for Delphi reporting tools. For ReportBuilder, eDocEngine has the TgtRBExportInterface export interface component.

You can either let the end-user of the ReportBuilder application to choose the output provided by eDocEngine in an interactive report "Print" dialog box or you could export the report programmatically in Object Pascal.

In either case, you need to pair an instance of the eDocEngine interface component to an eDocEngine document-creation engine component. For example, to output a ReportBuilder report to PDF, a TgtRBExportInterface instance needs to be paired with a TgtPDFEngine instance on the same form as a ReportBuilder control.

Interactive ReportBuilder Report Export

If you have an existing ReportBuilder application and wish to let the end-user select the output format, then you can add eDocEngine output support without writing any code. Just follow these steps.

  1. Open the ReportBuilder project in the IDE.
  2. From the eDocEngine Additionals tab on the Tools Palette, add TgtRBExportInterface control to the form that contains ReportBuilder controls. From the eDocEngine tab of the Tool Palette, add a document-creation engine component, such as TgtPDFEngine, to the form.
  3. If you need to differentiate the eDocEngine output format from the built-in ReportBuilder output formats, then set FileDescription property of the document-creation engine. For PDF output, use a text string such as 'PDF generated by eDocEngine'. Set the Engine property of the TgtRBExportInterface control to the engine control. If you had chosen the TgtPDFEngine control, the reporting application would have automatically gained PDF output support.
  4. Set the ReportBuilder report to permit printing to a file.

Here is a tutorial on how to create a ReportBuilder report from scratch and add report-export capabilities provided by eDocEngine.

  1. Start the IDE and create a VCL forms application project.
  2. Drag and drop TppReport, TppDBPipeline, TDataSource and TADODataSet controls, one each, on the form.
  3. Select the TADODataSet control and set it up to retrieve records from a database table.
  4. Set the DataSet property of the TDataSource control to the TADODataSet control.
  5. Set the DataSource property of the TppDBPipeline control to the TDataSource control.
  6. Set the DataPipeline property of the TppReport control to the TppDBPipeline control.
  7. Add three TgtRBExportInterface controls to the form.
  8. Add three engine controls. For example, try one each of TgtPDFEngine, TgtRTFEngine and TgtExcelEngine.
  9. Set the Engine property of each TgtRBExportInterface control to one of these engine controls.
  10. Double-click the TppReport to edit the default report template.
  11. From the Fields panel, drag and drop fields to the Detail section of the report.
  12. If required, add content elements to the Header and Footer.
  13. In the Report Tree panel, select the report.
  14. In the Properties section, ensure that the AllowPrintToFile is checked.
  15. From the File menu, choose to save the report template.
  16. Close the report template.
  17. Add a button to the form and enter the following code in the event handler.
    ppReport1.Print;  // Execute the report
  18. For the AfterPrint event of the TppReport control, add the following event handler.
    Close;  // Close the form
  19. Run the project and click the button on the form.
  20. In the Print Preview window, click the Print icon.
  21. In the Print dialog, select the Print to File option.
  22. In the Type list box, select the option for PDF generated by eDocEngine.
  23. In the Where box, enter the path where the output PDF document.

Programmatic ReportBuilder Report Export

You can export ReportBuilder to eDocEngine programmatically in two ways:

  1. If you have a ReportBuilder report template, pair it with data and call the Print() method of the ReportBuilder report component. To try it out:
    • Open the IDE and create a VCL Forms Application.
    • Copy/create the following files in the current directory.
      • NorthWind Access database from the MS Office installation directory.
      • A ReportBuilder report template with data components in the Details section for fields in the Employees table.
    • Add the following components to the form.
      • TgtPDFEngine
      • TgtRBExportInterface
      • TADODataSet
      • TDataSource
      • TppDBPipeline
      • TppReport
    • Wire the components together either in the Design view or using Object Pascal.
      procedure TForm1.Demo_TgtRBExportInterface_From_Report;
      begin
        gtPDFEngine1.Preferences.OpenAfterCreate := true;
      
        gtPDFEngine1.FileDescription := 'Adobe PDF Files (Generated by eDocEngine)';
        gtRBExportInterface1.Engine := gtPDFEngine1;
        gtRBExportInterface1.MetafileAsRasterImage := True;
      
        ADODataSet1.ConnectionString :=
           'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FPNWIND.MDB;' +
           'Mode=Read;Persist Security Info=False';
        ADODataSet1.CommandText := 'SELECT * FROM EMPLOYEES';
        DataSource1.DataSet := ADODataSet1;
        ppDBPipeline1.DataSource := DataSource1;
        ppReport1.DataPipeline := ppDBPipeline1;
      
        ppReport1.Template.FileName := 'rb_template.rtm';
        ppReport1.AllowPrintToFile := True;
        ppReport1.TextFileName := 'sample_rb_report_export.pdf';
        ppReport1.Print;
      end;
      
    • Run the report and the print it.
    • In the Print dialog box, choose to print to file, set the file type to 'eDocEngine-Generated PDF Document' and click OK.
  2. If you have a .RAF file, use the RenderDocument() method of the TgtRBExportInterface component, as shown below:
    {
     Add the following components to a form.
      1. TgtRBExportInterface
      2. TppArchiveReader
    }
    procedure TForm1.Demo_TgtRBExportInterface_From_RAF;
    var
      gtPDFEngine1: TgtPDFEngine;
    begin
      // Create a PDF engine
      gtPDFEngine1 := TgtPDFEngine.Create(Nil);
    
      // Set output file name for the PDF engine
      gtPDFEngine1.FileName := 'sample_rb_export.pdf';
    
      // Connect report export interface to PDF engine
      gtRBExportInterface1.Engine := gtPDFEngine1;
    
      // Read report
      ppArchiveReader1.ArchiveFileName := 'sample_RB_report.raf';
    
      // Generate report
      ppArchiveReader1.PrintToDevices;
    
      // Export generated report to PDF
      gtRBExportInterface1.RenderDocument(TppReport(ppArchiveReader1));
    
      // Clean up
      ppArchiveReader1.Reset;
    end;
    

---o0O0o---

Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved.