PDF links for dummies
December 15, 2010 5:10 PM Subscribe
Method to automatically print or download PDFs from a website.
I am developing a website for a client, where there are links to PDF files hosted elsewhere. They claim that their users are confused by PDF links, don't know what to do with them, etc., and insist (a lot) that we add 'special' links that allow said users to, with a single click, print or download the files, i.e. not have their browsers open them internally or in Reader.
Do you know of any successful, simple, cross-browser way to do this?
I'm not saying it's possible, just want to make sure I know what I'm talking about when I tell them it can't be done.
Any link or documentation to this effect is also appreciated.
I am developing a website for a client, where there are links to PDF files hosted elsewhere. They claim that their users are confused by PDF links, don't know what to do with them, etc., and insist (a lot) that we add 'special' links that allow said users to, with a single click, print or download the files, i.e. not have their browsers open them internally or in Reader.
Do you know of any successful, simple, cross-browser way to do this?
I'm not saying it's possible, just want to make sure I know what I'm talking about when I tell them it can't be done.
Any link or documentation to this effect is also appreciated.
Is that going to work well for a large number of PDF links with different names?
posted by christopherious at 5:34 PM on December 15, 2010
posted by christopherious at 5:34 PM on December 15, 2010
Response by poster: Not sure if it'll work, the PDFs are on a different server, that I don't have any control over.
posted by signal at 5:39 PM on December 15, 2010
posted by signal at 5:39 PM on December 15, 2010
If you have no control over the other server then you will have to either proxy the requests through your web app so that you can add the appropriate http response headers or you will need to write your own browser plugin to take care of the pdf's on the client side.
I know which one sounds a whole lot easier to me.
posted by mmascolino at 6:46 PM on December 15, 2010
I know which one sounds a whole lot easier to me.
posted by mmascolino at 6:46 PM on December 15, 2010
> Not sure if it'll work, the PDFs are on a different server, that I don't have any control over.
That part should be fine, I think. I'm not familiar with the method used in jenkinsEar's link but it appears to involve manipulating stuff on your own web server and should work for external and internal links alike.
I was actually wondering about the file name in the header -- your website is linking to more than one PDF and so you probably need something that affects all files of a given extension.
posted by christopherious at 6:49 PM on December 15, 2010
That part should be fine, I think. I'm not familiar with the method used in jenkinsEar's link but it appears to involve manipulating stuff on your own web server and should work for external and internal links alike.
I was actually wondering about the file name in the header -- your website is linking to more than one PDF and so you probably need something that affects all files of a given extension.
posted by christopherious at 6:49 PM on December 15, 2010
This technique needs control of the web server that's hosting the PDF files; you have to add a header to the http response when the browser requests the file. As mmascolino says, if you can't control the PDF server, you'll need to proxy the request and add your own header to it.
If you do have the ability to upload, and the files are on a properly configured apache server, you could accomplish this by placing all of the files in a directory, and adding an .htaccess file - something like:
posted by jenkinsEar at 7:15 PM on December 15, 2010
If you do have the ability to upload, and the files are on a properly configured apache server, you could accomplish this by placing all of the files in a directory, and adding an .htaccess file - something like:
<Files *.pdf> ForceType application/octet-stream Header set Content-Disposition attachment </Files>This presupposes that the folks hosting the pdf's will allow arbitrary .htaccess files.
posted by jenkinsEar at 7:15 PM on December 15, 2010
Response by poster: The PDF server is running IIS. I've sent them an email asking them to try the Content-Header. Any other ideas much appreciated.
posted by signal at 8:23 PM on December 15, 2010
posted by signal at 8:23 PM on December 15, 2010
I don't understand how forcing a download is going to make users any less confused. So now they have a file somewhere on their computer -- but they have no idea what it's called or the location where it's saved. The kind of users that get tripped up by this don't even know what directories are so they would have no idea what a "location" would mean unless it's the desktop. How are they supposed to know to find it and open it, or to launch a PDF reader app and then open the file from there if they can't handle choosing "File - Print" from the embedded PDF reader?
IMO if you want to help with the confusion put a screen shot of a browser window with the embedded viewer and a big red circle/arrow pointing at exactly what they should click to print the file. Forcing a download will just make things harder.
posted by Rhomboid at 11:28 PM on December 15, 2010 [1 favorite]
IMO if you want to help with the confusion put a screen shot of a browser window with the embedded viewer and a big red circle/arrow pointing at exactly what they should click to print the file. Forcing a download will just make things harder.
posted by Rhomboid at 11:28 PM on December 15, 2010 [1 favorite]
If you can't access the server config, you could also write a small PHP/ASP/whatever script to set said header, and then output the file.
Here would be a two line php script to do it (completely untested):
header("Content-Disposition: attachment; filename=$_GET[file]");
readfile($_GET[file]);
This is just an example, you'd need to do some input string sanitizing, or else you'd open a gaping security hole with this script.
posted by roerek at 5:34 AM on December 18, 2010
Here would be a two line php script to do it (completely untested):
header("Content-Disposition: attachment; filename=$_GET[file]");
readfile($_GET[file]);
This is just an example, you'd need to do some input string sanitizing, or else you'd open a gaping security hole with this script.
posted by roerek at 5:34 AM on December 18, 2010
« Older Help me figure out what specs I need on a netbook... | Adult Sci-Fi that is easy to read? Newer »
This thread is closed to new comments.
http://www.jtricks.com/bits/content_disposition.html
Setting the header as: should force a save as dialog box when the user clicks on the file.
posted by jenkinsEar at 5:19 PM on December 15, 2010