PDF-Lib Modify PDF Downloadable

1.4k Views Asked by At

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!

1

There are 1 best solutions below

0
On BEST ANSWER

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/[email protected]"></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.