Rasura

Use cases

Twenty-one things people build with this, what makes each one hard, and the calls it needs.

The common thread is that all of them need the document to survive. Anything that regenerates the file loses signatures, revision history, tags, and every byte someone downstream might be hashing.

Document workflows

Anything where a person receives a PDF, changes part of it, and sends it back. These are the cases the library was designed around.

Correct a typo without regenerating the file

A contract went out with a misspelt name. The source document is in someone else’s hands, or was generated by a system nobody wants to run again.

Find the paragraph, replace the characters, commit. The other 200 pages keep their exact bytes, so signatures on unrelated revisions and any downstream hash of the untouched objects stay valid.

page()replaceText()commit()

Fill a form nobody has the source for

A government or bank PDF with AcroForm fields. Filling it in a viewer works; doing it for ten thousand applicants does not.

Read the field tree, set values by fully qualified name, flatten so the values cannot be edited back out.

formFields()setFieldValue()flattenForms()

Redact before disclosure

A document has to go out with names, account numbers or addresses removed, and a black rectangle drawn over text is not removal.

Remove the glyphs, then ask the library to search the saved bytes for the string. Redaction forces a full rewrite so the original bytes cannot survive in an earlier revision.

Read notChecked as well as clean. It names the places the check does not reach.

redactText()verifyRedaction()

Merge, split and reorder

Assemble a submission pack from several files, or pull one chapter out of a report.

Delete and reorder pages with links, outlines and named destinations retargeted rather than left dangling.

deletePage()movePage()

Stamp every page with a reference

Case numbers, Bates numbers, draft watermarks, a recipient name on each page.

Add an annotation per page, or compose the mark and place it. Adding content appends a stream rather than rewriting the page, so nothing already on the page moves.

addAnnotation()save()

Update a price list in place

A catalogue is regenerated monthly, but only the numbers change.

Locate the table, set cell values, and let the reflow policy decide whether the column widens or the text shrinks.

page().tablessetCellText()

Generation

Composing documents that did not exist. The layout engine handles measure, leading, pagination and columns; the typeface is embedded and subset to what you actually draw.

Invoices, receipts and statements

Server-side PDF generation means a headless browser or a print pipeline. Both are heavy, and both fail in ways that are hard to reproduce.

Describe the content as blocks and compose it in the tab or in a Worker. No browser, no font installed on the host, no network.

Pdf.create()

Reports and exports from application data

Users want the dashboard as a PDF, and the screenshot approach produces something nobody can select text in.

Compose from the same data that drives the view. The text is real text, so it is searchable, copyable and accessible.

Pdf.create()save()

Certificates and letters at volume

Ten thousand personalised documents, each with a different name and date.

Compose each one. The font is embedded once per document and subset to the glyphs that document uses, so a name in Greek costs only the glyphs in that name.

Composition picks a Type0 font automatically when the text needs one.

Pdf.create()

Offline-first and privacy-sensitive generation

Medical, legal or financial content that must not leave the device, or a field application with no connectivity.

Everything runs in WebAssembly in the tab. No document is uploaded, because there is nowhere to upload it to.

Pdf.create()

Pipelines and automation

Server-side and batch work, where the Rust crates are the better entry point.

Normalise files from many producers

Documents arrive from scanners, Word, InDesign, LaTeX and a decade of legacy tooling. Half of them break something.

Open with recovery enabled, read the leniency list to see what was wrong, and re-save clean. The recovery path rebuilds a cross-reference table by scanning when the real one is unusable.

open({ recovery })info().leniencies

Extract text and structure for search or a model

Indexing, retrieval, or feeding documents to a language model.

Read paragraphs in reading order rather than content order, with tables as tables and headers and footers separated from the body.

Reading order comes from the structure tree when the document has one, and from geometry when it does not. Which one was used is reported.

page().paragraphspage().tables

Prune bloated files

A 40 MB document where 35 MB is fonts nobody uses any more after edits.

Drop every glyph no page draws from each embedded font, then save a full rewrite.

compactFonts()save({ mode: "full-rewrite" })

Audit and compliance checks

Confirm a batch is tagged, has no XFA, carries no JavaScript, and is not encrypted in a way that blocks accessibility.

Every one of those is a property on the info object or a leniency, and none of them needs the document rendered.

info()metadata()

Re-encrypt or remove protection

A vault holds files under a rotated password, or a document has to be decrypted for archival.

Open with the password, change or drop protection, save. Changing protection forces a full rewrite because a mixed-key file is unreadable.

protect()unprotect()

Products you could build on it

Larger shapes, where the library is the engine rather than a utility.

A browser-based PDF editor

Every web editor either renders and overlays, or uploads the file to a server that runs a desktop tool.

Pair pdf.js for display with Rasura for editing. The editor on this site does the second half without the first, to show what the library alone knows.

everything

Translation and localisation tooling

Translating a laid-out document usually means rebuilding it, because the text grows.

Replace paragraph text and let reflow re-break the lines at the measure the document used. Overflow is reported rather than clipped, so a string that no longer fits is a decision rather than a surprise.

replaceText()configureSession({ overflow })

Accessibility remediation

A tagged document loses its tags the moment anything edits it.

Tag integrity is an invariant here, checked across the corpus on every run. Editing a tagged document keeps the structure tree consistent, and degradation is reported separately from absence.

info().taggedStatus

Document diffing and review

Two revisions of a contract, and the question is what changed.

Compare reconstructed paragraph text rather than rendered pixels, so a reflow that moved every line does not read as a change on every line.

page().paragraphs

Data extraction from forms and invoices

Pulling line items out of thousands of supplier invoices.

Tables are detected with cell geometry, so a row is a row rather than a cluster of text at similar y positions.

page().tables

Regulated archival

Files must be verifiably unmodified except for a recorded set of changes.

Incremental saving keeps every prior revision in the file. What changed is the appended bytes, and what did not is identical.

save()info().revisionCount

Not on this list

Anything that needs the page rasterised: thumbnails, print preview, OCR of a scan. Rasura has no renderer. Pair it with pdf.js, which does that well.

If your case is not here, the API reference lists every operation, and most workflows are two or three of them in sequence.