Java 类com.lowagie.text.pdf.PdfOutline 实例源码

项目:itext2    文件:BookmarksTest.java   
/**
 * Adds an outline for every new Paragraph
 * 
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH,
            position);
    new PdfOutline(cb.getRootOutline(), destination, "paragraph " + n);
}
项目:birt    文件:TOCHandler.java   
/**
 * The constructor.
 *
 * @param root
 *            The TOC node in which need to build PDF outline
 */
public TOCHandler( TOCNode root, PdfOutline outline, Set<String> bookmarks )
{
    this.root = root;
    this.outline = outline;
    this.bookmarks = bookmarks;
}
项目:itext2    文件:OutlineActionsTest.java   
/**
 * Demonstrates some PageLabel functionality.
 * 
 */
@Test
public void main() throws Exception {

    // step 1: creation of a document-object
    Document document = new Document();
    Document remote = new Document();
    // step 2:
    PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("OutlineActions.pdf"));
    PdfWriter.getInstance(remote, PdfTestBase.getOutputStream("remote.pdf"));
    // step 3:
    writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
    document.open();
    remote.open();
    // step 4:
    // we add some content
    document.add(new Paragraph("Outline action example"));
    // we add the outline
    PdfContentByte cb = writer.getDirectContent();
    PdfOutline root = cb.getRootOutline();
    PdfOutline links = new PdfOutline(root, new PdfAction("http://www.lowagie.com/iText/links.html"),
            "Useful links");
    links.setColor(new Color(0x00, 0x80, 0x80));
    links.setStyle(Font.BOLD);
    new PdfOutline(links, new PdfAction("http://www.lowagie.com/iText"), "Bruno's iText site");
    new PdfOutline(links, new PdfAction("http://itextpdf.sourceforge.net/"), "Paulo's iText site");
    new PdfOutline(links, new PdfAction("http://sourceforge.net/projects/itext/"), "iText @ SourceForge");
    PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false);
    other.setStyle(Font.ITALIC);
    new PdfOutline(other, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
    new PdfOutline(other, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");
    new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");

    remote.add(new Paragraph("Some remote document"));
    remote.newPage();
    Paragraph p = new Paragraph("This paragraph contains a ");
    p.add(new Chunk("local destination").setLocalDestination("test"));
    remote.add(p);

    // step 5: we close the document
    document.close();
    remote.close();
}
项目:itext2    文件:DestinationsTest.java   
/**
 * Creates a document with some goto actions.
 * 
 */
@Test
public void main() throws Exception {

    // step 1: creation of a document-object
    Document document = new Document();

    // step 2:
    PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Destinations.pdf"));
    // step 3:
    writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
    document.open();
    // step 4: we grab the ContentByte and do some stuff with it
    PdfContentByte cb = writer.getDirectContent();

    // we create a PdfTemplate
    PdfTemplate template = cb.createTemplate(25, 25);

    // we add some crosses to visualize the destinations
    template.moveTo(13, 0);
    template.lineTo(13, 25);
    template.moveTo(0, 13);
    template.lineTo(50, 13);
    template.stroke();

    // we add the template on different positions
    cb.addTemplate(template, 287, 787);
    cb.addTemplate(template, 187, 487);
    cb.addTemplate(template, 487, 287);
    cb.addTemplate(template, 87, 87);

    // we define the destinations
    PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
    PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
    PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
    PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
    PdfDestination d5 = new PdfDestination(PdfDestination.FIT);

    // we define the outlines
    PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
    PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
    new PdfOutline(out1, d3, "sub 2");
    new PdfOutline(out2, d4, "sub 2.1");
    new PdfOutline(out2, d5, "sub 2.2");

    // step 5: we close the document
    document.close();
}
项目:jasperreports    文件:JRPdfExporter.java   
Bookmark(Bookmark parent, PdfDestination destination, String title)
{
    this.pdfOutline = new PdfOutline(parent.pdfOutline, destination, title, false);
    this.level = parent.level + 1;
}
项目:jasperreports    文件:JRPdfExporter.java   
Bookmark(PdfOutline pdfOutline, int level)
{
    this.pdfOutline = pdfOutline;
    this.level = level;
}
项目:birt    文件:PDFPageDevice.java   
protected TOCHandler createTOCHandler( TOCNode root, PdfOutline outline,
        Set<String> bookmarks )
{
    return new TOCHandler( root, outline, bookmarks );
}
项目:PDFTestForAndroid    文件:OutlineActions.java   
/**
 * Demonstrates some PageLabel functionality.
 * 
 * @param args
 *            no arguments needed here
 */
public static void main(String[] args) {

    System.out.println("Outlines with actions");

    // step 1: creation of a document-object
    Document document = new Document();
    Document remote = new Document();
    try {
        // step 2:
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "OutlineActions.pdf"));
        PdfWriter.getInstance(remote, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "remote.pdf"));
        // step 3:
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        document.open();
        remote.open();
        // step 4:
        // we add some content
        document.add(new Paragraph("Outline action example"));
        // we add the outline
        PdfContentByte cb = writer.getDirectContent();
        PdfOutline root = cb.getRootOutline();
        PdfOutline links = new PdfOutline(root, new PdfAction("http://www.lowagie.com/iText/links.html"),
                "Useful links");
        links.setColor(new Color(0x00, 0x80, 0x80));
        links.setStyle(Font.BOLD);
        new PdfOutline(links, new PdfAction("http://www.lowagie.com/iText"), "Bruno's iText site");
        new PdfOutline(links, new PdfAction("http://itextpdf.sourceforge.net/"), "Paulo's iText site");
        new PdfOutline(links, new PdfAction("http://sourceforge.net/projects/itext/"), "iText @ SourceForge");
        PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false);
        other.setStyle(Font.ITALIC);
        new PdfOutline(other, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
        new PdfOutline(other, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");
        new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");

        remote.add(new Paragraph("Some remote document"));
        remote.newPage();
        Paragraph p = new Paragraph("This paragraph contains a ");
        p.add(new Chunk("local destination").setLocalDestination("test"));
        remote.add(p);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
    remote.close();
}
项目:PDFTestForAndroid    文件:Destinations.java   
/**
 * Creates a document with some goto actions.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {

    System.out.println("Destinations");

    // step 1: creation of a document-object
    Document document = new Document();
    try {

        // step 2:
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "Destinations.pdf"));
        // step 3:
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        document.open();
        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        // we create a PdfTemplate
        PdfTemplate template = cb.createTemplate(25, 25);

        // we add some crosses to visualize the destinations
        template.moveTo(13, 0);
        template.lineTo(13, 25);
        template.moveTo(0, 13);
        template.lineTo(50, 13);
        template.stroke();

        // we add the template on different positions
        cb.addTemplate(template, 287, 787);
        cb.addTemplate(template, 187, 487);
        cb.addTemplate(template, 487, 287);
        cb.addTemplate(template, 87, 87);

        // we define the destinations
        PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
        PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
        PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
        PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
        PdfDestination d5 = new PdfDestination(PdfDestination.FIT);

        // we define the outlines
        PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
        PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
        new PdfOutline(out1, d3, "sub 2");
        new PdfOutline(out2, d4, "sub 2.1");
        new PdfOutline(out2, d5, "sub 2.2");
    } catch (Exception de) {
        de.printStackTrace();
    }

    // step 5: we close the document
    document.close();
}
项目:itext2    文件:BookmarksTest.java   
/**
 * Adds an outline for every new Paragraph
 * 
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
    new PdfOutline(cb.getRootOutline(), destination, "paragraph " + n);
}
项目:PDFTestForAndroid    文件:Bookmarks.java   
/**
 * Adds an outline for every new Paragraph
 * 
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
    new PdfOutline(cb.getRootOutline(), destination, "paragraph " + n);
}
项目:PDFTestForAndroid    文件:Bookmarks.java   
/**
 * Adds an outline for every new Paragraph
 * 
 * @param writer
 * @param document
 * @param position
 */
public void onParagraph(PdfWriter writer, Document document, float position) {
    n++;
    PdfContentByte cb = writer.getDirectContent();
    PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
    new PdfOutline(cb.getRootOutline(), destination, "paragraph " + n);
}