Opening a PDF

J

Jim Willis

Hi,

I have an application that returns a PDF document to the browser (not as a
download). The document is returned in a new window. This works fine in
most installations, but I have one installation where it doesn't work in IE,
but does work in Netscape. At the installation where it doesn't work IE
returns the file download dialog box instead of just opening the file. When
I click open or save it complains that it can't find the file. I suspect
the problem is with the file name. IE is generating a very long file and
I'm guessing it is getting confused. My code did not originally set the
file name, so I'm trying to solve the problem by setting the file name.
Here's the code that I'm using, but it doesn't seem to have any affect.
Does anyone see why this doesn't work? objHttpConn is an HTTP control that
is used to retrieve the PDF document.

PS We are hosting the web sites where it does work and were it doesn't work
and I'm testing using my PC. The only difference is the version of the
application that returns the PDF document. All the machines are 2000
servers with IE 6.0 SP1.

Thanks
Jim

Response.Clear()
Response.ContentType = objHttpConn.getResponseHeader ("Content-Type")
if Instr(1,Response.ContentType,"pdf",vbTextCompare) > 0 then
Response.AddHeader "Content-Type", "application/pdf"
Response.AddHeader "Content-Disposition",
"inline;filename=Statement.pdf"
Response.BinaryWrite objHttpConn.ResponseBody
else
Response.Write objHttpConn.ResponseText
end if
 
J

Jim Willis

PS Here're the file names that I get when I save the documents once they
are opened in Netscape.

This is from the site that works both in IE and Netscape
C__Documents and Settings_jwillis_Application
Data_Mozilla_Profiles_default_zr4dozb8.pdf

This is from the site that only works in Netscape
C__Documents and Settings_jwillis_Application
Data_Mozilla_Profiles_default_zr4dozb8.slt_plugtmp_StatementRequest.pdf
 
J

Jim Willis

I was able to solve the problem. I have an include file that tries to force
the browser not to cache any of our pages. This included adding items such
as Reponse.AddHeader "pragma", "no-cache" and a few other items. I thought
the Reponse.Clear would remove these items, but after removing that include
file it fixed the problem. Also, we have a setting that controls when
caching is disabled, so that's probably why it works in one installation and
not another.
 

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

Forum statistics

Threads
474,141
Messages
2,570,816
Members
47,362
Latest member
ayamcy

Latest Threads

Top