Example usage for com.lowagie.text.pdf PdfContentByte localDestination

List of usage examples for com.lowagie.text.pdf PdfContentByte localDestination

Introduction

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

Prototype

public boolean localDestination(String name, PdfDestination destination) 

Source Link

Document

The local destination to where a local goto with the same name will jump.

Usage

From source file:questions.stamppages.ParagraphBookmarkEvents.java

/**
 * Adds an outline for every new Paragraph
 * //from  ww  w.  ja va  2 s .  c  o  m
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfOutline root = cb.getRootOutline();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
    if (named) {
        cb.localDestination("p" + n, destination);
        new PdfOutline(root, PdfAction.gotoLocalPage("p" + n, false), "paragraph " + n);
    } else {
        new PdfOutline(root, destination, "paragraph " + n);
    }
}