473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

OutputStream.Write with PDF resulting in blank page in IE

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.RenderedRepo rt, 0, _
pdfReport.RenderedReport.Length)
Response.Flush()

Many thanks in advance,
Rob

Nov 19 '05 #1
5 4038
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
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.RenderedRepo rt, 0, _
pdfReport.RenderedReport.Length)
Response.Flush()
Many thanks in advance,
Rob

Nov 19 '05 #2
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
Nov 19 '05 #3
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&l...am&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
Nov 19 '05 #4
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

"To********************@pandora.be" wrote:
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&l...am&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

Nov 19 '05 #5
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/defaul...etExplorerBugs
(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
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
"To********************@pandora.be" wrote:
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&l...0&q=asp.net+pd
f+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

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Richard | last post by:
I'm working on a site that creates mailing labels. When a label is generated, two things happen in the background with the image. First, it is saved as a smaller low-quality .gif on the server...
3
by: Zoury | last post by:
Hi folks ! :O) I'm trying to show a PDF in ASP.NET but I can't get to work properly. here's a portion of my code : '** Dim ms As MemoryStream =...
6
by: Joseph | last post by:
Hi! I have this webpage that contains some panels and buttons. I also want to output an Image to that same page, but when I save the image to the OutputStream using the Image.Save...
0
by: brrrdog | last post by:
Whenever I write to Response.Outputstream after doing a plain response.write, I get a delimiter between the two writes that is made up of three extended ascii chars (decimal equivalents 239,...
2
by: 1 | last post by:
Hi there, A while back I wrote some code using the .Net drawing libraries... this code takes a datatable and generates a pie or bar chart on the fly. The resulting image is returned using...
11
by: Random | last post by:
I have tried all the Response methods I can think of (WriteFile, BinaryWrite, OutputStream) to write the byte array of a pdf file to the response. The result looks like it's trying, it comes up as...
6
by: landers | last post by:
Hello All, I am having problems maintaining image quality when drawing text onto an image. I have a reasonable good quality GIF file with a transparent background. Whenever I write text onto...
1
by: vinodkreddy1 | last post by:
Hi, Im using the GDI and Response.OutputStream to generate the bitmap in aspx page. After doing the above said thing im giving that aspx page as imageURl to ImageButton which is the item of the...
3
by: kellygreer1 | last post by:
PHP will alllow you to build up an entire page and before sending that out as the response.... you can grab all the text and do search and replaces, add comments, make more CSS/XHTML compliant,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.