Interface PdfPageEvent
- All Known Implementing Classes:
FieldPositioningEvents, IndexEvents, PdfPageEventForwarder, PdfPageEventHelper
Note: do not use Document.add() inside a page event.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when a Chapter is written.voidonChapterEnd(PdfWriter writer, Document document, float paragraphPosition) Called when the end of a Chapter is reached.voidonCloseDocument(PdfWriter writer, Document document) Called when the document is closed.voidCalled when a page is finished, just before being written to the document.voidonGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) Called when aChunkwith a generic tag is written.voidonOpenDocument(PdfWriter writer, Document document) Called when the document is opened.voidonParagraph(PdfWriter writer, Document document, float paragraphPosition) Called when a Paragraph is written.voidonParagraphEnd(PdfWriter writer, Document document, float paragraphPosition) Called when a Paragraph is written.voidCalled when a Section is written.voidonSectionEnd(PdfWriter writer, Document document, float paragraphPosition) Called when the end of a Section is reached.voidonStartPage(PdfWriter writer, Document document) Called when a page is initialized.
-
Method Details
-
onOpenDocument
-
onStartPage
Called when a page is initialized.Note that if even if a page is not written this method is still called. It is preferable to use
onEndPageto avoid infinite loops.Note that this method isn't called for the first page. You should apply modifications for the first page either before opening the document or by using the onOpenDocument() method.
- Parameters:
writer- thePdfWriterfor this documentdocument- the document
-
onEndPage
-
onCloseDocument
-
onParagraph
Called when a Paragraph is written.paragraphPositionwill hold the height at which the paragraph will be written to. This is useful to insert bookmarks with more control.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the paragraph will be written to
-
onParagraphEnd
Called when a Paragraph is written.paragraphPositionwill hold the height of the end of the paragraph.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position of the end of the paragraph
-
onChapter
Called when a Chapter is written.positionwill hold the height at which the chapter will be written to.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the chapter will be written totitle- the title of the Chapter
-
onChapterEnd
Called when the end of a Chapter is reached.positionwill hold the height of the end of the chapter.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the chapter will be written to
-
onSection
void onSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title) Called when a Section is written.positionwill hold the height at which the section will be written to.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the section will be written todepth- the number depth of the sectiontitle- the title of the section
-
onSectionEnd
Called when the end of a Section is reached.positionwill hold the height of the section end.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the section will be written to
-
onGenericTag
Called when aChunkwith a generic tag is written.It is useful to pinpoint the
Chunklocation to generate bookmarks, for example.- Parameters:
writer- thePdfWriterfor this documentdocument- the documentrect- theRectanglecontaining theChunktext- the text of the tag
-