[
https://issues.apache.org/jira/browse/PDFBOX-251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adam Nichols resolved PDFBOX-251.
---------------------------------
Assignee: Adam Nichols
Resolution: Not A Problem
There's leading whitespace on the "CMC" node, which is why it is not equal. It
works fine if the if statement is changed to:
if(strTitle.trim().equalsIgnoreCase("CMC"))
Here's the code to test this and verify my results.
public static void main(String[] args) {
PDDocument doc = null;
try {
doc = PDDocument.load("C:\\TEMP\\output.pdf");
PDDocumentOutline root =
doc.getDocumentCatalog().getDocumentOutline();
PDOutlineItem currentNode = root.getFirstChild();
while( currentNode != null ) {
String strTitle = currentNode.getTitle();
System.out.println( "Item:" +strTitle );
if(strTitle.trim().equalsIgnoreCase("CMC")){
System.out.println("cmc node");
}
PDOutlineItem childNode = currentNode.getFirstChild();
while( childNode != null ) {
System.out.println("Child:"+childNode.getTitle());
childNode = childNode.getNextSibling();
}
currentNode = currentNode.getNextSibling();
}
} catch(Exception e) {
System.out.println("FAIL");
} finally {
if(doc != null)
try { doc.close(); } catch(Exception e) { }
}
System.out.println("END");
}
> Read Bookmarks
> --------------
>
> Key: PDFBOX-251
> URL: https://issues.apache.org/jira/browse/PDFBOX-251
> Project: PDFBox
> Issue Type: Bug
> Assignee: Adam Nichols
> Priority: Minor
>
> [imported from SourceForge]
> http://sourceforge.net/tracker/index.php?group_id=78314&atid=552833&aid=1666294
> Originally submitted by nobody on 2007-02-22 07:48.
> I need to read the bookmarks from the pdf & create an index of the bookmarks
> Example I have used the pdfbox to actually create the bookmarks in the .pdf
> and set their titles.
> while( currentNode != null ) {
> strTitle = currentNode.getTitle();
> System.out.println( "Item:" +strTitle );
> if(strTitle.equalsIgnoreCase("CMC")){
> System.out.println("cmc node");
> }
> childNode = currentNode.getFirstChild();
> while( childNode != null ) {
> System.out.println("Child:"+childNode.getTitle());
> childNode = childNode.getNextSibling();
> }
> currentNode = currentNode.getNextSibling();
> }
> OUTPUT:
> Item: Index
> Item: CMC
> Child: 3.2.S Drug Substance
> Child: 3.2.P Drug Product
> HOWEVER THE STRING COMPARISION DID NOT WORK ??
> [attachment on SourceForge]
> http://sourceforge.net/tracker/download.php?group_id=78314&atid=552833&aid=1666294&file_id=217237
> output.pdf (application/pdf), 85286 bytes
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.