Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

Is there a way to check to see if a page event has already been added to a PdfWriter object? If so, can you also remove that page event?

Posted on StackOverflow on Apr 15, 2014 by IyaTaisho

In the Java version of iText, there's a method getPageEvent() available in PdfWriter. There should be a GetPageEvent() or PageEvent in iTextSharp that you can use to find out if there is a page event present.

To remove an existing page event, you need to set the page event to null. Adding an extra page event won't replace the existing page event, but add an extra event that will be triggered along with the original event(s).