Click here to Skip to main content
15,880,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create multiple pdfs from single RDLC report as per pages. For e.g: If I have 3 pages in RDLC report then I want to render 3 PDFS. How can I do it. Please help.

Thanks in Advance

What I have tried:

bytes = oReportViewer.LocalReport.Render(
                    "PDF", null, out mimeType, out encoding,
                     out extension,
                    out streamids, out warnings);
Posted
Updated 3-Aug-20 4:52am
Comments
Garth J Lancaster 3-Aug-20 4:13am    
I'm not sure it's possible like that. What control do you have over the SQL statement selecting data from the data source ? (I'm thinking if you use SQL Server you can use OFFSET & FETCH to paginate the data)

1 solution

If you want to play with PDF (merge multiple into one or split one into multiple), would suggest take that as a separate task here instead of driving it through RDLC report.

Use any free thrid party library that can split a pdf into pages as per your need. Example, I would take the RDLC report and then use that as an input to PDFSharp to break it into multiple pdf's per page.
Example:
C#
// Get a fresh copy of the sample PDF file
const string filename = "Portable Document Format.pdf";
File.Copy(Path.Combine("../../../../../PDFs/", filename),
Path.Combine(Directory.GetCurrentDirectory(), filename), true);
// Open the file
PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);
string name = Path.GetFileNameWithoutExtension(filename);

for (int idx = 0; idx < inputDocument.PageCount; idx++)
{
// Create new document
PdfDocument outputDocument = new PdfDocument();
outputDocument.Version = inputDocument.Version;
outputDocument.Info.Title =
String.Format("Page {0} of {1}", idx + 1, inputDocument.Info.Title);
outputDocument.Info.Creator = inputDocument.Info.Creator;
// Add the page and save it
outputDocument.AddPage(inputDocument.Pages[idx]);
outputDocument.Save(String.Format("{0} - Page {1}_tempfile.pdf", name, idx + 1));
}

Reference: PDFsharp Sample: Split Document - PDFsharp and MigraDoc Wiki[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900