Example usage for com.lowagie.text.pdf PdfWriter getPageReference

List of usage examples for com.lowagie.text.pdf PdfWriter getPageReference

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfWriter getPageReference.

Prototype

public PdfIndirectReference getPageReference(int page) 

Source Link

Document

Use this method to get a reference to a page existing or not.

Usage

From source file:docet.engine.PDFDocumentHandler.java

License:Apache License

private void writeTOCBookmarks(Collection<DocumentPart> documents, PdfWriter writer) {

    writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);

    PdfOutline root = writer.getRootOutline();

    Map<DocumentPart, PdfOutline> outlines = new HashMap<>();

    for (DocumentPart document : documents) {

        PdfOutline parent = outlines.getOrDefault(document.parent, root);

        PageBox page = document.pages.get(0);

        //            PdfDestination dest = new PdfDestination(PdfDestination.XYZ, 0, 0, 0);
        PdfDestination dest = new PdfDestination(PdfDestination.FIT);

        LOGGER.log(Level.FINE, "Writing bookmark {0} - {1} to page {2}",
                new Object[] { title, document.name, document.startPageNo + page.getPageNo() });

        dest.addPage(writer.getPageReference(document.startPageNo + page.getPageNo()));

        PdfOutline outline = new PdfOutline(parent, dest, document.name, true);

        outlines.put(document, outline);

    }//from  w ww. j  a v a  2  s  . c om

}