Hello,
I'm having a problem when showing SSRS report directly to PDF without ReportViewer.
In Chrome, it ended with javascript error "Fail to load resource", dark gray background and
partial loaded "loading image".
But it shows correctly on Firefox and Internet Explore.
If I use ReportViewer and choose save as PDF, it works fine.
What could be the solution?
I surfed on web for a long time and still can't get the solution.
This is my reference article:
Exporting a SQL Server Reporting Services 2005 Report Directly to PDF or Excel[
^]
I'm using Visual Studio 2012 and running on localhost.
SSRS version is [11.0.3000.0]
Google Chrome is [Version 27.0.1453.116 m]
This is my C# function.
private void PreviewPDF(string aReportCode, string aID)
{
PrepareCommonParameters();
PrepareSpecificReportParameters(aReportCode, aID);
bool allCredentialsSet;
rptviewer.Reset();
rptviewer.ServerReport.ReportServerCredentials = new ReportServerNetworkCredential();
rptviewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["RSURL"].ToString());
rptviewer.ServerReport.ReportPath = mReportPath;
rptviewer.ServerReport.GetDataSources(out allCredentialsSet);
rptviewer.ServerReport.SetParameters(mReportParameterCollection);
string mimeType, encoding, extension, deviceInfo;
string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings;
string format = "PDF";
deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>";
byte[] bytes = rptviewer.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
Response.Clear();
if (format == "PDF")
{
Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "filename=output.pdf");
}
else if (format == "Excel")
{
Response.ContentType = "application/excel";
Response.AddHeader("Content-disposition", "filename=output.xls");
}
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.Flush();
Response.Close();
}
Update! I tried both Google Chrome built-in PDF viewer and Adobe Reader 11.
Same result.
Also tested in Safari and Maxthon.
Safari is working but Maxthon don't.
Please help. I need this to be work on Chrome.
Thanks in advanced,
Linn