Your PDF never leaves your browser: how I built 16 PDF tools with no uploads
Most "free PDF" sites work the same way: you upload your contract, they process it on a server, you download the result. It works, but your payslip or passport scan just took a trip to a stranger's machine. I wanted to
Most "free PDF" sites work the same way: you upload your contract, they process it on a server, you download the result. It works, but your payslip or passport scan just took a trip to a stranger's machine.
I wanted to see how far a browser can go on its own. The result is PDFixed: 16 PDF tools where the file never leaves your device. Here is how the main ones work, in case you want to build something similar.
The stack
- pdf-lib to create, merge, split and rewrite PDFs
- pdf.js to render pages onto a canvas
- Tesseract.js for OCR
- Alpine.js + Vite for the interface
The free tools have no upload endpoint. The server sends the page and its scripts; everything else runs in the visitor's tab. (There is a separate, optional expert editing service where you send a file on purpose, but that is not one of the tools.)
Merge: pdf-lib does the heavy lifting
Merging is the easy one. Copy the pages of each source document into a new one:
import { PDFDocument } from 'pdf-lib';
const merged = await PDFDocument.create();
for (const file of files) {
const source = await PDFDocument.load(await file.arrayBuffer());
const pages = await merged.copyPages(source, source.getPageIndices());
pages.forEach((page) => merged.addPage(page));
}
const bytes = await merged.save();
const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
That last line is the whole "download" step. The result is a Blob in memory, and a link to it.
Compress: most of a PDF is images
Most of a big PDF's weight is photos and scans, not text. So the compressor finds every embedded image, decodes it, scales it down to a size limit, and saves it again as a JPEG, but only when that actually makes it smaller. Text and vector drawings are untouched, so they stay sharp and selectable. There are three levels, with different maximum image sizes and JPEG quality settings. Then pdf-lib saves the document with compact object streams.
The "only if smaller" rule matters. A PDF that is already mostly text barely shrinks, and the tool says so instead of pretending.
OCR: a scanned PDF is just pictures
A scanned PDF has no text, only an image of each page. To make it searchable:
- pdf.js renders each page to a canvas.
- Tesseract.js reads the canvas and returns the words and their positions.
- pdf-lib adds that text back as an invisible layer on top of the original page.
The page looks identical, but you can now search and copy it.
const { createWorker } = await import('tesseract.js');
// worker, core and language files are served from our own site
const worker = await createWorker('eng', 1, { workerPath, corePath, langPath });
const { data } = await worker.recognize(canvas);
I host the Tesseract worker and language files myself, so OCR does not need to call any third-party server either.
Protect: AES-256 in the browser
Password protection is just encryption, and the PDF format supports AES-256. A fork of pdf-lib (@cantoo/pdf-lib) can encrypt a document before saving it. The password is used locally and never sent anywhere, which also means I cannot recover a forgotten one.
What did not go smoothly
- Big files are limited by the tab's memory. Rendering hundreds of pages to canvases is heavy, so there is a file size cap.
- OCR is slow. It takes a few seconds per page, and accuracy depends on how clean the scan is.
- PDF to Word is approximate. I convert text and basic formatting, but tables and pictures are not rebuilt, and I say so in the tool.
- PDF is a strange format. Fonts, encodings and broken files will humble you. Always test with real-world PDFs, not only the ones you made yourself.
Check it yourself
Open DevTools, go to the Network tab, drop a file into any tool and watch. You will see the page's scripts load, and no request carrying your document.
If you try it, I would like to hear which PDF job annoys you most that a tool like this could handle. The tools are free, with no account: pdfixed.com.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes ā full credit and traffic to the original publisher.