How to check for an event and remove it?
Posted on StackOverflow on Apr 15, 2014 by IyaTaisho
There is an IEventHandler
interface in iText 7. You should add it’s implementation (say, MyEventHandler
) to the PdfDocument
instance like this:
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
MyEventHandler handler = new MyEventHandler();
pdfDoc.addEventHandler(PdfDocumentEvent.END_PAGE, handler);
You can check if the document has any type of event (PdfDocumentEvent.START_PAGE
, PdfDocumentEvent.INSERT_PAGE
, PdfDocumentEvent.REMOVE_PAGE
, PdfDocumentEvent.END_PAGE
) using hasEventHandler(String type)
method.
To remove an existing page event, you need removeEventHandler(String type, IEventHandler handler)
method. If you want to delete all page events, feel free to invoke removeAllHandlers()
.
Click How to check for an event and remove it? if you want to see how to answer this question in iText 5.