Rasura

JavaScript API

Every method on the package surface, with its parameters, return type and the codes it can throw.

Everything is asynchronous because everything crosses a Worker boundary by default. Pass { worker: false } to Pdf.open to run inline; the methods keep the same shape.

Opening and creating

Reading

Editing

Session and saving

Protection and fonts

Error codes

Every failure is a PdfError with a code. Fourteen of them, and each one implies a different response.

CodeWhat to do
malformedThe bytes are not a usable PDF, even after recovery. Nothing to retry.
encrypted-password-requiredAsk for a password and open again.
encrypted-unsupportedA handler this library does not implement. Rare outside DRM.
scanned-no-textThe page is an image. Route it to OCR, or tell the user.
xfa-unsupportedAn XFA form. Form edits are refused; text edits still work.
type3-glyph-missingA Type 3 font with no procedure for the glyph. Substitute or decline.
font-unavailableNo font can draw the text. Call registerFont and retry.
overflowAn index past the end, or text that will not fit under the current policy.
stale-sessionThe handle was closed. Open the document again.
fidelity-below-requiredThe floor you set cannot be met. Lower it or supply a font.
signature-would-be-destroyedPass acceptSignatureDestruction, or save incrementally.
unsupported-filterA stream filter this library does not decode.
invalid-argumentThe call itself is wrong: empty content, a level out of range.
internalA bug. The message and detail are worth reporting.