Why a black box isn’t enough
Most PDF tools let users “redact” by drawing a black rectangle over sensitive text. The rectangle hides the words on screen, but the underlying characters stay in the file’s content stream. Anyone can select the hidden text, copy it, or run a simple script to extract it. In other words, the data is still there; the black box is only a visual cover.
The problem the developer faced
The author needed a PDF editor that runs entirely in the browser, without uploading files to a server. That constraint makes it impossible to rely on a back-end service to strip text. Existing client-side solutions simply add a shape on top of the content, which leaves the original text intact. The challenge was to remove the text permanently while keeping the operation fast and the document usable.
Selective page rasterisation: the core idea
Instead of converting the whole PDF to an image—a step that would bloat the file and destroy searchability—the solution rasterises only the pages that contain redactions. Those pages become bitmaps; every other page remains a vector PDF, preserving text selection, search, and small file size.
The approach yields a document that feels normal: 19 pages stay crisp and searchable, while the one sensitive page is a pixel-only image where the hidden information no longer exists.
Three practical rules for reliable conversion
- Render at three-times scale – The bitmap is generated at three times the page’s normal resolution. A low-resolution render looks blurry next to the surrounding vector pages, which can raise suspicion or simply look unprofessional.
- Merge all visual elements into the bitmap – Annotations, signatures, watermarks and the redaction rectangle are composited together before the page is rasterised. Mixing vector annotations with a raster image on the same page can confuse PDF readers, leading to display errors.
- Anchor to the viewport, not pixels – Annotations are tied to the page’s viewport coordinates. When a user zooms, the elements stay aligned instead of drifting or scaling inconsistently, which would otherwise expose the underlying text.
Guarding against race conditions
Rendering each page is an asynchronous task. If a user resizes the browser window quickly, multiple render jobs can overlap, producing broken or overlapping frames on the canvas. The implementation introduces a per-page render token: each new render request invalidates the previous token, causing the older task to cancel itself. The result is a smooth, glitch-free experience even under rapid UI changes.
What the trade-offs look like
Turning a page into a bitmap removes any hidden text, but it also discards the ability to search or copy that page’s contents.
Where this could go next
Takeaway
A simple black box does not delete data; it merely hides it. By converting only the pages that need redaction into high-resolution bitmaps and leaving the rest of the PDF vector-based, a browser-only editor can permanently erase sensitive text while keeping the document fast, searchable and private. The method balances security with usability, but users should watch the cumulative impact on file size and searchability when redacting many pages.
