XtremeDocumentStudio Delphi
Next-generation multi-format document-processing component suite for Delphi/C++Builder developers
Compatibility
VCL - FireMonkey - Delphi - C++Builder

Export FastReport reports to PDF, RTF, plain text and image formats using Delphi

Learn to export FastReport reports using XtremeDocumentStudio Delphi.
By Manikanta Sai Prasad

Gnostice XtremeDocumentStudio Delphi is the next-generation multi-format document-processing component suite for Delphi/C++Builder developers. Currently, it includes VCL components for viewing, printing, and converting PDF, DOCX, BMP, JPEG, PNG, WMF, EMF, and single-page and multi-page TIFF. Apart from VCL, XtremeDocumentStudio also includes FireMonkey support. Its FireMonkey document viewer can display PDF and images on Windows, Mac, iOS [PREVIEW] and Android platforms with varying levels of support. With the optional StarDocs integration, full support is available on all these platforms.

In the latest release of XtremeDocumentStudio Delphi, we have introduced a new report-export component for FastReport. You can export FastReport reports to multiple formats including PDF, PDF/A, XLSX, RTF, HTML, XHTML, TXT, SVG, PNG, JPEG, and GIF. You do not have to write a lot of code for interfacing with FastReport components. It will all be done automatically.

Just drop the new TgtFRExport component on the form of your FastReport project and connect it to a TfrxReport component. The TgtFRExport component will then automatically take care of interfacing with the TfrxReport and exporting the report content to the above-mentioned formats. When you execute the report "Preview" option, the new formats will be automatically available as extra options. You can also export the report totally programmatically without any intervening GUI.

In this article, we will first create a FastReport report and then export it to various formats using XtremeDocumentStudio.

Create a sample FastReport report

  1. Start your IDE and create a new VCL Forms project.
  2. Drop these components on your form:
    • TfrxReport
    • TfrxDBDataset
    • TADODataSet
    I had set the TADODataSet object with the Microsoft Access NorthWind database, as it requires minimal components. You can connect the TfrxDBDataset to some other valid dataset on your computer.
  3. Set the DataSet property of TfrxDBDataset to the TADODataSet object.
  4. Double-click the TfrxReport component to start the report designer.
  5. Change the Page size to a comfortable envelope size.
  6. Select the "Report" node in the Report Tree and change its DataSet property to TfrxDBDataset.
  7. From the Data Tree, drag and drop the fields on to the page to create connected TfrxMemoView objects on the report.
  8. From the main menu of the designer window, choose to save the report to a .fr3 file.
    Save this FastReport report as an FR3 file.
  9. From the main menu of the designer window, choose to Preview the report.
  10. In the Preview window, choose to save the report to a "Prepared Report" (with .fp3 extension).
    Save this prepared report as an FP3 file.

Exporting FastReport reports to XtremeDocumentStudio-supported formats

Here comes the exciting part. XtremeDocumentStudio provides two ways of exporting your FastReport reports - programmatic and interactive.

Programmatic export of FastReport reports

Continuing with the above project, add two buttons to the form and set their "click" event handlers like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  frxReport1.LoadFromFile('XDoc_FastReport_Report.fr3');
  frxReport1.PrepareReport(true);
  gtFRExport1.ExportToFile(frxReport1, 'fr_export', TgtxOutputFormat.PDF);
  gtFRExport1.ExportToFile(frxReport1, 'fr_export', TgtxOutputFormat.RTF);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  frxReport1.PreviewPages.LoadFromFile('XDoc_FastReport_PreparedReport.fp3');
  gtFRExport1.ExportToFile(frxReport1, 'fr_export', TgtxOutputFormat.PDF);
  gtFRExport1.ExportToFile(frxReport1, 'fr_export', TgtxOutputFormat.RTF);
end;

For this example, the reports are exported only to PDF and RTF. XtremeDocumentStudio supports more formats than that.

Interactive export of FastReport reports

If you execute the report preview in either case and don't touch TgtFRExport component, you will still have the new formats in options for saving the report, as shown below. To show the preview, you will need code like this:

frxReport1.LoadFromFile('XDoc_FastReport_Report.fr3');
frxReport1.PrepareReport(true);
frxReport1.ShowPreparedReport;

//... or ...

frxReport1.PreviewPages.LoadFromFile('XDoc_FastReport_PreparedReport.fp3');
frxReport1.ShowPreparedReport;

You can limit the choice of formats by modifying the VisibleFormats property of the TgtFRExport component.

The TgtFRExport component has a EncodersSettings (TgtxStandardEncodersSettings) property with which you can specify format-specific settings for the export. For example, if you are exporting to PDF, you can have it encrypted with owner and user passwords.

Notice something new in the Object Inspector? XtremeDocumentStudio can now output PDF/A documents.

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .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
XtremeDocumentStudio 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
XtremeDocumentStudio (for 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-2017 Gnostice Information Technologies Private Limited. All rights reserved.