How to Merge Multiple Reports into a Single PDF in .NET
Merging multiple reports together is one of the most commonly asked questions from our customers in many business environments.
For example, say your organization has multiple offices across the world and each office has its own report showcasing the sales for a particular year. You are asked to create a presentation that analyses the company’s sales, by region. You have multiple sales reports, you need to analyse and present all of the sales data in one report. In this use case, all of the reports will need to be merged together into a single PDF.
This article demonstrates how to merge multiple reports together into a PDF using .NET framework. PDF for .NET uses familiar .NET syntax to generate PDFs from your C# or VB.NET applications. These PDFs can be generated from UI elements, like grids and charts, HTML, or data sources. PDF for .NET supports commonly used PDF features like forms, security, compression, and more.
We will be using ComponentOne PDF in this demo. ComponentOne PDF actually allows you to create PDF documents from an application.
Merging Multiple Reports Together using the .NET framework
Step 1:
Create a list of C1FlexReport objects and add reports to it by creating an extension method for C1PdfDocument.
Step 2:
Get each page from every report object after rendering. Now, draw this retrieved C1Page on a specified C1PdfGraphics.
The extension method (RenderPdf) accomplishes this step.
Step 3:
Add C1FlexReport objects to a C1PdfDocument and save the file using C1PdfDocument’s save method.
Step 4:
The resultant PDF file can also be displayed in C1FlexViewer using C1PdfDocumentSource.
After this step, you will have a merged PDF file containing all the reports together.
Learn more about PDF for Winforms
Download C# sample
Download VB sample
If you have any questions about this tutorial, please leave us a comment. Additionally, if you have a request for a specific demo, be sure to leave a comment below!