We are creating pdf documents in Java using pdfBox. Since they should be accessible by Screenreaders, we are using tags and we are setting up a parentTree and we add that to the document catalog.
Please find an example file here.
When we check the resulting pdf with PAC3 validator we get 25 errors for inconsistent entries in the structural parent tree.

Same result but more details in Adobe prefight syntax error check. The error message is
Inconsistent ParentTree mapping (ParentTree element 0) for structure element
Traversal Path:->StructTreeRoot->K->K->[1]->K->[3]->K->[4]
Adobe preflight syntax error check

When i try to follow that traversal path in pdfBox Debugger, i see an element referencing the ID 22.
Now my questions are:
- What is the connection between the StructTreeRoot and the ParentTree?
- Where in the StructTreeRoot/ParentTree can i find the item with ID 22 that is refered to in node K->K->2->K->4->K->4? See image PDF Debugger
- What is that Parent Tree element 0 in the Preflight error message? See image Adobe preflight syntax error check
PDF Debugger

I think, building accessible pdf with pdfBox as well as error messages from common validation tools are rather poorly documented. Or where can i find more information about it?
Thanks a lot for your help.


The issue in your PDF reminds very much of the issue discussed in the last section "Yet another issue with parent tree entries" in this answer to the question “Find Tag from Selection” is not working in tagged pdf? by fascinating coder:
Instead you should simply reference the actual parent structure element of the MCID.
As your question title asks how to heal inconsistent parent tree mappings in a PDF created by pdfBox, here an approach to fix your parent tree by rebulding the parent tree from the structure tree.
First recursively collect MCIDs and their parent structure tree elements by page, e.g. using a method like this:
(RebuildParentTreeFromStructure method)
with this helper method
(RebuildParentTreeFromStructure helper method)
and then rebuild based on the collected information:
(RebuildParentTreeFromStructure method)
Applied like this
(RebuildParentTreeFromStructure test
testTestdatei)PAC3 and Adobe Preflight (at least of my old Acrobat 9.5) go all green for the result:
Beware: This is no generic parent tree rebuilder yet. It is made to work for the test file at hand with a specific kind of structure tree nodes and content only in page content streams. For a generic tool it has to learn to cope with other kinds, too, and to also process e.g. marked content in embedded XObjects.