How I Built a Zero-Upload Browser PDF Toolkit with Next.js and pdf-lib

2026-11-28来源 dev.toEnglish

Every time I needed to merge a resume, delete a blank scanner page, or watermark an ID scan, the top Google results all did the same thing: upload my private PDF to a remote server and lock basic features behind a paywall after two tasks.

As a CS student, I wondered: modern browsers already have fast binary APIs (ArrayBuffer, Blob, Canvas). Why does merging two PDFs need a server at all?

So I built VaultPDF — a suite of 8 PDF tools that execute 100% client-side in your browser with zero file uploads.

Architecture: Zero Upload Endpoints

Instead of sending FormData to a backend API running Ghostscript or Python, every tool reads local File objects into volatile browser memory, manipulates PDF objects via pdf-lib, and triggers a direct local Blob download:

  1. Read locally: const bytes = await file.arrayBuffer()
  2. Process in-browser: Merge, split, rotate, delete pages, embed JPG/PNG/WebP images, stamp vector watermarks, or inspect/scrub document metadata.
  3. Save directly to disk: URL.createObjectURL(new Blob([outBytes], { type: "application/pdf" }))

You can verify zero uploads yourself by opening DevTools → Network (or toggling Airplane Mode after the page loads) and running any tool — zero bytes leave your machine.

What's Inside VaultPDF

All 8 tools are free with no signup or watermarks:

  • Merge PDF — Combine and reorder multiple PDFs locally.
  • Split & Extract PDF — Extract custom ranges (1-3, 5, 8-10) or burst every page into a ZIP archive with jszip.
  • Rotate & Organize PDF — Fix sideways scans, reorder pages, and remove blank sheets.
  • Delete PDF Pages — Visually mark pages (or all even/blank pages) for removal and export a freshly serialized PDF.
  • Images to PDF — Convert JPG, PNG, and WebP (auto-transcoded via local Canvas) into A4, US Letter, or exact-fit PDFs.
  • Watermark & Page Numbers — Add diagonal vector stamps (e.g. CONFIDENTIAL) and clean Page X of Y footers with a live preview.
  • Inspect & Strip PDF Metadata — Audit hidden Author, Title, Creator, and timestamp fields embedded by Word/Pages and scrub them in one click.
  • PDF Inspector — Analyze exact dimensions in mm/inches/points and detect A4 vs. US Letter paper mismatches before printing.

Two Small Engineering Details That Mattered

  • WebP Support: pdf-lib natively embeds JPG and PNG, not WebP. When a user drops a .webp image, VaultPDF decodes it with createImageBitmap() onto an offscreen HTML5 Canvas, encodes PNG bytes locally, and embeds it seamlessly.
  • True Metadata Scrubbing: Simply renaming a PDF doesn't erase hidden header dictionaries. VaultPDF initializes a brand-new PDFDocument.create() container, copies only the visible page objects, and blanks all metadata fields during fresh serialization.

Try It Out & Feedback Welcome

I'd love to hear your feedback — especially if you hit any PDF edge cases or have ideas for the next local-only tool to add!

原文:https://www.a8q9.cn/en/article/how-i-built-a-zero-upload-browser-pdf-toolkit-with-next-js-and-pdf-lib-755707.html

相关文章