Browser Integration¶
Recommended layering¶
- Use PDF.js or another viewer only for preview rendering and user interaction
- Keep redaction logic in
@fabifont/open-redact-pdf - Convert UI events into canonical page-space geometry before calling
applyRedactions
Typical flow¶
- Load PDF bytes from a file input
- Call
initWasm() - Open the document with
openPdf(bytes) - Read page sizes and render the preview with a viewer
- Convert pointer or search results into
RectTarget,QuadTarget, orQuadGroupTarget - Call
applyRedactions - Call
savePdf - Offer the returned bytes as a download
Coordinate conversion¶
The demo converts preview coordinates into page-space using:
- the rendered viewport scale
- the normalized page height
- a bottom-left page origin
Do not pass screen-space pixels directly into the engine.
Rebuilding browser artifacts¶
When Rust or wasm-facing code changes: