Rasura

Introduction

Rasura reads a PDF as paragraphs and blocks, changes them, and writes the file back with the untouched bytes intact.

The problem

A PDF is a page-description format. It contains no paragraphs, no words, and frequently no spaces. What it contains is positioned glyph runs: draw this glyph at this point, then that one 4.7 units to the right.

Every browser PDF library does one of two things with that. It renders the page (pdf.js), or it draws new content on top of the old (pdf-lib, jsPDF). Neither edits. Changing a word in a sentence means recovering the sentence first, which means rebuilding the paragraph from glyph positions, resolving each glyph back to a character, re-breaking the lines at the width the document actually used, and patching the content stream in place.

Rasura does that. It is Rust, compiled to WebAssembly, and it runs in the tab.

Three rules

Everything in the library follows from these, in this order.

  1. Non-locality is forbidden. An edit on page 40 must not change the rendered output of any other page by a single pixel, and must not alter the bytes of any object it did not need to touch. An unedited save returns the input byte for byte.
  2. Fidelity is reported, never assumed. When the engine cannot make an exact edit it says so in the return value. It does not silently substitute a font, silently drop kerning, or silently overlay a text box.
  3. The file stays a valid PDF. Output passes qpdf --check and opens in Acrobat, Preview, Chrome and Firefox without repair prompts.

The second rule is the one that shapes the API. Most operations return a fidelity rung rather than throwing, and you can set a floor below which an operation is refused instead of degraded.

What it refuses

Each of these is a decision with a reason, not a gap in the roadmap.

  • Rendering. pdf.js does it well and is Apache-2.0. Pair with it for display and use Rasura for editing.
  • Scanned documents. Editing them needs OCR and raster inpainting, which is a different product. open() succeeds and reports documentKind: 'scanned'.
  • XFA forms. Deprecated by ISO and Adobe-proprietary. Detected, exposed as hasXfa, and form edits refused.
  • Creating digital signatures. Needs key custody and carries regulatory weight. Existing signatures are detected, preserved, and their invalidation reported before you save.

Permissions are reported, not enforced

The /P bits say what a conforming reader should allow. Rasura tells you what they say and does not act on them. A library that enforced them would be claiming a security property the format does not have.

Where to go next