Reporting - Embedding PDF Files

Purpose

The purpose of embedding PDF files within a Perfion report is to include a pre-constructed PDF document within your report reusing existing content, e.g. creating a report with PDF file content and headers / footers that are printed on PDF file pages. The functionality can also be used to link to a data source to dynamically return documents linked to the records associated with the report.

Prerequisite

Minimum version of 2021-R2 (4.10.x) required

Embedding PDFs

This chapter describes how to embed PDF files within reports. This feature is an extension of DevExpress feature XRPdfContent.

Click on the Insert PDF tool button to insert the PDF into the report at the desired location. Note the PDF will be rendered in its original size, changing the Size attributes will not affect the area of the PDF displayed.

It is possible to load both a static PDF file from networked or local drive (Source), from a web location (Source URL) or from a data source by creating the Data Binding.

Static PDF

A static PDF file can be loaded outside the detail band to appear once in the report, or placing within the detail band will render the PDF once per item.

Simply click the Source ellipses in the PDF Content Tasks dialog control and navigate to your chosen PDF file. Note this file needs to be present at that location during report generation, the report designer only stores a path to the file. Upon production of the report, the PDF is embedded into the report and is no longer dependent on the source PDF, therefore it can be exported as a new PDF for example.

PDF From Datasource

Perfion can use the File API to retrieve a PDF from a data source. Place the PDF report control in the detail band at the desired location.

In the PDF Content Tasks on the second Data Binding select the attribute that contains the PDF content. Ensure this comes from Structure Item or Structure Types sections for a left side report.

In the image below, InstructionsPDF is the feature containing the PDF files. Note in the case of multiple values allowed for the feature, only one will be displayed.

With the data source set, switch to the Properties dialogue for the PDF control (ensure the control has the focus within the report). Switch to the Data section (yellow database icon in the centre of the five icons) .

Expand Data Bindings and Source URL sections as below. You should see the data binding to the PDF feature which you defined in an earlier step. This is the GUID of the file, we will now construct a call to the File API by specifying a prefix.

Constructing the Report API call

You will need to know the address of your API service and apply as follows:

Binding Prefix

http://<ServiceHostName>/Perfion/File.aspx?id=

Add this prefix to the Format String section as follows: click on the ellipses next to the blank box.

Add the binding prefix in General\Prefix as below:

You can now dynamically retrieve the PDF file at runtime to be displayed within the report.

If you do not know the address of your Perfion API

If this is not known, you will need to determine this from the server your Perfion API is installed on. From the server, open Internet Information Services (IIS) Manager.

Navigate to the Perfion API website, right click and choose Edit Bindings.

 

The example above has two bindings, therefore the site can be accessed via http://api.local or http://localhost:8080 (the latter only when using a client on the same machine). The API File service for this example is therefore http://api.local/Perfion/File.aspx (for more details about the API service, see Perfion API Reference).

The image below shows the PDF guid rendered on the report as well as the embedded PDF. This can be repeated for multiple items with reports.

NOTE: PDF documents will be displayed in their original size as currently there is no possibility to amend the size they are displayed at.

Â