- java.lang.Object
-
- com.itextpdf.text.pdf.events.PdfPageEventForwarder
-
- All Implemented Interfaces:
PdfPageEvent
public class PdfPageEventForwarder extends java.lang.Object implements PdfPageEvent
If you want to add more than one page event to a PdfWriter, you have to construct a PdfPageEventForwarder, add the different events to this object and add the forwarder to the PdfWriter.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayListeventsArrayList containing all the PageEvents that have to be executed.
-
Constructor Summary
Constructors Constructor Description PdfPageEventForwarder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPageEvent(PdfPageEvent event)Add a page event to the forwarder.voidonChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title)Called when a Chapter is written.voidonChapterEnd(PdfWriter writer, Document document, float position)Called when the end of a Chapter is reached.voidonCloseDocument(PdfWriter writer, Document document)Called when the document is closed.voidonEndPage(PdfWriter writer, Document document)Called when a page is finished, just before being written to the document.voidonGenericTag(PdfWriter writer, Document document, Rectangle rect, java.lang.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.voidonSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title)Called when a Section is written.voidonSectionEnd(PdfWriter writer, Document document, float position)Called when the end of a Section is reached.voidonStartPage(PdfWriter writer, Document document)Called when a page is initialized.
-
-
-
Method Detail
-
addPageEvent
public void addPageEvent(PdfPageEvent event)
Add a page event to the forwarder.- Parameters:
event- an event that has to be added to the forwarder.
-
onOpenDocument
public void onOpenDocument(PdfWriter writer, Document document)
Called when the document is opened.- Specified by:
onOpenDocumentin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the document
-
onStartPage
public void onStartPage(PdfWriter writer, Document document)
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.- Specified by:
onStartPagein interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the document
-
onEndPage
public void onEndPage(PdfWriter writer, Document document)
Called when a page is finished, just before being written to the document.- Specified by:
onEndPagein interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the document
-
onCloseDocument
public void onCloseDocument(PdfWriter writer, Document document)
Called when the document is closed.Note that this method is called with the page number equal to the last page plus one.
- Specified by:
onCloseDocumentin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the document
-
onParagraph
public void onParagraph(PdfWriter writer, Document document, float paragraphPosition)
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.- Specified by:
onParagraphin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the paragraph will be written to
-
onParagraphEnd
public void onParagraphEnd(PdfWriter writer, Document document, float paragraphPosition)
Called when a Paragraph is written.paragraphPositionwill hold the height of the end of the paragraph.- Specified by:
onParagraphEndin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position of the end of the paragraph
-
onChapter
public void onChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title)
Called when a Chapter is written.positionwill hold the height at which the chapter will be written to.- Specified by:
onChapterin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentparagraphPosition- the position the chapter will be written totitle- the title of the Chapter
-
onChapterEnd
public void onChapterEnd(PdfWriter writer, Document document, float position)
Called when the end of a Chapter is reached.positionwill hold the height of the end of the chapter.- Specified by:
onChapterEndin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentposition- the position of the end of the chapter.
-
onSection
public 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.- Specified by:
onSectionin interfacePdfPageEvent- 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
public void onSectionEnd(PdfWriter writer, Document document, float position)
Called when the end of a Section is reached.positionwill hold the height of the section end.- Specified by:
onSectionEndin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentposition- the position of the end of the section
-
onGenericTag
public void onGenericTag(PdfWriter writer, Document document, Rectangle rect, java.lang.String text)
Called when aChunkwith a generic tag is written.It is useful to pinpoint the
Chunklocation to generate bookmarks, for example.- Specified by:
onGenericTagin interfacePdfPageEvent- Parameters:
writer- thePdfWriterfor this documentdocument- the documentrect- theRectanglecontaining theChunktext- the text of the tag
-
-