[
https://issues.apache.org/jira/browse/PDFBOX-3368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15306796#comment-15306796
]
ASF subversion and git services commented on PDFBOX-3368:
---------------------------------------------------------
Commit 1746152 from [~lehmi] in branch 'pdfbox/branches/1.8'
[ https://svn.apache.org/r1746152 ]
PDFBOX-3368: use the underlying map to check if a key is present
> ContainsKey don't work for he Map<String, Object> returned by
> PDStructureTreeRoot.getRoleMap
> --------------------------------------------------------------------------------------------
>
> Key: PDFBOX-3368
> URL: https://issues.apache.org/jira/browse/PDFBOX-3368
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.8.12, 2.0.1
> Environment: Windows 10
> Reporter: Carlos Cabral
> Assignee: Andreas Lehmkühler
> Priority: Trivial
> Labels: patch
> Fix For: 1.8.13, 2.0.2, 2.1.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> No sure if it is an expected behaviour or a bug.
> The Method PDStructureTreeRoot.getRoleMap returns a map which the key is a
> String (Map<String, Object>).
> However when we use map.containsKey("Header") it always return false because
> instead of a String it is waiting for A COSName instance.
> Then we have to use map.containsKey(COSName.getPDFName("Header"));
> In the other the method map.get("Header"); works
> {code:title=Test.java}
> //PDF Filte tested:
> //http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
> try (PDDocument document = PDDocument.load(new File("PDF32000_2008.pdf"));){
> PDStructureTreeRoot treeRoot =
> document.getDocumentCatalog().getStructureTreeRoot();
> Map<String, Object> roleMap = treeRoot.getRoleMap();
> //Returned map: COSDictionaryMap<K,V>
> System.out.println(roleMap.containsKey("Header"));//No work
> System.out.println(
> roleMap.containsKey(COSName.getPDFName("Header")));//Works
> } catch (IOException ex) {
> ex.printStackTrace();
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]