Normalize semantic tree structure for PDF/A-1a compliance #1364
+175
−127
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.
Summary
This PR implements semantic tree normalization for PDF/A-1a documents by removing non-standard structural nodes and promoting their children to the correct hierarchy level. The normalization is applied immediately before the semantic tree is finalized and assigned to the document canvas, ensuring PDF/A-1a compliance without affecting other conformance modes.
Key Features
TBody,THead,TFoot) from the semantic treeSemanticTreeManagerTechnical Implementation
The semantic tree normalization logic is implemented directly inside
SemanticTreeManagervia theRemoveNonStandardStructureTypesmethod. This method performs a depth-first traversal of the tree and removes structural-only nodes that are not allowed under PDF/A-1a. When such a node is encountered, it is removed and its children are reinserted into the parent at the same position, preserving the original ordering.The normalization is invoked from
ConfigureWithSemanticTreeonly when PDF/A-1a conformance is enabled. This ensures that stricter structural requirements are applied conditionally and do not affect other PDF standards.After normalization, the semantic tree is retrieved, the manager state is reset, and the finalized tree is passed to the document canvas. This guarantees that:
Structural node types subject to removal are centralized in a static lookup to ensure fast evaluation and easy extensibility.