Skip to content
Lamina PDF
Unreleased

These docs describe changes that aren’t released yet. For the newest release, see the released docs.

Error and warning codes

Every error and warning Lamina PDF raises, in Rust, in WebAssembly and in @laminapdf/sdk, 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 PDF 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 PDF 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)
extract-limit-blockslimita page had more runs of text than the extraction block limit; the runs past it were left outraise ExtractLimits::max_blocks_per_page if the page really has that many blocks
extract-reading-order-ambiguousunsupporteda page mixes horizontal and vertical writing, so the order of its blocks is a guessnothing to do; check the order of that page's blocks, or ask for content order
extract-table-ambiguousunsupporteda table's rules marked out merged cells that aren't rectangles, so its cells were kept unmergednothing to do; check that table's cells, whose text may be split across neighbours
extract-table-limitlimita page's ruling lines would make a table bigger than the extraction's cell limit; those lines gave no tableraise ExtractLimits::max_table_cells if the page really has a table that big
extract-struct-tree-ignoredinputa tagged page's structure tree covered too little of its text, or its order jumped back across columns too often, so the layout gave the reading ordernothing to do; ReadingOrder::Tagged uses the tree anyway
extract-untagged-contentinputa page read in structure-tree order has visible text that is neither in the tree nor an artifact; it follows the tree's blocks, in layout ordernothing to do; tag that text in the file to give it a place in the reading order

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 bug in Lamina PDF: 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 PDF 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 PDF 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 PDF 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 PDF 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 PDF'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 PDF 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
profile-version-conflictusagethe PDF version asked for is one the profile doesn't allow (PDF/UA-1, PDF/A-2 and PDF/A-3 are based on PDF 1.7)leave the version at 1.7 (the default) or lower; PDF 2.0 needs PDF/A-4 or PDF/UA-2, which Lamina PDF doesn't write yet
missing-titleusagePDF/UA-1 needs a document title, and the metadata gives noneset a title with Builder::metadata (Metadata::with_title)
missing-langusagePDF/UA-1 needs the document's natural language, and none was setset the language with Builder::lang, such as "en-GB"
missing-alt-textusagea Figure or Formula has no alternate text (/Alt or /ActualText), which PDF/UA-1 requiresgive the figure or formula a description with Tag::with_alt or Surface::figure's alt, or draw decoration as an artifact
untagged-contentusagecontent was drawn outside every structure element and artifact, which PDF/UA-1 forbidsdraw it inside Surface::tag (real content) or Surface::artifact (decoration)
heading-level-skippedusagea heading skips a level (the first is not H1, or an H3 follows an H1), which PDF/UA-1 forbidsstart with H1 and go down one level at a time
unnumbered-heading-misusedusagean unnumbered H heading shares its parent with another H, or the document also uses H1-H6, which PDF/UA-1 forbidsuse numbered headings (H1, H2, ...) throughout, or one H per section
invalid-structure-nestingusagea table or list element sits in a parent its type doesn't allow (a TD outside a TR, a P directly in a Table)nest tables as Table > TR > TH/TD and lists as L > LI > Lbl/LBody
link-without-structureusagea link annotation has no Link structure element (it was drawn inside an artifact), which PDF/UA-1 forbidsdraw links outside artifacts, so the builder gives each one a Link element
link-without-contentsusagea link annotation has no description (/Contents), which PDF/UA-1 requirespass a description as the link's contents
font-not-embeddedusagea standard 14 font, which is never embedded, was used under a profile that needs every font embeddedload a font file with Builder::font instead of Builder::standard_font
glyph-without-unicodeusagea glyph was drawn without a Unicode value, which PDF/A-2u and PDF/UA-1 forbiduse text whose glyphs each stand for characters, or choose PDF/A-2b, which doesn't need Unicode
device-color-without-output-intentusagea DeviceCMYK colour or image was used, but the PDF/A output intent is sRGBuse RGB or gray colours, or a CMYK colour with an ICC profile (Color::icc)
embedded-file-forbiddenusagePDF/A-2 doesn't allow attached files that aren't PDF/A themselveschoose PDF/A-3b, which allows attached files of any kind
embedded-file-without-mime-typeusagean attached file has no MIME type, which every PDF/A profile requirespass the file's MIME type, such as text/xml or application/octet-stream

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_PDF_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
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
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 PDF 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 @laminapdf/sdk function was called before init() finished loading the WebAssembly moduleawait init() once before calling anything else in @laminapdf/sdk
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
worker-version-mismatchusagethe worker answered with a different protocol or package version than the clientserve the worker file from the same @laminapdf/sdk build as the page; don't load it from a CDN or an older deploy
worker-crashedinternalthe worker running Lamina PDF 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 PDF's (a bug in @laminapdf/sdk/worker, or a result it couldn't send)this is a bug in Lamina PDF: report it with the call and the message; the worker keeps running
wasm-trapinternalthe WebAssembly module trapped (a bug in Lamina PDF), so its instance was discarded and the next call gets a fresh oneopen the document again and retry; report the file and the call if it traps again
out-of-memorylimitthe WebAssembly module ran out of memory (its maximum, or what the engine could give), so its instance was discarded and the next call gets a fresh oneopen fewer or smaller documents at once and free each when done; lower the open limits so hostile files fail sooner
instance-resetstatea handle was used after its WebAssembly instance was replaced, by reset() or after a trapopen the document again or create a new builder: nothing from the old instance survives

Cli errors

CodeKindWhat happenedWhat to do
invalid-command-lineusagethe command line doesn't parse: an unknown command or flag, a missing argument, a bad value, or stdin named twicerun the command with --help to see its arguments
invalid-page-rangeusagea page range doesn't fit the grammar, or names a page the document lackswrite pages as 1-5, z for the last page, r2 for the second from the end, or x3 to leave page 3 out; data.position is the character where the range went wrong
binary-output-to-terminalusagethe command would write a PDF to standard output, and standard output is a terminalredirect standard output to a file or a pipe, or write to a file with -o
unknown-codeusageexplain was given a code that isn't a Lamina PDF error or warning codecheck the spelling against didYouMean, or list every code at the docs URL
overwrite-refusedstatethe output file exists, or the command would modify its input in place, and --force wasn't givenpass --force, or write to a new file with -o
input-unreadableioan input file, standard input or the password file couldn't be readcheck that the file exists and that you can read it; data.input names it
output-unwritableiothe output couldn't be written: its folder is missing or read-only, the disk is full, or standard output closedcheck that the output's folder exists, that you can write to it and that the disk has room
path-outside-rootssecuritylaminapdf mcp was given a path outside its --root folders, or a link that leads out of themuse a path inside one of the server's --root folders, or start the server with another --root