Dev.to WebDev 🛠 Dev 👁 0

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

Most online PDF mergers upload your file to a server. For sensitive documents, that's a problem. Approach Use pdf-lib in the browser: Read files with File.arrayBuffer() PDFDocument.load() each source cop

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.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.