PDF Generates blank pages

Hi All,

Im using Aspose version 6.2.0.0
My application is running in .net 4.0 (VS2010) Web Application
Im using ReportViewer as the source for my PDF data
Now when I try to run the page in the browser I’m getting blank page for all the pages. It does generate 6 pages but all are blank.
I’ve verified my code and the ReportViewer does displays the data. But when I fed the data to the PDF viewer then i’m getting blank pages.
In firefox I’m getting “This PDF document might not display correctly.

I appreciate it much if anyone can give some thoughts on this. Thank you.

I have the following code to generate the PDF using MemoryStream

Aspose.Pdf.License lic = new Aspose.Pdf.License();
lic.SetLicense(System.Web.Hosting.HostingEnvironment.MapPath(”~/Aspose.Pdf.lic"));

Warning[] warnings = null;
string[] streamids = null;
string mimeType = string.Empty;
string encoding = string.Empty;
string ext = string.Empty;

byte[] buffer1 = this.ReportViewer1.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
byte[] buffer2 = this.ReportViewer2.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
byte[] buffer3 = this.ReportViewer3.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
byte[] buffer4 = this.ReportViewer4.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
byte[] buffer5 = this.ReportViewer5.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);

MemoryStream fileStream1 = new MemoryStream(buffer1);
MemoryStream fileStream2 = new MemoryStream(buffer2);
MemoryStream fileStream3 = new MemoryStream(buffer3);
MemoryStream fileStream4 = new MemoryStream(buffer4);
MemoryStream fileStream5 = new MemoryStream(buffer5);

using (MemoryStream pdfStream = new MemoryStream()) {
Aspose.Pdf.Facades.PdfFileEditor pdfEditor = new Aspose.Pdf.Facades.PdfFileEditor();
using (MemoryStream fileStream1 = new MemoryStream(buffer1)) {
using (MemoryStream fileStream2 = new MemoryStream(buffer2)) {
pdfEditor.Concatenate(fileStream1, fileStream2, pdfStream);
}
}

using (MemoryStream fileStream3 = new MemoryStream(buffer3)) {
pdfEditor.Concatenate(pdfStream, fileStream3, pdfStream);
}

using (MemoryStream fileStream4 = new MemoryStream(buffer4)) {
pdfEditor.Concatenate(pdfStream, fileStream4, pdfStream);
}

if (_quoteType.ToLower().Equals(“age”)) {
byte[] buffer6 = this.ReportViewer6.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
using (MemoryStream fileStream6 = new MemoryStream(buffer6)) {
pdfEditor.Concatenate(pdfStream, fileStream6, pdfStream);
}
if (_hasAddPlans) {
byte[] buffer6Add = this.ReportViewer6Add.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
using (MemoryStream fileStream6Add = new MemoryStream(buffer6Add)) {
pdfEditor.Concatenate(pdfStream, fileStream6Add, pdfStream);
}
}
}

using (MemoryStream fileStream5 = new MemoryStream(buffer5)) {
pdfEditor.Concatenate(pdfStream, fileStream5, pdfStream);
}

if (_hasAddPlans) {
byte[] buffer5Add = this.ReportViewer5Add.LocalReport.Render(“PDF”, null, out mimeType, out encoding, out ext, out streamids, out warnings);
using (MemoryStream fileStream5Add = new MemoryStream(buffer5Add)) {
pdfEditor.Concatenate(pdfStream, fileStream5Add, pdfStream);
}
}

byte[] dataStream = pdfStream.ToArray();
Response.Clear();
Response.ContentType = “application/pdf”;
Response.AddHeader(“Content-Type”, “application/pdf”);
Response.AddHeader(“Content-Disposition”, “inline;filename=QuoteRate”);

Response.BinaryWrite(dataStream);
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
Response.End();
}

Hi Vincent,


Thanks for using our products.

I have gone through problem description and the code snippet which you have shared and as per my observations, you are first trying to read the contents of ReportViewer, rendering them to PDF format, concatenating the PDF files into single output file using PdfFileEditor and finally display/rendering the PDF file in user browser. Can you please verify that Reports are properly being converted to PDF format and once the files are concatenated, before rendering the final document to user browser, can you please save the document over system so that we can figure out that

  • Are the PDF files properly being generated ?
  • Concatenated document is being generated properly ?
  • Problem occurs when trying to display/render resultant document to user browser ?
  • Or the issue is appearing before rendering the output to user browser.

If individual PDF’s are properly being generated and problem is occurring during concatenation process,can you please share the resource PDF files so that we can test the scenario at our end.

We are sorry for this inconvenience.

Thank you so much for your quick response. I did tried everything. The stream data has bytes returned in it. I try to write it on the file but it’s still blank.

Actually this exact code works before when it was in VB.NET. We’ve converted it to C# (Separate project) and now it doesn’t work. Is there any configuration I’ve missed on this one or perhaps this is related to licensing or something?

I tried to generate the stream data from the ReportViewer and generate it to PDF and it works just fine. I think the problem is concatenating the PDF files into single file using PdfFileEditor.

vinzmvp:
Actually this exact code works before when it was in VB.NET. We've converted it to C# (Separate project) and now it doesn't work. Is there any configuration I've missed on this one or perhaps this is related to licensing or something?
Hi Vincent,

Thanks for sharing the details and sorry for the delayed response.

Please note that Aspose.Pdf for .NET is built on top of .NET Framework and irrespective of the .NET based programming language, the product should work and perform similar operations.
vinzmvp:
I tried to generate the stream data from the ReportViewer and generate it to PDF and it works just fine. I think the problem is concatenating the PDF files into single file using PdfFileEditor.
Hi Vincent,

Can you please share some sample PDF files (generated from Stream data of ReportViewer) so that we can test the concatenation scenario at our end. We are really sorry for your inconvenience.

Attached is the sample file generated with the stream data from ReportViewer. Note that the sample is generated without using aspose.

One thing, the only difference right now is we are using ReportViewer 2010. Previously it was generated using ReportViewer 2008 but I don’t think that would matter.

Thank you.

Found the culprit. Looks like Aspose pdf concatenation is not compatible with ReportViewer 10.0.0.0 (the default in Visual Studio 2010). I converted back all my reports to 9.0.0.0 (Visual Studio 2008 version) and seems to generate fine.

I hope you will look into this and support it in the future releases.

Hi Vincent,

Thanks for sharing the details and resource file.

I have tested the scenario where I have first created the copy of sample.pdf and tried concatenating these two documents using following code snippet and as per my observations, the resultant file properly shows the file contents. I have tested the scenario using Aspose.Pdf for .NET 7.7.0 . For your reference, I have also attached the resultant PDF file generated over my end.

[C#]

//create PdfFileEditor object<o:p></o:p>

PdfFileEditor pdfEditor = new PdfFileEditor();

//concatenate files

pdfEditor.Concatenate(“c:/pdftest/Sample

(1) - Copy.pdf”, “c:/pdftest/Sample
(1).pdf”, “c:/pdftest/Concatenated_output.pdf”);

FYI, Please note that we have a component named Aspose.Pdf for Reporting Services which is in fact a rendering extension of SQL Reporting Services. You may also try using this component to render .RDL files to PDF format. For further details, please visit

  • Product Overview
  • Features
  • [Integration with MS ReportViewer 2010](http://www.aspose.com/docs/display/pdfreportingservices/Integration+with+MS+ReportViewer+2010)