PdfEvents: on generic tags, on chapter : Document Page Event « PDF RTF « Java






PdfEvents: on generic tags, on chapter

PdfEvents: on generic tags, on chapter
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfWriter;

public class PdfEvents {
  public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 80, 50, 30, 65);
    try {
      
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfEvents.pdf"));
      document.open();
      writer.setPageEvent(new MyPageEvents());
      document.newPage();
      document.add(new Paragraph("Text"));
      document.close();
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
}
class MyPageEvents extends PdfPageEventHelper {
  
  public void onGenericTag(PdfWriter writer, Document document,  Rectangle rect, String text) {
    System.out.println("onGenericTag");
    
  }
  public void onOpenDocument(PdfWriter writer, Document document) {
    System.out.println("onOpenDocument");
  }

  public void onChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title) {
    System.out.println("onChapter");
  }
  public void onEndPage(PdfWriter writer, Document document) {
    System.out.println("onEndPage");
  }

  public void onCloseDocument(PdfWriter writer, Document document) {
    System.out.println("onCloseDocument");
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Using Pdf event to build the Pdf documentUsing Pdf event to build the Pdf document
2.PdfPageEvent: page endPdfPageEvent: page end
3.PdfPageEvent: on ParagraphPdfPageEvent: on Paragraph
4.Document Page Event: document open, close, page start and endDocument Page Event: document open, close, page start and end