010-68421378
sales@cogitosoft.com
Your location:Home>News Center >Industry News

PDF document in a report – using of new TfrxPDFView object

latest update:2021/12/21 Views:457
First of all, FastReport VCL is a report generator. Based on this conclusion, we can assume that previewing or embedding documents of other formats into a report is excessive. But according to requests from our customers, we can see the opposite point of view. Many of our customers are solving tasks with the integration of new and old systems.

First of all, FastReport VCL is a report generator. Based on this conclusion, we can assume that previewing or embedding documents of other formats into a report is excessive. But according to requests from our customers, we can see the opposite point of view. Many of our customers are solving tasks with the integration of new and old systems. Such an old system may contain already prepared documents that need to connect to the new reports. In other words – embed and view documents of third-party formats into a report adding new pages or fields to it.

For such tasks in FastReport VCL 2021.3 we have added the new report object - TfrxPDFView. This object uses the Open-source library Pdfium and is designed to view PDF documents in a report. You can build this library from the source code or use one ready-to-use from FastReport VCL installation package (frx_pdfium.dll and frx_pdfium_64.dll in Bin folder). After the manual build, you need to rename the library to frx_pdfium.dll for 32-bit system and to frx_pdfium_64.dll for 64-bit system. For the manual build, you need Visual Studio and Google depot_tools.

As was written above you don’t need to build Pdfium, you can use prepared libraries from the FastReport VCL installation package, but if your company has a security limitation and requires to build all code on your side use links from above.

The TfrxPDFView can draw documents both on one and several report pages. Using the ability of the report engine to split objects. Let’s check more closely how to use this object and what ability it provides.

After clear installation latest FastReport VCL 2021.3 version this component should appear on Delphi’s components palate in FastReport VCL section.

 

 

Just place the TfrxPDFObject on the application form, to use the TfrxPDFView at Run-time. If you started with new project also add the TfrxReport component to a Form and with a double click on it call the report designer.

 

Then click on the PDF Object in the report designer objects panel and create a new object on the band in the report. Just like any other FastReport VCL object.

 

The object was created. After that, the object editor should appear which allows loading a PDF document.

TfrxPDFView allows printing multi-page documents. Special for this TfrxPDFView has new properties.

DetailStretchMode property is responsible for displaying the content inside the container of the object and can be one of the following values:

pdOneToOneStrongStretch – a page is always stretched using report object size. It does not keep the aspect ratio.

pdOneToOneNormalize – a page is always stretched and keeps the aspect ratio of the original page in a PDF document.

pdManyToOneNormalize – allows to fit several pages into the report object area and keeps the aspect ratio of the original page in a PDF document.

 

 

Printing of multi-page PDF document

FastReport VCL allows printing PDF documents as one page of a PDF document onto one page of the report for each page of a PDF document.

We already created and load a PDF document on the Report Title band in the report. Let’s stretch it to the whole page of the report template page. It should look like the picture below.

 

 

If we click on the report preview now, we will see only one page of the load PDF document even when a document has more than one page. To print all the pages, we need to perform a series of steps.

Step 1. Turn on AllowSplit and Stretched properties and set them to True in the band object which has TfrxPDFView as a child. We need this band for stretches and splits.

Step 2. Set StretchMode property to smActualHeight or smMaxHeight on the TfrxPDFView object. This object can stretch now.

Let’s run the report preview and check the report output.

 

 

FastReport VCL prints all pages of PDF document each on the report page.

The TfrxPDFView object has and other properties. The “Password” property sets a PDF document password. “DrawOptions” flags allow controlling document output.

 

In addition, you can use a file name as a source for TfrxPDFView object by using FileLink property. And that’s not all! With the new DataLink property, it’s possible to load documents even through http and https protocols.

Now FastReport VCL can print PDF documents inside a report and not only generate them!

Next:HOW TO INSTALL QUARKXPRESS 2021 ON MAC?
Prev:Bluebeam:Best practices for measurement markups

© Copyright 2000-2023  COGITO SOFTWARE CO.,LTD. All rights reserved