Error opening document

Error opening document

Forum member · Mar 9, 2006
I am getting an error when trying to open/view the pdf document. Acrobat reader says that the file cannot be found. It happens all the time, on multiple machines using IE, when I try to force the download. I have done this using both of the code segments below. MyDocument.DrawToWeb(Me.Page, "Test.pdf", True) Response.End() or Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment; filename=Test.pdf") Response.BinaryWrite(MyDocument.Draw) Response.End() The open or save dialog comes up and when I choose to save, it saves fine and I can then open the saved file. But, if I choose to open from the dialog box I get a "The was an error opening this document. This file cannot be found." error message. When I dont force the download, it works in some browsers some of the time. I would prefer not to save the document to the server and then push it to the browser. If I reinstall acrobat reader on the machine it seems to correct the problem, but I also cannot request that all my users reinstall their reader. What would be causing this error and how can I fix it? TIA, Jeff

Re: Error opening document

Support · Mar 9, 2006
Hello Jeff, If you would like the PDF to open up directly in the browser you should use the DrawToWeb overload that just takes the page and the string like: MyDocument.DrawToWeb(Me.Page, "Test.pdf") Response.End() Also, make sure that you are not setting any other headers or writting anything to the Response object before the PDF is draw. If you are remove this and try again. If you have tried the code above (and removed any writing to the Response object) then we will need to take a look at the HTTP headers coming back from the server here. You will need to use a tool like ieHTTPHeaders to view the headers. Then post the results and we will see if anything looks out of place. Thanks, ceTe Software Support Team

Re: Error opening document

Forum member · Mar 13, 2006
Sorry for the late response to my original question. I wanted to post the solution that I found to work. As posted in previous questions making sure to add the Response.End() statement helps, but I found that it does not completely correct this issue with IE. You need to be sure that the Response and it's Headers have been cleared prior to writing the pdf to the response stream. I also added the command to buffer the entire pdf before displaying it even though this is probably unnecessary. Response.Clear() Response.ClearHeaders() Response.BufferOutput = True MyDocument.DrawToWeb(Me.Page, "Test.pdf", False) Response.End() It will also work with this code, which just basically does what the DrawToWeb function does. Response.Clear() Response.ClearHeaders() Response.ContentType = "application/pdf" 'Response.AddHeader("Content-Disposition", "attachment; filename=attachment.pdf") Response.AddHeader("Content-Disposition", "inline; filename=inline.pdf") Response.BufferOutput = True Response.BinaryWrite(MyDocument.Draw) Response.End() Hope this helps those that have come across this situation. Jeff Brint

Re: Error opening document

Forum member · Nov 10, 2009
Just wanted to say thanks for this post...the Response.BufferOutput = True is exactly the fix i was needing to get drawtoweb to work. This is great! solved a 4 hour search. thanks!!!!