OutputStream.Write with PDF resulting in blank page in IE

G

Guest

I’m attempting to stream a PDF to the browser so that the user will get the
appearance of just opening the PDF in Explorer. The PDF is being generated by
the SQL Server Reporting Services web service as a byte array (I’ve already
checked that this is working as expected).

My problem is that Explorer just loads a blank page, and reports “Done†in
the status bar. If I hit Refresh, it prompts me to “resend the informationâ€,
on clicking Retry, IE loads the PDF successfully. If instead of Refresh, I
click in the Address bar and hit Enter, the PDF loads successfully without
prompting.

How can I get this to work properly (i.e. without needing to reload the page)?

I’ve tried various alternatives without success, PLEASE HELP!

I’m currently using the following code (where pdfReport.RenderedReport is a
property returning the byte array):

Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("content-length", _
pdfReport.RenderedReport.Length.ToString)
Response.OutputStream.Write(pdfReport.RenderedReport, 0, _
pdfReport.RenderedReport.Length)
Response.Flush()

Many thanks in advance,
Rob
 
T

Tom.PesterDELETETHISSS

Thats difficult to diagnose. Do you have a live url where I can test the
download?

Let me know if you have any more questions..

Cheers,
Tom Pester
 
G

Guest

Tom,

Unfortunately not. It's not on a live server yet (may not be until I make it
work!), and I probably wouldn't be allowed to give you access to it if it was.

Any ideas that I could try?

Cheers,
Rob
 
T

Tom.PesterDELETETHISSS

I remember I had something similar a long time ago where a refresh made it
work. I dont remember what it was but I tweaked the code just a little to
make it work.
Ic you start with a response.clear which is very necessary cause it get rids
of headers asp sets before your code. Maybe it was the sequence of statements.
Try to rearrange the code maybe and see how other samples do it:
http://www.google.com/search?hl=en&lr=&c2coff=1&biw=1470&q=asp.net+pdf+stream&btnG=Search

Have you tested it in other browsers like Opera or Firefox or maybe a different
version of IE? Some IE versions have bugs when it comes to receiving streams.
Maybe its the PDF plug-in that's making the mistake or maybe you tell IE
the wrong lenght of the file. if the length is zero based than you could
try to add 1 to it.

Finally i would see what headers are being sent to IE cause they should be
different somehow. Try this free utility:

http://www.blunck.info/iehttpheaders.html

Just some thoughts... gl !

Cheers,
Tom Pester
 
G

Guest

Tom,

I upgraded to Acrobat Reader 7 and my code works now.

Thanks for the help.

I'm now going to put a picture of the Adobe logo on a dart board.

Cheers,
Rob
 
T

Tom.PesterDELETETHISSS

I remember too that a refresh did show the pdf. I think we had the same problem.

I found a trace on this page :
http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerBugs
(In the section "PDF viewing from an ASPX is broken in XP SP2")

If its a cache bug you could make ever pdf unique by adding a timestamp to
the url (doc.pdf?data=120220050606)

Or you could advice your visitors to upgrade to version 7 of AR. There is
also a problem with IE in that it passess compressed pages (or pdf files)
withoput uncompressing to a plug in.
If you are compressing content you could disable it maybe.

Cheers,
Tom Pester
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top