Skip to content

Error and warning codes

Every error and warning lamina raises, in Rust, in WebAssembly and in @lamina/pdf, has one of these codes. The tables below are read from fixtures/codes.json when this site is built: the same file cargo xtask gen codes generates the Rust enums and the TypeScript unions from. Each code links to its page on this site, which explains when it happens, why, how to fix it and what its data holds. See Errors and warnings for how to handle them.

Warnings

CodeKindWhat happenedWhat to do
missing-headerinputno %PDF-x.y header in the first 1,024 bytes; parsing went aheadnothing to do if the document reads correctly; open in strict mode to refuse such files
xref-repairedinputthe stored cross-reference data was unusable and was rebuilt by scanningcheck the result; save with a full rewrite, since an incremental update refuses a repaired base
xrefstm-ignoredinputa hybrid file's /XRefStm could not be read and was ignorednothing to do; the classic xref table is used instead
stream-length-recoveredinputa stream's /Length was wrong, so its end was found by scanning for endstreamnothing to do; a full rewrite writes the correct length
stale-generationinputa reference's generation did not match its xref entry, so it resolved to nullnothing to do; the reference is treated as missing
page-tree-node-skippedinputa page-tree node was missing, malformed or too deep, and was skippedcheck the page count: pages under the skipped node are missing
page-count-mismatchinputthe page tree's /Count differs from the number of pages walkednothing to do; lamina uses the walked page count
flate-truncatedinputFlate data was truncated or had a bad checksum; the partial output was keptcheck the affected content: the end of the stream may be missing
objstm-index-mismatchinputan object stream's index was stale and the object was found by searchingnothing to do; a full rewrite writes a correct index
object-number-out-of-rangelimitan xref entry above max_object_number was droppedraise max_object_number in Limits only if you trust the input
aes-padding-invalidsecurityAES-encrypted data had a bad length or padding and was kept as storedtreat the affected strings and streams as suspect: they may have been tampered with
perms-mismatchsecurityan R5/R6 document's /Perms does not match its /P and /EncryptMetadatatreat the document's permissions as untrusted
warnings-truncatedlimitmore than max_warnings warnings were raised and the rest were droppedraise max_warnings in Limits if you need the full list
invalid-boxinputa page boundary box is not four numbers and reads as absentnothing to do; the page uses the next box in the fallback chain
invalid-rotateinputa page's /Rotate is not a multiple of 90 and reads as 0set the page rotation explicitly if 0 is wrong
name-tree-node-skippedinputa name- or number-tree node was malformed, repeated or too deep, and was skippedcheck the tree's entries: those under the skipped node are missing
outline-cycleinputan outline item was reached twice; that branch of the walk stoppednothing to do; the outline is read without the loop
outline-item-skippedinputan outline item was missing, not a dictionary or too deep, and was skipped with its subtreecheck the outline: the skipped item and its children are missing
invalid-dateinputan Info date is not a valid PDF date; the raw string is keptread the raw value from the Info view if you need it
invalid-page-labelinputa /PageLabels entry is malformed; the malformed part is droppednothing to do; affected pages fall back to decimal labels
invalid-entryinputan entry a view reads is unreadable or of the wrong type and reads as absentnothing to do; the view uses the entry's default
content-unknown-operatorinputan operator the spec does not define was skipped outside a BX/EX sectionnothing to do; check the page's rendering if the operator mattered
content-bad-operandsinputan operator had too few operands or operands of the wrong type, or extra onesnothing to do; the operator was skipped or used its last operands
content-unbalanced-qinputa Q without a matching q was ignored, or saved graphics states were left opennothing to do; the graphics state was restored as the spec intends
content-unbalanced-btinputa text object was opened twice, closed outside one, or left opennothing to do; text operators outside a text object were handled tolerantly
content-unbalanced-markedinputan EMC without a matching BMC or BDC was ignored, or marked content was left opencheck tagged-content results: marked-content sequences were closed for you
content-syntaxinputcontent-stream bytes that are not a token were skippedcheck the page's content: the bytes around the reported offset were skipped
content-resource-missinginputan operator named a resource that is missing, of the wrong type or unreadablecheck the page's resources: the operator ran without the resource or was skipped
inline-image-unterminatedinputno EI ends an inline image; the rest of the content was skippedcheck the page's content: everything after the inline image is missing
xobject-cycleinputa Form XObject draws itself, directly or through other formsnothing to do; the inner Do was skipped
content-path-unpaintedinputa content stream ended with a path no painting operator endednothing to do; the unpainted path was dropped as the spec intends
font-invalidinputa font dictionary has a missing or malformed entry, so its text was decoded with defaultsnothing to do; extracted text or positions for that font may be off
cmap-invalidinputa font's CMap or ToUnicode CMap is malformed or names a predefined CMap lamina has no table fornothing to do; the bad entries were skipped and the rest of the CMap is used
unmapped-glyphinputa font shows glyphs that nothing maps to textnothing to do; those glyphs extract as U+FFFD (the file needs a ToUnicode CMap)

Errors

CodeKindWhat happenedWhat to do
not-pdfinputthe input does not look like a PDF at allcheck that the bytes passed to open are a PDF file
missing-rootinputno document catalog (/Root) was found, even after repairuse another copy of the file: this one has no usable catalog
reference-cycleinputa reference chain or the page tree loops back on itselfuse another copy of the file, or repair it with another tool
limit-exceededlimita hard Limits value was exceededthe input exceeds a safety limit; raise {limit} in Limits only if you trust the input
strictinputstrict mode refused something the tolerant reader would have repairedopen without strict mode to read the file with repairs, or fix the file
data-pendingstatethe ByteSource has not fetched the byte ranges the call needs yetfetch the listed ranges into the source and retry the call
sourceiothe ByteSource failed to readretry the call, or check the source; the document stays usable
typeinputan object had a different type than the structure requiresuse another copy of the file, or repair it with another tool
invalid-structureinputan object stream, xref section or filter parameter was malformeduse another copy of the file, or repair it with another tool
unset-objectinternala writer object number was reserved but never given a valuethis is a lamina bug: report it with the steps that led to it
repaired-basestatean incremental update was requested for a document whose xref needed repairsave with a full rewrite instead of an incremental update
encrypted-baseunsupporteda save of an encrypted document was requestedsaving encrypted documents is not supported yet; use another tool to decrypt or re-encrypt
password-requiredsecuritythe document is encrypted with a user password and none was givenpass the document's password in OpenOptions
wrong-passwordsecuritythe given password is neither the user nor the owner passwordask for the password again and retry with the correct one
unsupported-security-handlerunsupportedthe document uses a security handler lamina cannot decryptuse a tool that supports this encryption to decrypt the file first
unexpected-eofinputthe input ended before a complete token or object was readuse a complete copy of the file: this one looks truncated
syntaxinputa token or structure did not match the PDF grammaruse another copy of the file, or repair it with another tool
unsupported-filterunsupporteda stream uses a filter lamina does not implementuse a tool that supports the filter to read this stream
decompressinputcompressed stream data was corruptuse another copy of the file: this stream's data is damaged

Op errors

CodeKindWhat happenedWhat to do
nested-transactionstatea transaction was started, or undo or redo called, while one is opencommit or roll back the open transaction first, or use a savepoint inside it
no-transactionstateapply, commit or rollback was called without an open transactioncall begin first, or use transact
unknown-pageusagean op names a page the document does not haveuse a PageId from this document's pages()
direct-pageunsupportedthe page is a direct dictionary, which ops cannot edit yetrewrite the file so that every page is an indirect object, or wait for page-structure ops
unsupported-versionunsupportedan op log has a schema version this reader does not knowupgrade lamina to a version that reads this op log version
invalid-op-loginputan op log does not parse: an unknown op or field, a bad value, or not JSONvalidate the op log against the op schema; the samples in fixtures/ops show the format
saved-not-rebasedstatethe document was saved to a sink lamina cannot read back and waits for rebasecall rebase with the saved bytes before applying ops or saving again
no-pending-savestaterebase was called without a save waiting for itcall rebase only after a save that returned SavedNotRebased

Save errors

CodeKindWhat happenedWhat to do
sinkiothe sink failed to take the bytes or could not give them backcheck the destination and retry the save; the document is unchanged
not-rebasedstatethe output was written, but rebasing the document onto it failedretry rebase with the saved output carried by the error
sink-not-emptyusagethe sink already held bytes before the save startedpass an empty sink: output offsets count from the sink's first byte
would-invalidate-signaturessecuritythe save would break one or more signaturessave with SaveMode::Auto, or ask the user and retry with SaveOptions::with_invalidate_signatures
requires-rewritestatean incremental save was requested but only a full rewrite is safesave with SaveMode::Auto or SaveMode::FullRewrite

Text errors

CodeKindWhat happenedWhat to do
invalid-fontinputfont bytes could not be read as a fontpass the complete bytes of a .ttf, .otf, .ttc or .otc file
collection-indexusagea font collection member past the end of the collection was asked foruse an index below Font::collection_len
unknown-axisusagean instance was asked for on a variation axis the font does not havecheck the font's axes before choosing coordinates, or use a variable font
font-not-embeddableusagethe font's OS/2 fsType forbids embeddinguse another font, or register it with EmbedPolicy::Override if your licence allows embedding
missing-glyphinputthe font has no glyph for a character of the textuse a font that covers the character, or split the text across fonts
glyph-out-of-rangeusagea glyph ID at or past the font's glyph count was usedpass glyph IDs from the font you registered
unknown-fontusagea FontKey was used with a registry that did not hand it outuse the key returned by this registry's add
subset-failedunsupportedsubsetting a font failedtry another version or format of the font, and report the font if it is a common one
invalid-axis-valueusagea variation axis value was NaN or infinitepass finite axis values; values outside the axis range are clamped
wrong-documentusagefinish_fonts was given a document the registry did not reserve its fonts inuse one FontRegistry per document and finish it with that document
invalid-featureusagean OpenType feature setting did not parsewrite it as liga=0, -liga, smcp or aalt=2 (HarfBuzz syntax without ranges)
invalid-text-rangeusagea byte range was out of bounds or not on character boundaries of the texttake ranges from lamina's results (line_breaks, itemize, break_lines) and pass the same text
unsupported-layout-optionunsupporteda layout option that is not implemented yet was asked forleave the option at its default; justification comes with a later release
font-mismatchusagea shaped run was given with a font key for a different font than it was shaped withpass the key of the font the run was shaped with (the font index of each line run maps to your keys)
encoding-fulllimita standard 14 font has no free one-byte code left for another glyphembed a font with Font::from_bytes, or split the text across two registrations of the standard font
font-not-shapableunsupporteda standard 14 font was given to shaping or layout, which need a font programdraw standard 14 fonts with FontRegistry::encode, or shape with an embedded font

Text warnings

CodeKindWhat happenedWhat to do
tounicode-conflictusageone glyph was used for two different texts; ToUnicode keeps the firstmark the second occurrence with /ActualText so extraction gets its text
whole-font-rebuiltusagea font that forbids subsetting was rebuilt with every glyph keptcheck that the font's licence allows this, or use a static TrueType or CFF version

Build errors

CodeKindWhat happenedWhat to do
invalid-imageinputimage bytes are not a readable image of the format they were given aspass the complete bytes of a JPEG or PNG file to Image::jpeg or Image::png
unsupported-imageunsupportedthe image uses a feature that PDF or lamina does not supportconvert it to a baseline or progressive 8-bit JPEG, or to PNG
image-too-largelimitthe image needs more memory than the builder allows (a decoded PNG over 256 MiB, or raw dimensions whose size overflows)scale the image down before adding it
image-data-lengthusageraw image samples are not width x height x channels bytes longpass exactly 4 bytes (RGBA) per pixel, row by row
invalid-icc-profileinputthe bytes are not a usable ICC profilepass a complete ICC profile with a Gray, RGB or CMYK data colour space
color-componentsusagea colour has the wrong number of components for its colour spacegive one component per channel of the colour space (/N of the ICC profile)
invalid-colorusagea colour string is not of the form #rgb or #rrggbbwrite the colour as # followed by 3 or 6 hexadecimal digits
invalid-geometryusagea page size, box, /UserUnit, drawing value (coordinate, matrix, line width, dash, miter limit) or image size is not usableuse finite coordinates, positive page sizes and /UserUnit, non-negative line widths and dashes, a miter limit of at least 1, and images of at least one pixel
text-overflowusagea text box's lines don't all fit its height and its options asked for an errormake the box taller or the text shorter, or use Overflow::Clip and read TextLayout::overflow
page-index-out-of-rangeusagea link, outline item or destination names a page index the document doesn't haveuse a 0-based index below the document's page count
unknown-destinationusagea link or outline item names a destination that was never defineddefine it with Builder::destination before the build finishes, or link to a page
invalid-page-labelsusagepage label ranges that don't start at page 0, don't increase, start past the last page or number from 0give ranges sorted by first page, the first at page 0, numbered from 1

Render errors

CodeKindWhat happenedWhat to do
render-too-largelimitthe requested tile is larger than the render limits allow; nothing was allocatedrequest smaller tiles (256 to 512 pixels at high zoom) or raise RenderLimits if the larger bitmap is intended
render-failedinputthe render engine could not open the document or draw the pagethe file may be damaged or use a feature this engine can't draw; try the other backend, or report the file
render-backend-unavailableiothe render engine is not available: its library or module could not be loadedrun cargo xtask fetch-pdfium or set LAMINA_PDFIUM_DIR to the folder holding the PDFium library

Facade errors

CodeKindWhat happenedWhat to do
cancelledcancelleda CancelToken stopped the work; the job is finished and returned no partial resultnothing to do: this is the outcome the caller asked for; start a new job to try again
job-finishedstatea job was stepped after it had finished, failed or been cancelledstop stepping a job once a step returned its result or an error; create a new job
document-changedstatethe document a job was created for changed (an edit, undo, redo, save or rebase) or a different document was passed to steppass the document the job was created from, and don't change it while the job runs; create a new job

Binding errors

CodeKindWhat happenedWhat to do
builder-finishedstatea builder or one of its pages was used after it finishedcreate a new builder or page: a finished one takes no more drawing, pages, fonts or settings
invalid-argumentusagea value passed to a binding does not have the shape its type declarespass the value the type declarations describe; the data field says what was wrong
source-budget-exceededlimita sparse source was given more bytes than its byte budget allowsraise the source's budget, or open the file with fewer bytes fetched (smaller blocks, no readahead)
unknown-optionusagean options record passed to a binding has a key lamina does not knowremove the key or correct its spelling; didYouMean lists the closest known names

Package errors

CodeKindWhat happenedWhat to do
already-initializedstateinit() or loadText() named a different source for a module that is already loaded or loadingcall init and loadText with a source once, before the first load; later calls need no source
extract-module-not-loadedstatepage.text() was called on a document opened in the base module, which has no text extractionload the extract module (init with the extract option, or loadExtract) or the text module before opening the document
fetch-failedioa range source could not fetch input bytes: a network error, an HTTP status other than 200 and 206, a 206 whose Content-Range or length doesn't match the request, or a read that returned the wrong number of bytescheck that the URL is reachable and that the server sends the CORS headers range requests need (Content-Range must be exposed); data.reason and data.status say what failed
not-initializedstatean @lamina/pdf function was called before init() finished loading the WebAssembly moduleawait init() once before calling anything else in @lamina/pdf
source-changedioa remote file changed while it was being read: its ETag or length differs from the first responseopen the file again; the document already read parts of the old version and can't mix in the new one
text-module-not-loadedstatea font or text call was made on a builder of the base module, which has no fonts or textload the text module with init and the text option, or with loadText, before creating the builder that draws text
disposedstatea document, builder or other handle was used after free(), or after the using block that held it endedfree a handle only after its last use; to keep working, open the document again or create a new builder
worker-version-mismatchusagethe worker answered with a different protocol or package version than the clientserve the worker file from the same @lamina/pdf build as the page; don't load it from a CDN or an older deploy
worker-crashedinternalthe worker running lamina stopped (an uncaught error, a WebAssembly trap or out of memory); calls in flight were rejectedcall client.restart() and open the document again; report the file if it keeps happening
worker-failedinternalthe worker client failed with an error that isn't lamina's (a bug in @lamina/pdf/worker, or a result it couldn't send)this is a lamina bug: report it with the call and the message; the worker keeps running