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,
- 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.
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?
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.
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 the resource file.
I have tested the scenario where I first created a copy of sample.pdf
and tried concatenating these two documents using the following code snippet. Based on my observations, the resultant file properly shows the file contents. I tested this scenario using Aspose.Pdf for .NET 7.7.0. For your reference, I have also attached the resultant PDF file generated on my end.
[C#]
// Create PdfFileEditor object
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: