javascriptpdfpdf-lib.js

PDF-Lib Modify PDF Downloadable


Currently implementing the PDF-Lib Library for my project to modify PDFs Source: https://pdf-lib.js.org/#examples

And it is working very well, but the modified PDFs are saved on the server. I am searching for the opportunity that the pdfs which modified will directly downloaded for the user.

Thanks!


Solution

  • If you follow the examples where the ones that download to client like https://jsfiddle.net/Hopding/64zajhge/1/ have

     <script src="https://unpkg.com/downloadjs@1.4.7"></script>
    </head><body>
    ... 
    Instructions
    <button onclick="modifyPdf()">Modify PDF</button>
    ...
    
    <script>
    async function modifyPdf()
    ...
    // Trigger the browser to download the PDF document
          download(pdfBytes, "pdf-lib-output.pdf", "application/pdf");
    

    however that may need some secured configuration, way beyond this single question.