[ 
https://issues.apache.org/jira/browse/TIKA-4891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18115446#comment-18115446
 ] 

Tilman Hausherr edited comment on TIKA-4891 at 9/15/26 7:40 AM:
----------------------------------------------------------------

Copilot commented on code in PR #3172:
URL: https://github.com/apache/tika/pull/3172#discussion_r4012973500

{noformat}
##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pdf-module/src/main/java/org/apache/tika/parser/pdf/PDFMarkedContent2XHTML.java:
##########
@@ -1467,20 +1468,11 @@ private ElementSpec spec(StructureIndex.Node node) {
             chain.add(n);
         }
         for (int i = chain.size() - 1; i >= 0; i--) {
-            chain.get(i).spec = buildSpec(chain.get(i));
+            chain.get(i).spec = buildSpec(chain.get(i), new AttributesImpl());
{noformat}

Review Comment:
   Removing this fallback broadens the PDFBox compatibility fix into a 
regression for malformed tagged PDFs. `mapType` still invokes several PDFBox 
accessors besides `/Headers` (for example element language/title and table 
span/scope); if any throws, the exception now escapes structure-tree emission 
instead of rebuilding the element without optional attributes as before. Keep 
the catch-and-rebuild guard while bypassing only `getHeaders()`.
   
   This issue also appears on line 1693 of the same file.






was (Author: githubbot):
Copilot commented on code in PR #3172:
URL: https://github.com/apache/tika/pull/3172#discussion_r4012973500


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pdf-module/src/main/java/org/apache/tika/parser/pdf/PDFMarkedContent2XHTML.java:
##########
@@ -1467,20 +1468,11 @@ private ElementSpec spec(StructureIndex.Node node) {
             chain.add(n);
         }
         for (int i = chain.size() - 1; i >= 0; i--) {
-            chain.get(i).spec = buildSpec(chain.get(i));
+            chain.get(i).spec = buildSpec(chain.get(i), new AttributesImpl());

Review Comment:
   Removing this fallback broadens the PDFBox compatibility fix into a 
regression for malformed tagged PDFs. `mapType` still invokes several PDFBox 
accessors besides `/Headers` (for example element language/title and table 
span/scope); if any throws, the exception now escapes structure-tree emission 
instead of rebuilding the element without optional attributes as before. Keep 
the catch-and-rebuild guard while bypassing only `getHeaders()`.
   
   This issue also appears on line 1693 of the same file.





> Improve handling of PDF/UA structural tags/marked content
> ---------------------------------------------------------
>
>                 Key: TIKA-4891
>                 URL: https://issues.apache.org/jira/browse/TIKA-4891
>             Project: Tika
>          Issue Type: Task
>            Reporter: Tim Allison
>            Priority: Major
>         Attachments: 1008690.pdf, TIKA-4891-1008690.html, 
> image-2026-09-13-10-54-59-251.png, screenshot-1.png, screenshot-2.png
>
>
> PDF/UA includes structural markup. We hacked out a standalone handler for 
> this back in 1.x but haven't touched it in years.
>  
> We should modernize our handling of structural tags and eventually consider 
> turning that on by default. That decision will be based on evaluation on 
> 1000s of PDFs. This is not a default switch to be taken lightly.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to