Example usage for org.apache.pdfbox.pdmodel.interactive.action PDActionGoTo getDestination

List of usage examples for org.apache.pdfbox.pdmodel.interactive.action PDActionGoTo getDestination

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.action PDActionGoTo getDestination.

Prototype

public PDDestination getDestination() throws IOException 

Source Link

Document

This will get the destination to jump to.

Usage

From source file:org.pdfmetamodifier.OutlineHelper.java

License:Apache License

private static Integer getOutlinePageNumber(final PDOutlineItem outlineItem, final PDPageTree pages,
        final PDDestinationNameTreeNode destinations) throws IOException {
    final PDAction action = outlineItem.getAction();
    if (action != null) {
        if (action instanceof PDActionGoTo) {
            final PDActionGoTo actionGoTo = (PDActionGoTo) action;

            return getDestinationPageNumber(actionGoTo.getDestination(), pages, destinations);
        }/*from   w w  w  .j  av a  2  s. c  o m*/

        // Ignore other actions.
    }

    return getDestinationPageNumber(outlineItem.getDestination(), pages, destinations);
}

From source file:org.xwiki.test.misc.PDFTest.java

License:Open Source License

private Map<String, String> extractToLinks(URL url, int tocPageIndex) throws Exception {
    Map<String, String> internalLinks = new HashMap<String, String>();
    PDDocument document = null;/*  w w  w.  ja v a2 s .  co m*/
    try {
        document = PDDocument.load(IOUtils.toByteArray(url));
        PDPage tocPage = document.getDocumentCatalog().getPages().get(tocPageIndex);
        for (Map.Entry<String, PDAction> entry : extractLinks(tocPage).entrySet()) {
            if (entry.getValue() instanceof PDActionGoTo) {
                PDActionGoTo anchor = (PDActionGoTo) entry.getValue();
                internalLinks.put(entry.getKey(), getDestinationText(anchor.getDestination()));
            }
        }
    } finally {
        if (document != null) {
            document.close();
        }
    }
    return internalLinks;
}