Example usage for java.util List add

List of usage examples for java.util List add

Introduction

In this page you can find the example usage for java.util List add.

Prototype

void add(int index, E element);

Source Link

Document

Inserts the specified element at the specified position in this list (optional operation).

Usage

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("test.pdf");
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my.pdf"));
    stamper.insertPage(1, PageSize.A4);//from   w w w.j  ava  2  s.co  m
    PdfContentByte cb = stamper.getOverContent(1);
    PdfImportedPage p = stamper.getImportedPage(reader, 2);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 450);
    p = stamper.getImportedPage(reader, 3);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 300f, 450);
    p = stamper.getImportedPage(reader, 4);
    cb.addTemplate(p, 0.4f, 0f, 0f, 0.4f, 36f, 100);
    stamper.addAnnotation(PdfAnnotation.createText(stamper.getWriter(), new Rectangle(300f, 350f, 500f, 450f),
            "inserted page", "This page contains a copy of the next three pages.", true, null), 1);
    List list = SimpleBookmark.getBookmark(reader);
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("Title", "title content");
    map.put("Action", "GoTo");
    map.put("Page", "1 FitH 806");
    list.add(0, map);
    stamper.setOutlines(list);
    stamper.close();
}