I've been having a bit of an issue, trying to merge pdf files with the code below;
which works in our test environment, however, when we move to production environment
only page 1 of the merged pdf is created, and adobe gives this error when trying to view page 2 onwards...
"There was a problem reading this document (14)"
environment: VS2013/C#/ASP MVC
TIA
- Code: Select all
ReportViewer rv1 = new ReportViewer();
ReportViewer rv2 = new ReportViewer();
ReportViewer rv3 = new ReportViewer();
ReportViewer rv4 = new ReportViewer();
PdfDocument _PDF1= new PdfDocument();
PdfDocument _PDF2=new PdfDocument();
PdfDocument _PDF3= new PdfDocument();
PdfDocument _PDF4= new PdfDocument();
PdfDocument pdfMerged= new PdfDocument();
byte[] File1 = null;
byte[] File2 = null;
byte[] File3 = null;
byte[] File4 = null;
File1 = rv1.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
_PDF1.LoadFromBytes(File1);
File2 = rv2.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
_PDF2.LoadFromBytes(File2);
File3 = rv3.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
_PDF3.LoadFromBytes(File3);
File4 = rv4.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
_PDF4.LoadFromBytes(File4);
if (_PDF1 != null)
pdfMerged.AppendPage(_PDF1);
if (_PDF2 != null)
pdfMerged.AppendPage(_PDF2);
if (_PDF3 != null)
pdfMerged.AppendPage(_PDF3);
if (_PDF4 != null)
pdfMerged.AppendPage(_PDF4);