Open almost any "free PDF editor" and the first thing it asks for is the file. That is not a UI detail. Your document is copied to a server, written to disk, processed by a queue, and returned as a new file. For a recipe that is fine. For a contract, a payslip or a medical letter, it is a decision with legal weight.
I maintain pdfcanvas, an MIT-licensed PDF editor that runs entirely in the browser. This post is about the engineering behind it, including the parts that are still ugly.
The privacy claim is the easy part
The architecture is boring on purpose. The site is static files, and the editor is JavaScript plus WebAssembly. There is no API route that accepts a document.
Rendering is done by PDF.js. Editing existing text is done by a WebAssembly build of PDFium, the engine inside Chrome. Writing the output is done by pdf-lib. All three run in the tab, and the worker is served from the same origin, never from a CDN.
You do not have to trust that paragraph. Open the editor, load a file, open the network panel, and switch it to Offline. Keep editing and export. If the document were processed remotely, the export would fail.
The privacy guarantee is the easy part because it falls out of the architecture. The hard part is what happens when a PDF contains text that was never designed to be edited.
Three engines, because one library cannot do all of it
A PDF editor has three jobs, and each has a different best tool:
- Render pages, with fonts, CMaps and colour spaces. PDF.js is the renderer maintained by Mozilla and used by Firefox.
- Edit text that already exists in the file. This is the rare capability. pdf-lib can draw new content but cannot change a glyph in the original content stream. PDFium can.
- Write the result. pdf-lib produces valid PDFs with images, fonts and page trees.
Pulling PDFium in for everything would be simpler, but it is also the largest asset in the build. Using each engine for its job keeps the initial path smaller.
The snippets below target pdfcanvas 0.8.x and were checked against 0.8.0 in November 2026.
Mounting the engine looks like this:
import { PdfCanvas } from "pdfcanvas";
const pdf = new PdfCanvas(document.querySelector("#editor")!, {
workerSrc: "/pdfjs/pdf.worker.min.mjs",
pdfiumWasmUrl: "/pdfium/pdfium.wasm",
fontAssetsUrl: "/fonts/",
});
await pdf.load(file);
pdf.addText(80, 120, { text: "Approved", fontSize: 24, color: "#6b4eff" });
await pdf.download();
The container needs an explicit height. That is the first bug every integration hits.
PDF text is not a text box
This is the part I underestimated.
A PDF content stream does not store paragraphs. It stores glyphs at coordinates, with a font and a transformation matrix. Sometimes a line of text is one text-showing operator. Sometimes every character is placed individually, because the producing tool was optimizing for something else. There is no line object to select.
So "click a line and edit it" is a heuristic, not a lookup. PdfCanvas groups characters into editable line runs by comparing their baseline, spacing and font. On a normal document exported from Word or LaTeX this works. On a scan there is no text to group. On unusual encodings it can fail, and when it fails the editor should say so instead of silently corrupting the file.
Once a run is selected, changing it is a separate operation. The original glyphs are removed and new text is drawn with a matching font:
pdf.setTool("text-edit");
pdf.on("originaledit", ({ edit }) => {
if (!edit) return;
pdf.updateOriginalText({ boldOverride: true, fontSizeOverride: 11 });
});
That distinction matters for the export, and it is where most of the debugging time went.
Fonts lie about what they contain
PDFs usually embed a subset of a font: only the glyphs the document uses. If you edit a word and introduce a character outside that subset, the original font cannot render it.
The editor tries to reuse the embedded font first, which keeps line lengths and shapes identical. When it cannot, it falls back to Work Sans or to Liberation Sans, which has Arial metrics. Close is not the same as equal: a replaced font can shift line breaks and make accented characters look wrong.
This is a limitation I would rather state than hide. If a document is typographically sensitive, check the export before sending it.
Export has to stay vector
There is a tempting shortcut: render the edited page to a canvas, wrap it in an image, and call it a PDF. It is a few lines of code. It also destroys the document. Text stops being selectable and searchable, file size explodes, and printing quality drops.
The approach here is different. Pages you did not touch are copied as they are. Overlays are written as real PDF objects: text with an embedded font, shapes with a fill, images with a transform. The original page stays vector.
That choice is also why the whiteout tool needs an honest warning.
Whiteout is not redaction
The editor has a tool that draws a filled rectangle over part of a page. It looks like redaction. It is not.
The rectangle is drawn on top of the content. The text underneath is still in the file and can be extracted with any text tool. Real redaction removes or rewrites the content stream, and verifying that is its own project.
Most online editors have the same behaviour and do not say so. I would rather lose a feature comparison than have someone send a "redacted" document that still contains the account number.
For the same reason, the project does not claim AcroForm filling, OCR, certified digital signatures or PDF/A. Each of those has a correctness bar that a small editor cannot meet, and a broken version is worse than a missing one.
The bill: what local processing costs
Client-side processing moves cost from a server bill to the user's first load. These are the assets in the production build at v0.8.0, measured with Node's zlib on the files as shipped:
| Asset | Raw | Brotli |
|---|---|---|
pdfium.wasm |
4.43 MB | 1.58 MB |
pdf.worker.min.mjs |
1.21 MB | 0.30 MB |
| CMaps | 1.14 MB | not measured |
| Standard fonts | 779 KB | not measured |
The first visit pays for the engine. After that the browser caches it, and the editing session itself makes no network requests. On a slow connection the first load is the price of not uploading anything.
The other limit is memory. The default maximum file size is 200 MB, but the real ceiling is the tab. A 500-page scan will open on a laptop and struggle on a cheap phone. There is no server to bail you out.
When you should not use it
I would not recommend this editor for:
- Forms. AcroForm fields are not supported. You can place text over a field, but the field itself stays empty.
- Redaction. Use a tool that removes the content and lets you verify the result.
- OCR. Scanned documents can be annotated, not edited.
- Certified signatures. The signature tool draws a signature. It does not create a cryptographic one.
- Server pipelines. It depends on browser APIs. For batch processing use a library built for Node.
- Mission-critical workflows without maintenance. There is no support contract.
If those are requirements, Nutrient, Apryse or Acrobat are the right products. They cost money because someone maintains the hard parts.
The part I would do again
Keeping the whole thing open source and client-side forced better decisions. There is no upload endpoint to secure, no retention policy to write, and no tenant isolation to get wrong. The security review is "read the code and watch the network panel".
It also made the editor embeddable. The same package ships a core API and a ready-made UI:
import { PdfCanvasEditor } from "pdfcanvas/editor";
const editor = new PdfCanvasEditor(document.querySelector("#app")!, {
workerSrc: "/pdfjs/pdf.worker.min.mjs",
pdfiumWasmUrl: "/pdfium/pdfium.wasm",
fontAssetsUrl: "/fonts/",
locale: "auto",
autosave: { key: "contracts" },
});
await editor.ready();
await editor.open(file);
Autosave stores the original bytes and the scene in IndexedDB. Still no server.
Try it, or read the code
- Editor: pdf.eneawork.it
- Source: github.com/Frenxys/pdfcanvas
- Package:
npm i pdfcanvas(npm) - Docs: pdf.eneawork.it/docs/
The honest summary: it handles text, images, signatures, highlights and pages, it keeps the file on the device, and it is missing features that other tools charge for. The gaps are documented in the repository, because finding them in production is worse.
If you try it on a real document and something breaks, open an issue with the kind of PDF that broke it. The per-character text cases are the ones I want to see.
Top comments (0)