How to force a pdf download automatically?

Solution 1:

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>

Solution 2:

Set Content-Disposition in your HttpResponse header:

Content-Disposition = 'attachment; filename=filename.pdf'