Providing multiple .rdlc reports to a single PDF file using PDFSharp

I run several reports and combine them into one PDF file. For each report, I pass the data source, parameters and report path to the next. The result is a PDF file with the correct number of pages, but all pages are empty. What am I missing?

LocalReport report = null; PdfDocument pdfDoc = new PdfDocument(); private void ProcessReport( ReportDataSource reportDS, ReportParameter[] reportParms, string reportPath) { string format = "PDF"; string deviceInfo = null; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; Warning[] warnings = null; string[] streamIDs = null; report = new LocalReport(); report.EnableExternalImages = true; report.ReportPath = reportPath; if (reportParms != null) report.SetParameters(reportParms); if (reportDS != null) report.DataSources.Add(reportDS); Byte[] pdfArray = report.Render( format, deviceInfo, out mimeType, out encoding, out extension, out streamIDs, out warnings); //Stream s = new MemoryStream(pdfArray); MemoryStream ms = new MemoryStream(pdfArray); PdfDocument tempPDFDoc = PdfReader.Open(ms, PdfDocumentOpenMode.Import); for (int i = 0; i < tempPDFDoc.PageCount; i++) { PdfPage page = tempPDFDoc.Pages[i]; pdfDoc.AddPage(page); } } 
+4
source share
2 answers

Try creating reports with a different setting, as described in this section: http://forum.pdfsharp.net/viewtopic.php?p=1613#p1613

If you provide us with some files that do not work, we can try to fix this in PDFsharp.

+3
source

You need to change the line deviceInfo = null; to deviceInfo="<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>";

-1
source

Source: https://habr.com/ru/post/1402447/


All Articles