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.
| Code | What to do |
|---|---|
malformed | The bytes are not a usable PDF, even after recovery. Nothing to retry. |
encrypted-password-required | Ask for a password and open again. |
encrypted-unsupported | A handler this library does not implement. Rare outside DRM. |
scanned-no-text | The page is an image. Route it to OCR, or tell the user. |
xfa-unsupported | An XFA form. Form edits are refused; text edits still work. |
type3-glyph-missing | A Type 3 font with no procedure for the glyph. Substitute or decline. |
font-unavailable | No font can draw the text. Call registerFont and retry. |
overflow | An index past the end, or text that will not fit under the current policy. |
stale-session | The handle was closed. Open the document again. |
fidelity-below-required | The floor you set cannot be met. Lower it or supply a font. |
signature-would-be-destroyed | Pass acceptSignatureDestruction, or save incrementally. |
unsupported-filter | A stream filter this library does not decode. |
invalid-argument | The call itself is wrong: empty content, a level out of range. |
internal | A bug. The message and detail are worth reporting. |