Example usage for com.lowagie.text.pdf PdfOutline PdfOutline

List of usage examples for com.lowagie.text.pdf PdfOutline PdfOutline

Introduction

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

Prototype

public PdfOutline(PdfOutline parent, PdfDestination destination, Paragraph title, boolean open) 

Source Link

Document

Constructs a PdfOutline.

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 w w . j  av a2 s. co  m

}