Merging PDFs in the browser with pdf-lib (no server upload)

2026-10-08来源 dev.to WebDevEnglish

Most online PDF mergers upload your file to a server. For sensitive documents, that's a problem.

Approach

Use pdf-lib in the browser:

  1. Read files with File.arrayBuffer()
  2. PDFDocument.load() each source
  3. copyPages() into a new PDFDocument
  4. save() and download via a Blob URL

The PDF never needs to leave the user's device for this flow.

Verify privacy

Open DevTools → Network, merge a test PDF, and confirm there's no upload request carrying the file body. After the app loads, you can even try offline.

Try it

I packaged this (merge, split, and more) in PDFCraftify:

Tradeoffs

  • Browser memory limits very large jobs
  • Password-protected PDFs must be unlocked first
  • Not a replacement for full desktop DTP

If you build similar tools, what edge cases bite you most? Comments welcome.

原文:https://www.a8q9.cn/en/article/merging-pdfs-in-the-browser-with-pdf-lib-no-server-upload-94ad36.html

相关文章