Reporting - Merge PDF Documents into Your Report (v20.1)

Reporting Team Blog
22 April 2020

Consider the following use case: Your company needs to issue an invoice and include tech specifications for each product listed within the invoice. The tech specifications are stored as PDF files.

If you’ve used DevExpress Reports in the past, you know that a solution exists to address this use case. With the help of our Office File API, you can merge multiple PDF files together with your report. Unfortunately, this solution does not allow you to display a preview of the merged document prior to printing/export. 

With our newest release (v20.1), we’ve addressed this limitation and eliminated the need to use our Office File API to merge PDF documents with your report. By using our new XRPdfContent report control, you embed PDF documents alongside your report and preview the complete report within our Document Viewer.

Quick note: If you’d like to merge RTF and DOCX files, use our XRRichText report control instead (XRRichText has been available for numerous years).

We’ve prepared the following video tutorial to help demonstrate XRPdfContent’s capabilities. You can download the video script here .

In the rest of this post, I’ll describe a few things you should consider when using XRPdfContent.

Primary Features 

Design-Time

As you might expect, XRPdfContent is available in the Report Designer toolbox by default. Once dropped onto a report’s surface, XRPdfContent spans the entire width of the live report area – from the left to the right side of your document’s margins. The control cannot be resized (remember that we are merging a PDF file at the end of the report, not embedding it within the report itself).

Report Designer - PDF Content Control Drag and Drop

This implementation mirrors merge operations when using subreports. The following diagram illustrates the merge logic behind XRPdfContent.  

Pdf Content Control - How it works

The control exposes two properties: Source and SourceUrl. Both properties can be bound to a data source field or expression. You can load a PDF file using the Source property. When specified, PDF content will be stored within your report definition and serialized together with a report’s layout. The SourceUrl property allows you to specify a path to a local file or a URL: 

Report Designer - PDF Content Control

To load PDF content, you can specify either of these properties, or you can simply drop a PDF file onto the report’s design surface.

Runtime Experience

XRPdfContent includes the following runtime characteristics and limitations:  

  • The page generation engine always surrounds PDF content with page breaks. This means that PDF content always starts with a new page and report document continues printing on a new page (after PDF content). 

  • PDF content is displayed as an image in Print Preview (text selection is unavailable). If you’d like to enable text selection, simply export the report to PDF.

  • When using a Linux-based environment or Azure hosting, you can only programmatically export a report to PDF. Previewing reports and exporting to other formats is not yet supported.

Your Feedback Counts 

We expect to refine the capabilities of XRPdfContent in future updates. Please share your thoughts/comments below and tell us how you’d like us to improve DevExpress Reports in our next release cycle.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.