Rendering and I/O errors
These entries cover the rendering and input/output (I/O) exceptions raised while the HTML pipeline lays out content, the paged-media resolver assigns page geometry, the text shaper processes complex scripts, the typography stage breaks lines, the writer serializes a document, the reader parses an existing PDF, and the metadata stage reads an Extensible Metadata Platform (XMP) packet.
Two base hierarchies appear below, and the difference governs what diagnostic
data you can read after a catch:
NextPdfExceptionimplementsContextAwareExceptionInterface::getContext(): array. The base implementation returns an empty array; a subclass carries structured keys only when it overridesgetContext(). Subclasses that do not override it still expose their data throughpublic readonlyproperties.- Several classes here extend PHP’s
RuntimeExceptiondirectly. They are not context-aware and have nogetContext()method; read theirgetMessage()and any public properties instead.
Each entry names the exact class, the trigger condition, the context keys or public properties it carries, and the recovery path.
HTML layout and paged media
Section titled “HTML layout and paged media”UnsplittableContentException
Section titled “UnsplittableContentException”- When it is thrown. The HTML layout engine raises this when content marked
break-inside: avoid(a table cell whose break constraint isAvoid) has a measured height that exceeds the usable height of a single page. The engine cannot satisfy both the avoid-break constraint and the page boundary, so it fails rather than silently overflow. - Carried data. Extends
NextPdfExceptionbut does not overridegetContext(), sogetContext()returns an empty array. The diagnostic data is onpublic readonlyproperties:gridRow(int),gridCol(int),contentHeight(float, points), andpageHeight(float, points). The message names the cell coordinates and both heights. - Recovery. Remove the
break-inside: avoidconstraint on the offending cell, reduce the cell’s content so it fits one page, or increase the page size or reduce its margins so the usable height accommodates the content.
BudgetExceededException
Section titled “BudgetExceededException”- When it is thrown. Retained-mode layout primitives raise this when one of
the four resource-budget tiers defined in architecture decision record
ADR-020 is breached and the caller opted into a hard failure rather than the
soft fallback. The default path does not throw:
ContainerLayout::acceptChild()returnsfalse, the caller falls back to block layout, and a warning is emitted. The exception is reserved for configuration-time validation and for tests that assert the exact breach tuple. The tiers areper-child(a captured child stream exceeds its cap),per-container(the Tier 1 node-count budget),per-document(the layout-pass or nesting-depth budget), andglobal(the SDK-wide 256 MB peak resident-set-size ceiling). - Carried data. Overrides
getContext(), which returns a stable eight-key shape consumed by application performance monitoring (APM) tooling:budgetTier,exceededValue,budgetLimit,containerType,phase,breachOrigin,captureSize, andprocessedItemCount. The first four keys are the original v1.0.0 subset and are always populated; the latter four default tonullor0when the constructor is called without them.getCausalWarningCode()maps the (tier, container-type) tuple to theWarningCodethe soft-fallback path would have emitted. - Recovery. For a configuration breach, lower the requested value back into
the documented envelope (for example, the retained node budget accepts
5,000to100,000viaConfig::withRetainedNodeBudget()). For a content breach, reduce container nesting or node count, or rely on the default soft-fallback to block layout instead of opting into the hard-failure surface.
UnsupportedNamedPageException
Section titled “UnsupportedNamedPageException”- When it is thrown. The paged-media stage raises this, fail-closed, when a
document declares a named
@page <ident> { … }rule (bound to content through thepage: <ident>property). Named pages from CSS Paged Media Level 3 §3.4 and Level 4 §3.2 — including the:first,:left,:right, and:blankpseudo-classes and namedsize:androtate:overrides — are parsed but no production layout path consumes them. The engine refuses rather than emit the silently-incorrect default pagination that discarding the rule would produce. - Carried data. Overrides
getContext(), which returnspage_names(list of the distinct idents that triggered the failure, in source order),has_size_override(bool),has_rotate_override(bool), andhas_pseudo_classes(bool). The same values are exposed on thepageNames,hasSizeOverride,hasRotateOverride, andhasPseudoClassespublic properties. - Recovery. Remove the named
@page <ident>rules and anypage: <ident>bindings, and express the intended geometry through the supported unnamed@page { … }rule and its pseudo-class forms. Alternatively, pin to a future release that lands full named-page layout support.
Typography and text shaping
Section titled “Typography and text shaping”IcuRequirementException
Section titled “IcuRequirementException”- When it is thrown. Text segmentation raises this when it needs the
International Components for Unicode (ICU) line-break iterator but the
require-ICU policy is active (
NEXTPDF_REQUIRE_ICU=1) while theext-intlextension andIntlBreakIteratorare unavailable. - Carried data. Extends
RuntimeExceptiondirectly, so it is not context-aware and has nogetContext(). It is a strict refinement of the generic exception the same code path previously threw, so existingcatch (\RuntimeException)handlers continue to work. - Recovery. Install and enable
ext-intlso the ICU break iterator is available, or unsetNEXTPDF_REQUIRE_ICUto fall back to the non-ICU segmenter where the require-ICU policy is not mandatory.
ScriptShaperException
Section titled “ScriptShaperException”- When it is thrown. This is the base exception for the script-shaping service provider interface (SPI). It is not thrown directly today; concrete subtypes are thrown instead. Catch this type to handle any shaping failure in one place.
- Carried data. Extends
RuntimeExceptiondirectly; not context-aware, nogetContext(). - Recovery. Branch on the concrete subtype. See
NotYetImplementedExceptionbelow for the only subtype shipped in the current release.
NotYetImplementedException
Section titled “NotYetImplementedException”- When it is thrown. Every placeholder script-shaper raises this from its
shape()body for scripts whose concrete shaping is deferred (Mongolian and Tibetan). The shaping SPI seam is architecture-ready, but real shaping is pending a native-speaker-validated fixture. Raising an exception rather than a silent no-op surfaces accidental production wiring at runtime instead of emitting unshaped text into a PDF that claims tagged accessibility. - Carried data. Extends
ScriptShaperException(and thereforeRuntimeException), so it is not context-aware and has nogetContext(). The diagnostic data is on itspublic readonlyproperties:bcp47LanguageTag(the BCP-47 tag of the run, such asmn-Mongorbo-Tibt) andmissingCapability(the concrete capability the implementation lacks). The message includes both. - Recovery. Do not route runs in the unimplemented scripts through the shaper in production. Detect the language tag upstream and either fall back to a different rendering path or pin to a future release that lands shaping for the affected script.
Writer output profiles and encryption
Section titled “Writer output profiles and encryption”Pdf14FeatureRejectedException
Section titled “Pdf14FeatureRejectedException”- When it is thrown. The writer raises this when a document contains a feature forbidden under the PDF 1.4 output profile (ISO 19005-1:2005 / PDF/A-1), which prohibits constructs introduced in later PDF versions.
- Carried data. Extends
NextPdfExceptionbut does not overridegetContext(), sogetContext()returns an empty array. The diagnostic data is on itspublic readonlyproperties:feature(the rejected feature name),reason(why it is forbidden), andisoClause(the ISO clause reference). The message combines all three. - Recovery. Remove or replace the rejected feature with a PDF 1.4-compatible equivalent, or target a higher output profile that permits the feature.
Pdf20FeatureRejectedException
Section titled “Pdf20FeatureRejectedException”- When it is thrown. The writer raises this when a document contains a feature forbidden under the strict PDF 2.0 output profile. ISO 32000-2:2020 deprecates constructs that PDF 1.7 still permitted — most notably the Standard 14 Type 1 fonts (§9.6.2), which must be embedded in a conforming PDF 2.0 document.
- Carried data. Same shape as
Pdf14FeatureRejectedException: extendsNextPdfException, does not overridegetContext()(returns an empty array), and exposesfeature,reason, andisoClauseaspublic readonlyproperties. - Recovery. Remediate the rejected feature — for example, embed the base 14
fonts — or take the documented escape hatch where one exists (for non-embedded
base 14 fonts,
Document::allowNonEmbeddedBase14()).
PublicKeyEncryptionUnsupportedException
Section titled “PublicKeyEncryptionUnsupportedException”- When it is thrown.
PdfWriter::build()raises this at the entry point when the document’sencryptionModeispubkey(a public-key recipient list) before the writer-side public-key stream-body encryption dispatch is wired. Refusing up front prevents silently emitting an unencrypted PDF the caller believed to be encrypted. - Carried data. Extends
RuntimeExceptiondirectly, so it is not context-aware and has nogetContext(). It is a strict refinement of the generic exception the same site previously threw, so existingcatch (\RuntimeException)handlers continue to work. - Recovery. Use a supported encryption mode (password-based encryption) instead of the public-key recipient list, or pin to a release that lands public-key encryption support. Do not treat the output as encrypted when this is thrown.
Reader and metadata input
Section titled “Reader and metadata input”UnsupportedPdfStructureException
Section titled “UnsupportedPdfStructureException”- When it is thrown. The object-graph reader raises this, fail-closed, when
an input PDF falls outside its supported envelope. The reader supports classic
cross-reference tables (ISO 32000-2:2020 §7.5.4), cross-reference streams
(§7.5.8), object-stream-compressed objects (§7.5.7), multi-revision
/Prevchains (§7.5.6), and hybrid-reference files via/XRefStm(§7.5.8.4). Anything outside that envelope surfaces this exception rather than a partial or guessed parse. Named constructors map to the reason cases:encrypted(),damagedCrossReference(),cyclicReferenceChain(),nonConformantObjectStream(),irresolvableObjectCollision(),truncatedFile(), andcrossReferenceOffsetOutOfBounds(). - Carried data. Extends
RuntimeExceptiondirectly, so it is not context-aware and has nogetContext(). It exposes apublic readonlyreasonproperty of typeUnsupportedPdfStructureReason(an enum) so callers branch on the precise category without parsing the message; an optionaldetailstring and apreviousthrowable may add bounded, non-sensitive context. The default message is the reason’s non-leaking summary. - Recovery. Branch on
reason. ForEncryptedDocument, run a decrypt step before reading, since decryption is outside the reader’s scope. ForDamagedCrossReference,TruncatedFile, orCrossReferenceOffsetOutOfBounds, treat the file as malformed or incomplete and re-acquire or repair the source. ForCyclicReferenceChain,NonConformantObjectStream, orIrresolvableObjectCollision, the input violates the structural model and cannot be read as-is.
PacketTooLargeException
Section titled “PacketTooLargeException”- When it is thrown. The streaming XMP metadata reader raises this when an embedded XMP packet exceeds the configured byte ceiling. It is a defensive guard against entity-expansion and quadratic-blowup style inputs (a 128 MB peak ceiling against gigabyte-scale embedded XMP).
- Carried data. Extends
NextPdfExceptionbut does not overridegetContext(), sogetContext()returns an empty array. The diagnostic data is on itspublic readonlyproperties:byteCount(the observed byte count) andcap(the configured cap in bytes). The message reports both. - Recovery. Reject or skip the oversized metadata as malicious or malformed. If a legitimate document genuinely needs a larger packet, raise the configured cap deliberately, weighing the memory-exhaustion risk the guard exists to prevent.
See also
Section titled “See also”- Error reference index
- Fonts and tagging troubleshooting — for
NotYetImplementedException,ScriptShaperException, andIcuRequirementExceptionsymptoms. - PDF/A and PDF/UA validation troubleshooting — for
Pdf14FeatureRejectedExceptionandPdf20FeatureRejectedExceptionsymptoms. - Encryption and permissions troubleshooting — for
PublicKeyEncryptionUnsupportedExceptionand the reader’sEncryptedDocumentreason.