0

I try to download a pdf (inserted in the folder of my project) at the click of the user. but when I download the file it says "operation failed"

function downloadFile() {
let link = document.createElement('a');
let file='data:application/pdf';
link.setAttribute('href',file);
link.download = 'l.pdf';
link.click();
}
cioski
  • 1
  • Where’s the actual pdf data? If using a data href I’m thinking it will need the content of the pdf too. – evolutionxbox Dec 15 '19 at 15:09
  • 1
    Does this answer your question? [How to download PDF automatically using js?](https://stackoverflow.com/questions/34691525/how-to-download-pdf-automatically-using-js) – Vyacheslav Pukhanov Dec 15 '19 at 15:10

0 Answers0