FastReport

FastReport is a widely used reporting tool for Delphi. To use FastReport in a uniGUI application there are certain rules to follow. The FastReport engine must be adjusted so it can cope with uniGUI's multi-threaded environment.

1

1) Adjust the report engine parameters

Assume Report is a TfrxReport object. Set the engine options as follows:

Engine options
Report.EngineOptions.SilentMode := True;
Report.EngineOptions.EnableThreadSafe := True;
Report.EngineOptions.DestroyForms := False;
Report.EngineOptions.UseGlobalDataSetList := False;

These options ensure the report engine runs quietly and is safe for the multi-threaded uniGUI environment.

2

2) Adjust the report settings

Disable dialogs and editing in the report preview:

Report settings
Report.PrintOptions.ShowDialog := False;
Report.ShowProgress := False;
Report.PreviewOptions.AllowEdit := False;
3

3) Configure the export component (PDF example)

To export to PDF use the TfrxPDFExport component and set its properties:

PDF export settings
Exp.Background := True;
Exp.ShowProgress := False;
Exp.ShowDialog := False;

// Assign a unique exported file name
Exp.FileName := UniServerModule.NewCacheFileUrl(False,'pdf','','', AUrl);
Exp.DefaultPath := '';
4

4) Generate and export the report

Prepare and export the report programmatically:

Generate & export
Report.PrepareReport;
Report.Export(Exp);
5

5) Show or send the generated report

There are two common ways to present the generated PDF to the user:

  • Show it inside uniGUI using either TUniURLFrame or TUniPDFFrame.

    • Example for TUniURLFrame:

      TUniURLFrame usage
      UniURLFrame1.URL := AUrl;
      PDF Viewer using TUniURLFrame
    • Example for TUniPDFFrame:

      TUniPDFFrame usage
      UniPDFFrame1.PdfURL := Url;
      PDF Viewer using TUniPDFFrame
  • Or send the file to the user for download:

Send file to user
UniSession.SendFile(Exp.FileName);