Repository navigation
Read where an annotation sits in its document's structure tree - #100
Merged
Merged
Conversation
EPDFAnnot_GetStructurePosition() gives an annotation's place in the logical structure (the tags, ISO 32000-2 14.7): from the structure tree root down to its object reference (/OBJR), the index of each step among its parent's /K kids. Compared index by index, two positions give the tags' reading order, the order a page's /Tabs /S gives its annotations focus in, which most tagged forms ask for (the USCIS forms, Acrobat's, Word's, a browser's print). It's found from the annotation up: its /StructParent, the parent tree, then each element's /P, so no page is loaded and nothing else in the tree is read. An annotation the tree doesn't reach has none: no /StructParent, a parent tree that doesn't lead to an element listing it, or a broken way up (a missing /P, a parent that doesn't list its kid, a cycle, more than 256 levels). PDFium's structure tree API can't answer this: FPDF_StructTree_GetForPage() needs the page loaded, builds the page's tree only from its content (a /Form element holding just a widget's /OBJR isn't in it), and has no way to read an object reference's target. Tests: structure_position.in (a nested parent tree, a /K that is one kid, an /OBJR after a marked-content kid; untagged, unlisted, cyclic and missing entries), read from raw and loaded pages, a buffer shorter than the position, an untagged document; the C API list. Layer mode: the reads write nothing.
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.
Adds
EPDFAnnot_GetStructurePosition(): where an annotation sits in its document's logical structure (the tags, ISO 32000-2 14.7), as the index of each step from the structure tree root down to its object reference (/OBJR). Compared index by index, two positions give the tags' reading order, which a page's/Tabs /Sasks annotations to take focus in. Most tagged forms ask for it: the USCIS forms, Acrobat's, Word's, a browser's print./StructParent, the parent tree, then each element's/P. No page is loaded, and nothing else in the tree is read./StructParent, a parent tree that doesn't lead to an element listing it, or a broken way up (a missing/P, a parent that doesn't list its kid, a cycle, more than 256 levels).FPDF_StructTree_GetForPage()needs the page loaded, builds only from the page's content (a/Formelement holding just a widget's/OBJRisn't in it), and can't read an object reference's target.On the USCIS I-140, all 33 page-1 widgets resolve, and their positions give the form's printed order. Its
/Annotsorder starts with a barcode and puts the attorney's box after Part 1.Tests
structure_position.in: a nested parent tree, a/Kthat is one kid, and an/OBJRafter a marked-content kid; plus untagged, unlisted, cyclic and missing entries.The engine side,
structurePositionon every annotation andtabOrderOf(), is in embedpdf/embed-pdf-viewerfeature/structure-tab-order. It needs this released and pinned.