'Problem dowloading a pdf file through browser using javascript
I have to present for an exam a portfolio which allows visitors to download some documentations about my projects as pdf files.
I tried using an tag with a "download" attribute, unfortunately when I try to download the file by clicking on the link, the file is proposed to be recorded as .html or all files.
Whatever option I choose, after downloading the file, I'm not able to open it because it seems damaged or in the wrong format.
Here's the code I use :
My "demo" var is contained in an object Work as you can see on the screenshot :
In case it matters, my pdf file is stored here:
Thanks for you help ! =)
Solution 1:[1]
As a wild guess :
- your path is wrong (documents/pdt-test.pdf)
- your html is missing a doctype or a proper structure
- you need a doctype/pdf somewhere. Something like in here Download a by ByteArray as pdf /handle error in React
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | schiffsratte |




