Friday, March 23, 2012

Report Viewer Control - Export to PDF, Works on local IIS computer, but not another.

When exporting a report to a pdf file, I am experiencing what seems to be a "hang up" on the server. The code executes fine from my development machine, but when moved to the server I get this response. I also recieve this message if I click the refresh button. Acrobat could not open 'pdf9c9.tmp' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decode). To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF.

Here is my code for reference. It works fine on one IIS, but not another. What could I be missing?

Dim warningsAs Microsoft.Reporting.WebForms.Warning() =Nothing

Dim streamidsAsString() =Nothing

Dim mimeTypeAsString =Nothing

Dim encodingAsString =Nothing

Dim extensionAsString =Nothing

Dim deviceInfoAsString

Dim bytesAsByte()

Dim lrAsNew Microsoft.Reporting.WebForms.LocalReport

lr.ReportPath ="Report1.rdlc"

'lr.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DischargeSummary", ObjectDataSource1()))

deviceInfo ="<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"

bytes = ReportViewer1.LocalReport.Render("PDF", deviceInfo, mimeType, encoding, extension, streamids, warnings)

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType ="application/pdf"

Response.BinaryWrite(bytes)

Response.Flush()

Response.Close()

Check security permission on the server.

No comments:

Post a Comment