469,323 Members | 1,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Opening a PDF

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


Jul 19 '05 #1
3 5707
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
Jul 19 '05 #2
Jim Willis" <"nospam wrote:
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


I have seen this error before with images and text files. All incidences
share one thing with your app - they are creating on-the-fly output and
linking to it. It's a real pain to track down, but IIRC you need to ensure
the file is closed and ready before executing the link.

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #3
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.
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by PM | last post: by
14 posts views Thread by D. Alvarado | last post: by
15 posts views Thread by Umesh | last post: by
3 posts views Thread by Luke Davis | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.