FastReport Integration in Delphi: Embedding the Designer and Generating Runtime Reports
Embed a FastReport designer in Delphi, bind a dataset, generate runtime reports, export to PDF, and clean up resources to avoid leaks. Follow the step‑by‑step guide for a stable reporting solution.
10 Sept 2026, 14:48 UTC

Problem & Takeaway
Delphi developers often need to create reports that can be designed at runtime and exported in multiple formats. The FastReport library provides VCL components that let you embed a fully‑functional report designer in your application and generate reports from Delphi datasets. The key takeaway is that a correct component setup, proper dataset binding, and explicit resource cleanup are essential to avoid memory leaks and UI stalls.
Desired Outcome
By following this guide you will:
- Embed a FastReport designer in a Delphi VCL form.
- Bind a
TfrxDBDatasetto aTFDQuery(or anyTDataSet). - Generate a report at runtime and display it.
- Export the report to PDF using
TfrxPDFExport. - Ensure proper cleanup to avoid memory leaks.
Prerequisites
- Delphi 10.4 Sydney or newer (the guide uses 10.4, but syntax is compatible with earlier 10.x releases).
- FastReport for Delphi 4.10 or later installed and registered in the IDE.
- FastReport VCL components available in the component palette.
- Access to a working dataset (e.g.,
TFDQuerypopulated from a FireDAC database). - Project compiled with
UnitTestorDebugmode to catch runtime errors early.
Focused Procedure
1. Add Required Units
uses
frxClass, frxReport, frxDBSet, frxExportPDF, Data.DB, FireDAC.Comp.Client;
2. Drop Components on a Form
TfrxReport– the main engine that loads.fr3files.TfrxDBDataset– binds a Delphi dataset to the report.TfrxPDFExport– optional but required for PDF output.
3. Configure the Dataset Bridge
// Assume MyQuery is a TFDQuery already opened
DBDataSet.DataSet := MyQuery;
DBDataSet.DataSetName := 'CustomerData';
The DataSetName must match the DataSetName used in the report design.
4. Load and Prepare the Report
Report.LoadFromFile('CustomerReport.fr3');
Report.PrepareReport;
5. Show the Report (Runtime)
if Report.ShowReport then
ShowMessage('Report displayed successfully.')
else
ShowMessage('Report failed to display.');
6. Export to PDF
Report.Export(TfrxPDFExport.Create(nil));
Register the export filter once, typically in the project initialization block:
initialization
RegisterFilter(TfrxPDFExport);
7. Embed the Designer
To allow end‑users to modify the layout at runtime, embed the designer as shown:
procedure TForm1.ShowDesigner;
var
Designer: TfrxDesigner;
begin
Designer := TfrxDesigner.Create(nil);
try
Designer.Report := Report;
Designer.ShowModal;
finally
Designer.Free;
end;
end;
8. Clean Up
Always free the report and its child components after use:
Report.Free;
Expected Checks
- ShowReport Return Value –
Trueindicates the report rendered. IfFalse, check dataset connectivity and report file path. - Dataset Open – Verify
MyQuery.Active = Truebefore preparing the report. - Export File – After exporting, confirm the PDF exists at the specified location and contains the expected data.
- Memory Usage – Use the IDE’s profiler to ensure no leaks after
Report.Free.
Recovery Options
- If
ShowReportfails, catch the exception and display the error message:try…except…end;. - For large datasets, move the report generation to a background thread or apply SQL filters to reduce row count.
- In case of version mismatch, verify that the FastReport runtime libraries match the IDE’s component version; reinstall if necessary.
Limitations & Practical Verification
- FastReport components consume significant memory; monitor usage in large applications.
- Runtime designer modifications are not automatically persisted to the
.fr3file unless explicitly saved. - PDF export requires the
frxExportPDFunit; missing it will cause a compile error. - To verify, run the application, generate the report, open the PDF, and compare data rows with the dataset.
Conclusion
Embedding FastReport in Delphi is straightforward once you understand the component relationships and lifecycle. By following the steps above, you can provide users with a flexible, runtime‑editable reporting solution while maintaining application stability.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.