0

I have a problem where Google Chrome automatically opens pdf files instead of downloading them.

I need to be able to force this download with js so that the script then accesses another page.

  • 1
    Does this answer your question? [(HTML) Download a PDF file instead of opening them in browser when clicked](https://stackoverflow.com/questions/6794255/html-download-a-pdf-file-instead-of-opening-them-in-browser-when-clicked) – Diego D Sep 21 '22 at 06:46
  • I work with the Marketing Cloud tool and it has not been possible, I have not been able to include PHP. I have tried to make the code in several ways and always gave me an error: - I created an a element: This opens the pdf in the same tab and if I try to open it in a new one I get a popup window that needs to accept the user(not efficient) - I have tried with JS to try to open it directly but the same thing happens as with a - I have added the attribute "download" but it doesn't download it even putting the name I want - I can't add PHP code because it doesn't recognize it. – Daniel Developer Junior MC Sep 21 '22 at 15:25

1 Answers1

-2

This is a simple html5 solution:

<a href="https://where.you.hosted/your.pdf" download="filename.pdf" target="_blank">Download</a>

Note that IE still doesn't support this. But should be enough if you just want to support modern browsers.