Example usage for org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination PDPageFitDestination setPage

List of usage examples for org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination PDPageFitDestination setPage

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination PDPageFitDestination setPage.

Prototype

public void setPage(PDPage page) 

Source Link

Document

Set the page for a local destination.

Usage

From source file:uia.pdf.PDFMaker.java

License:Apache License

/**
 * Add bookmark.//from  w ww .ja va  2s.com
 * @param page Page.
 * @param text bookmark text.
 * @throws IOException
 */
public PDPage addBookmark(ContentView view, PDPage page, String text) throws IOException {
    text = text == null ? "" : text.trim();
    PDPageFitDestination dest = new PDPageFitDestination();
    dest.setPage(page);

    for (PDOutlineItem oi : this.temp) {
        oi.setDestination(dest);
    }

    if (text.trim().length() > 0) {
        this.lastOI = new PDOutlineItem();
        this.lastOI.setDestination(dest);
        this.lastOI.setTitle(text);
        this.hierarchyOI.peek().addLast(this.lastOI);
        this.bookmarkPages.add(new BookmarkPage(text, "" + this.doc.getNumberOfPages()));

        this.temp.add(this.lastOI);
    }

    page = view.drawBookmarks(page, this.temp);
    this.temp.clear();

    return page;
}