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.

Showcase Your Apps on DevExpress.com

Highlight your business app and share your development experiences with the DevExpress community. To include your app in our upcoming App Showcase, please forward an application screenshot to clientservices@devexpress.com and tell us which DevExpress products you currently use within your organization.
4 comment(s)
Gabriel Phaiphai
Gabriel Phaiphai
Great feature,
Will the report work/render on the web report viewer(ASP, MVC, Core)? 
As a wish list add the feature to web designer.
23 April 2020
Dmitry Tok (DevExpress Support)
Dmitry Tok (DevExpress Support)

Hi Gabriel,

This new control is also available in WPF and Web Report Designers. And yes, you'll be able to preview a report in web applications unless it is hosted in Linux or Azure environment. 

 

23 April 2020
Gabriel Phaiphai
Gabriel Phaiphai
That is great Dmitry,
This also means report viewer has capabilities of being a PDF viewer?
1 May 2020
Dmitry Tok (DevExpress Support)
Dmitry Tok (DevExpress Support)

Gabriel – the good news is that you can preview PDF Content inside the Report Viewer. The bad news – we are not going to make a full-featured web-based PDF Viewer. We’ve done that for WinForms and WPF and frankly delivered a ton of capabilities for desktops. We don’t expect to walk down that road on web platforms.

 

6 May 2020

Please login or register to post comments.