在浏览器中自动保存PDF

I have a interesting question for you all.

My client wants a way to automatically save a PDF that is opened up in Chrome. Currently he achieves this by either clicking on the Save button in Acrobat (in the browser), or by right clicking, thus bringing up the context menu and clicking Save As --> PDF. He would like this process automated.

I did a lot of searching and I cannot find a solution to this question.

So I ask all of you, is there a way to automatically save a PDF that is embedded in a HTML page?

I'm assuming I would have to do some screen scraping to get the HTML page, which would include the link with the PDF but I'm not sure where to go from there.

Any help will be greatly appreciated.

Thank you very much, and have a great day.

Web pages require user interaction before writing files to the user's hard drive. This is a security measure to keep any ol' web page from putting files on your disk.

It is possible to make file Save As dialog popup when the user clicks on something and ready to save a particular file to the disk, but in some browsers the user will still have to finish the operation. In other browsers, downloaded files can be pre-configured to go to a particular "downloads" directory and the user does not have to take another step after the browser initiates the save.

If, when the browser requests a file, the response is given a header:

Content-Disposition: attachment; filename="xxx.pdf"

The browser will try to save it. I don't know what happens if the web server does this as one request of many in a web page. The way I've seen this used is the user clicks a download button and the browser requests a specific URL that indicates to the server that the user wants to save the file and then, and only then, the web server includes this header.

You can do this with htaccess. Add the following to your .htaccess file.

AddType application/octet-stream .pdf