PdfPageEvent: on Paragraph : Document Page Event « PDF RTF « Java






PdfPageEvent: on Paragraph

PdfPageEvent: on Paragraph
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDestination;
import com.lowagie.text.pdf.PdfOutline;
import com.lowagie.text.pdf.PdfPageEventHelper;
import com.lowagie.text.pdf.PdfWriter;

public class OnParagraphEventPDF extends PdfPageEventHelper {
    public void onParagraph(PdfWriter writer, Document document, float position) {
      System.out.println("onParagraph");
    }

  public static void main(String[] args) {
    Document document = new Document(PageSize.A6);
    try {
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OnParagraphEventPDF.pdf"));
      writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
      document.open();
      writer.setPageEvent(new OnParagraphEventPDF());
            
      document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12)));
      document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12)));
      document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12)));
      document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12)));
      document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12)));
    } catch (Exception de) {
      de.printStackTrace();
    }
    document.close();
  }
}
           
       








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.PdfEvents: on generic tags, on chapterPdfEvents: on generic tags, on chapter
3.PdfPageEvent: page endPdfPageEvent: page end
4.Document Page Event: document open, close, page start and endDocument Page Event: document open, close, page start and end