Named Actions in PDF Document : PDF Action « PDF RTF « Java






Named Actions in PDF Document

Named Actions in PDF Document
import java.io.FileOutputStream;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfWriter;


public class NamedActionsPDF {
  public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {
      PdfWriter writer = PdfWriter.getInstance(document,  new FileOutputStream("NamedActionsPDF.pdf"));
      document.open();
      Paragraph p = new Paragraph(new Chunk("Click to print").setAction(new PdfAction(PdfAction.PRINTDIALOG)));

      
      p.add(new Phrase(new Chunk("First Page").setAction(new PdfAction(PdfAction.FIRSTPAGE))));
      p.add(new Phrase(new Chunk("Prev Page").setAction(new PdfAction(PdfAction.PREVPAGE))));
      p.add(new Phrase(new Chunk("Next Page").setAction(new PdfAction(PdfAction.NEXTPAGE))));
      p.add(new Phrase(new Chunk("Last Page").setAction(new PdfAction(PdfAction.LASTPAGE))));
      
      for (int i = 1; i <= 10; ++i) {
        document.add(new Paragraph("This is page " + i));
        document.add(new Paragraph(Chunk.NEWPAGE));
        document.add(p);
        document.newPage();
      }
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.PdfAction: Goto Another Pdf FilePdfAction: Goto Another Pdf File
2.PdfAction: Goto Local Page 1PdfAction: Goto Local Page 1
3.PdfAction: Goto Local Page 2PdfAction: Goto Local Page 2
4.Pdf action: open application (notepad.exe)Pdf action: open application (notepad.exe)
5.Pdf action: jump locallyPdf action: jump locally
6.Chained ActionsChained Actions