Skip to main content
Inspiring
September 25, 2021
Answered

PDF Embed API: Need a download method for Custom Force Download Button

  • September 25, 2021
  • 1 reply
  • 1198 views

We know that the embedded PDF itself has the download button, but for better user experience, we want to create a larger download button that allows our users to easily notice it and download the PDF file. Unfortunately, as we all know, the HTML5's download attribute is for the same-origin only. Therefore, we wonder if Adobe PDF Embed API could expose a download method from their AdobeDC.View object that will work exactly the same as the download button in the embedded toolbar. Any chance to have that feature or it's already available but I could have missed something?

Thank you.

This topic has been closed for replies.
Correct answer Antonio Ooi

Since I'm using Node.js, I've figured out how to solve this:

app.get("/download", (req, res) => {
    res.type("application/octet-stream");
    // Put the same URL as the one used in PDF Embed API
    // for the res.attachment() below:
    res.attachment("https://domainname.com/downloads/fiename.pdf");
    res.send("File downloaded!");
});

So in my HTML:

<!-- You don't even need to put target="_blank" -->
<a class="a-very-big-button" href="/download">Download PDF</a>

So consider it done, thanks.

1 reply

Antonio OoiAuthorCorrect answer
Inspiring
September 27, 2021

Since I'm using Node.js, I've figured out how to solve this:

app.get("/download", (req, res) => {
    res.type("application/octet-stream");
    // Put the same URL as the one used in PDF Embed API
    // for the res.attachment() below:
    res.attachment("https://domainname.com/downloads/fiename.pdf");
    res.send("File downloaded!");
});

So in my HTML:

<!-- You don't even need to put target="_blank" -->
<a class="a-very-big-button" href="/download">Download PDF</a>

So consider it done, thanks.