Report Manager ← Back to site

Lazarus and Free Pascal

Report Manager is available for Lazarus and Free Pascal as three packages: the reporting engine with PDF export, the LCL preview and printing, and the visual report designer, which you can embed in your own applications. The components are installed on the Reportman page of the component palette. The packages run on Windows, Linux and macOS and use the same .rep report files as the Delphi components, the .NET libraries and the Report Manager Designer.

The Linux desktop designer is built from these same packages. On macOS they build with the Cocoa widgetset, see macOS (Lazarus, Cocoa).

Requirements

The packages

PackageContentsRequires
reportman_rtl
packages/fpc/
Non-visual engine: report model, expression evaluator, data access and the PDF, SVG, HTML, CSV, text and metafile output. FCL, zcomponent
reportman_lcl
packages/fpc_lcl/
LCL runtime: TLCLReport, preview window, page setup, parameters and printing. reportman_rtl, LCL, Printer4Lazarus, DateTimeCtrls
reportman_designlcl
packages/fpc_lcl/
The embeddable visual designer TRpDesignerLCL, with the AI assistants. reportman_rtl, reportman_lcl, LCL, TurboPowerIPro, SynEdit

The three packages are run and design time: they register their components on the palette and your applications use the same units at run time.

Install from the Online Package Manager

  1. In Lazarus, open Package → Online Package Manager.
  2. Find Report Manager (category Reporting), check it and click Install.
  3. Accept the installation of ZeosDBO when the package manager asks for it.
  4. Let Lazarus rebuild and restart the IDE. The components appear on the Reportman page of the component palette.

Install from the source code

  1. Get the source code from GitHub or SourceForge.
  2. Install ZeosDBO 8.0 (from the Online Package Manager, or its zcomponent.lpk).
  3. Open packages/fpc/reportman_rtl.lpk and click Compile.
  4. Open packages/fpc_lcl/reportman_lcl.lpk and choose Use → Install.
  5. Open packages/fpc_lcl/reportman_designlcl.lpk and choose Use → Install; Lazarus rebuilds the IDE.

The packages can also be built from the command line with lazbuild, in the same order (packages/fpc/build_fpc.bat on Windows, build_fpc.sh on Linux and macOS).

Components on the palette

ComponentPackageUse
TLCLReportreportman_lclLoads a report, previews or prints it, and saves it to PDF, text or metafile.
TRpPreviewControlreportman_lclPreview control to place in your own forms.
TPDFReportreportman_rtlRuns a report and writes the PDF file, without any user interface (console programs, services, web servers).
TRpDesignerLCLreportman_designlclOpens the report designer for a report and saves the result.
TRpRulerLCLreportman_designlclThe ruler control of the designer.
TRpEvaluatorreportman_rtlThe expression evaluator of the engine, see expression evaluator.
TRpAliasreportman_rtlAssigns your own open datasets to the datasets of a report.
TRpTranslator, TRpLastUsedStrings, TRpMaskEditreportman_rtl, reportman_lclHelpers: translations, most recently used lists and masked input.

Examples

The packages include three example projects in examples/lazarus (inside the folder where the Online Package Manager installs Report Manager, or in the source code). They use the same report, sales.rep, with data that the application builds in memory, so they run without a database:

The folder postgresql adds two reports that open their own connection and SQL query on a PostgreSQL sample database (createdb.sh creates it), one with each direct driver: a FireDAC connection, which Free Pascal opens with SQLdb, and a Zeos connection. Its console program pgreport writes both as PDF; see the README.txt of the examples and macOS.

On macOS, Lazarus writes the LCL examples as application bundles (preview.app, designer.app) next to their projects, see macOS.

The snippets below show the essential lines.

Preview, print or export a report

Drop a TLCLReport on a form:

procedure TForm1.ButtonPreviewClick(Sender: TObject);
begin
  LCLReport1.Filename := 'sample4.rep';
  LCLReport1.Preview := True;    // False prints the report
  LCLReport1.Execute;
end;

procedure TForm1.ButtonPDFClick(Sender: TObject);
begin
  LCLReport1.Filename := 'sample4.rep';
  LCLReport1.SaveToPDF('sample4.pdf');
end;

PDF from a program without user interface

A console program that only needs the reportman_rtl package (add it in Project → Project Inspector → Add → New Requirement). On Linux, cthreads and cwstring must be the first units, as in any Free Pascal program that uses threads and Unicode strings:

program reptopdf;
{$mode objfpc}{$H+}
uses
  {$IFDEF UNIX}cthreads, cwstring,{$ENDIF}
  Classes, SysUtils, rppdfreport;
var
  Pdf: TPDFReport;
begin
  Pdf := TPDFReport.Create(nil);
  try
    Pdf.Filename := 'sample4.rep';
    Pdf.PDFFilename := 'sample4.pdf';
    Pdf.Execute;
  finally
    Pdf.Free;
  end;
end.

Let your users edit the reports

Drop a TRpDesignerLCL on a form. Execute opens the designer and returns True when the user accepts the changes, which are saved to the file (or, with the OnSave event or SaveToStream, wherever you keep your reports, for example a database):

procedure TForm1.ButtonDesignClick(Sender: TObject);
begin
  RpDesignerLCL1.Filename := 'sample4.rep';
  if RpDesignerLCL1.Execute then
    ShowMessage('The report has been saved');
end;

Data access

Reports connect to their databases with the same connection definitions as the designer (dbxconnections, see database connections): Zeos connections and FireDAC connections, which Free Pascal opens with SQLdb, for Firebird, PostgreSQL, MySQL/MariaDB, SQLite, SQL Server, Oracle, ODBC and other databases, and the Reportman DB Agent driver, which runs the queries on a remote database through the Hub (the engine goes to aiapi.reportman.es and the Agent to hub.reportman.es) without opening ports or a VPN. You can also give the report your own datasets, with TRpAlias or directly, as the examples do: Report.DataInfo.ItemByName('SALES').Dataset := MyDataset.

Notes