You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Carlos Cabral (JIRA)" <ji...@apache.org> on 2016/05/30 07:30:12 UTC
[jira] [Created] (PDFBOX-3368) ContainsKey don't work for he
Map returned by PDStructureTreeRoot.getRoleMap
Carlos Cabral created PDFBOX-3368:
-------------------------------------
Summary: 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: 2.0.1
Environment: Windows 10
Reporter: Carlos Cabral
Priority: Trivial
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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org