Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1859

ClassCastException for unknown destination type

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.3, 1.8.8, 1.8.9
    • 1.8.9
    • PDModel
    • None

    Description

      Trying to read the outlines failed for the attached document.

      import java.io.IOException;
      
      import org.apache.pdfbox.pdmodel.PDDocument;
      import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination;
      import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;
      import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineNode;
      
      public class TestPDDestination {
      
      	public static void main(String[] args) throws IOException {
      		PDDocument doc = PDDocument.load("Speisepläne.pdf");
      		traverse(doc.getDocumentCatalog().getDocumentOutline());
      		doc.close();
      	}
      	
      	static void traverse(PDOutlineNode node) throws IOException {
      		if (node instanceof PDOutlineItem) {
      			PDDestination dst = ((PDOutlineItem) node).getDestination();
      			/**
      			 * throws java.lang.ClassCastException: org.apache.pdfbox.cos.COSFloat cannot be cast to org.apache.pdfbox.cos.COSName,
      			 * but should be something like a PDPageXYZDestination!
      			 */
      			System.out.println(dst);
      		}
      		for (PDOutlineItem child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
      			traverse(child);
      		}
      	}
      }
      

      Attachments

        1. Speisepläne.pdf
          109 kB
          Hendrik Lescak

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tilman Tilman Hausherr
            hendrik.lescak Hendrik Lescak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment