Fix parent chain of structure element attribute dictionaries#104
Open
siebej wants to merge 1 commit into
Open
Conversation
Build the /A array via add() so that every attribute dictionary gets this element as parent. The PDFArray(List) constructor does not set parents, so any string value inside an attribute dictionary (such as Table /Headers entries) crashes serialization with 'Parent PDFDocument is unavailable' as soon as a structure element carries more than one attribute dictionary (e.g. a span plus Headers).
siebej
force-pushed
the
fix-structelem-attribute-parents
branch
from
July 22, 2026 15:12
6a73053 to
e7d5411
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PDFStructElem.attachAttributesbuilds the/Aarray with thePDFArray(List)constructor, which — unlikePDFArray.add()andPDFDictionary.put()— does not set the parent of its elements. The attribute dictionaries therefore cannot reach thePDFDocumentthrough their parent chain.This is currently latent: the existing table attributes (ColSpan, RowSpan, Scope) never need the document during serialization. But any string value inside an attribute dictionary (for example a Table
/Headersattribute, or any attribute under encryption) crashes withIllegalStateException: Parent PDFDocument is unavailableas soon as a structure element carries more than one attribute dictionary. We hit this in production-like output with tagged tables.The fix builds the array via
add(), which does set parents. Includes a unit test that fails without the fix.I don't have an ASF Jira account, so there is no FOP issue number yet — happy to reference one if a committer creates it.