Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to stop Acrobat from opening PDF in web browser

Status
Not open for further replies.

ikonpro

Technical User
Jun 21, 2001
189
US
Acrobat 6
Explore 6
Win XP Pro

I have tried changing the preferences in Acrobat so that when I click on a pdf in the web browers it will automatic save and not open Acrobat. So far changing the prefs have not helped. Is there any other place to change is feature or how can I correct this problem.
Thanks
 
Internet Explorer decides how to launch browsed-to documents based on the file associations maintained in the OS. When a user browses directly to a PDF, IE/Windows is going to pass it to whatever application handles PDFs.

That application (in this case Acrobat) may control how it displays the PDF, whether in the browser, in the full application, whatever. That's what the preferences you are setting control.

If you are coding the server page that sends the PDF, you can code it so that IE brings up the Save As dialog.

The technique in ASP involves sending the PDF as a binary stream. Do you want more details on this?



Thomas D. Greer
 
Yes I would like more info on this.
Thanks
Pamela
 
Use the content-disposition header. The values are either "inline", which tell the browser to display the content "in the browser", and "attachment", which tells it to treat is a file to be saved.

The theory is, if you stream the PDF is a binary stream instead of as a file with the .PDF extention, IE can't fall back to Acrobat. Additionaly, adding the content-disposition header prompts the browser to bring up the save dialog.

Something like this with ASP/VBScript:

Code:
dim pdfStream,body
set pdfStream = Server.CreateObject("ADODB.Stream")

pdfStream.Type = 1
pdfStream.Open
pdfStream.LoadFromFile Server.MapPath("mypdf.pdf")
body = pdfStream.Read

pdfStream.Close
set pdfStream = Nothing

Response.ContentType = "application/pdf"
Response.AddHeader "content-disposition", "attachment;filename=mypdf.pdf"
Response.BinaryWrite body
Response.Flush

Thomas D. Greer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top