Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a pdf download automatically?

Tags:

pdf

download

Is there any way to force the user's download-manager to start a download for .PDF instead of showing the .PDF in a new window/tab?

like image 396
Heinrich Avatar asked Apr 08 '10 09:04

Heinrich


People also ask

How do I make a PDF download automatically?

On the right, go to the Content section, and click on Additional content settings. Click on PDF documents. On the next page, turn on (enable) the Download PDF files instead of automatically opening them in Chrome option. You are done.

How do I download a PDF forcefully instead of opening it in a browser?

Click “Site Settings” on the right. Scroll down in Site Settings and click “Additional content settings” at the very bottom. In the expanded menu, select “PDF documents.” Toggle on the “Download PDF files instead of automatically opening them in Chrome” option.

How do I auto save a PDF in Chrome?

Move your mouse on the screen and a menu should appear on top of the page. You should see an image of a printer on the right side of it. click on that and then under Destination click on change and choose save as PDF from the menu.

Why are my PDF files not downloading?

Typically, this occurs for one of the following reasons: Your computer is not connected to the Internet, or there is a problem with your Internet settings. Your antivirus software needs to be updated. You may not be connected to the Adobe server.


2 Answers

use the download attribute inside your <a> tag

<a href="content/file.pdf" download > pdf link </a>
<a href="content/file.doc" download > doc link </a>

like image 181
Abouasy Avatar answered Sep 22 '22 17:09

Abouasy


Set Content-Disposition in your HttpResponse header:

Content-Disposition = 'attachment; filename=filename.pdf' 
like image 44
Bird Avatar answered Sep 21 '22 17:09

Bird