logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to combine multiple reports into one PDF file in Delphi / Lazarus / C++ Builder
  • How to make a PDF from Delphi / C++Builder / Lazarus

    May 14, 2020

    Quite often, you need to get a PDF document from a Pascal application - either

    read more
  • Web reports in Lazarus on Linux

    December 15, 2020

    Until recently, the task of generating reports through the Web from an application written in

    read more
  • Turn database data into a document in Delphi / Lazarus / C++ Builder

    February 3, 2021

    How to make a mush of data into an informative report? Oracle DB, MySQL, Microsoft SQL

    read more
  • Make Drill-Down report in FastReport VCL (Delphi/Lazarus)

    February 9, 2021

    "Drill Down" or "deepening into data" is a concept with many sides, which can refer

    read more
  • Installing FastReport in Lazarus

    March 17, 2021

    As part of the Academic's educational programme, we have decided to produce some support articles

    read more

How to combine multiple reports into one PDF file in Delphi / Lazarus / C++ Builder

September 3, 2020

It is often necessary to combine several documents into one (for example, PDF). It could be several chapters of documentation, catalog directories etc. Strictly speaking, this sometimes needs to be done not only for PDF, it’s just that this file format itself does not imply editing and “merging” without special tools, so it would be better to do it correctly right away.

Today I will tell you how to do this in FastReport VCL and FMX. In our case, there will be several reports at the input and one file at the output.

So, I suppose we already have a project using FastReport and the templates are prepared. In our example, these are files on the local storage but nothing prevents from taking them from the database or some other sources. Now we need to combine two (or more) reports into one large file.

For this, FastReport has tools that allow us to attach a new report in addition to the existing one. The TfrxReport.PrepareReport method has one optional ClearLastReport: Boolean parameter which is set True by default. This parameter determines whether the pages of the previously built report should be cleared. The following example shows how to build a package of two reports:

Pascal:
1
2
3
4
5
frxReport1.LoadFromFile('1.fr3');
frxReport1.PrepareReport;
frxReport1.LoadFromFile('2.fr3');
frxReport1.PrepareReport(False);
frxReport1.ShowPreparedReport;

 

C++:
1
2
3
4
5
frxReport1->LoadFromFile("1.fr3");
frxReport1->PrepareReport(true);
frxReport1->LoadFromFile("2.fr3");
frxReport1->PrepareReport(false);
frxReport1->ShowPreparedReport();

Load the first report and build it without displaying it on the screen. Then load the second report into the same TfrxReport object and build it with the ClearLastReport = False parameter. This adds the second report to the previous one.

Obviously, we can repeat the two penultimate lines to add some more reports to our complex composite report. And this part is only possible from the code.

When we have built everything, we can see the combined reports in the preview window and easily save this file in any format and location from it.

Saving the combined report as PDF.

After we managed to combine two reports into one we simply export it to PDF (or, in fact, to any file format – for example, RTF/DOC/ODT or tabular – but it is not so difficult to combine them after export while it is relevant for PDF). Here you can let the user select the file format for saving and settings:

Click on the Save icon in the preview.
Select the required format – PDF.

We can see the Export settings window.

Configure everything that we need.

For more information about creating and configuring, see the article: 

Click OK when finished!

Or something like that   "FrxReport1.Export (frxPDFExport1);"

I described the parameters of saving in various formats from the Delphi, Lazarus, and C ++ Builder code in more detail in previous articles.

We can open the resulting document after creation. Having opened the file, we will see a consistent display of our reports in one PDF document.

Combining two PDF reports from Delphi, Lazarus, and C++ Builder is not as difficult as it might seem.

about product download buy
avatar
Michael Philippenko
VP
Fast Reports Team: Michae Philippenko - VP at Fast Reports
VCL Export Lazarus PDF FastReport 6 Delphi

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Extended licensing
  • Contact us

© 1998-2022 by Fast Reports Inc.

  • Privacy Policy