@@ -52,6 +52,7 @@ This file is part of the iText (R) project.
5252import com .itextpdf .kernel .colors .DeviceGray ;
5353import com .itextpdf .kernel .colors .DeviceRgb ;
5454import com .itextpdf .kernel .counter .EventCounterHandler ;
55+ import com .itextpdf .kernel .counter .event .IMetaInfo ;
5556import com .itextpdf .kernel .font .PdfFont ;
5657import com .itextpdf .kernel .font .PdfFontFactory ;
5758import com .itextpdf .kernel .geom .Rectangle ;
@@ -116,6 +117,8 @@ public class PdfCleanUpTool {
116117
117118 private boolean processAnnotations ;
118119
120+ private IMetaInfo cleanupMetaInfo ;
121+
119122 /**
120123 * Check if page annotations will be processed
121124 * Default: True
@@ -253,6 +256,18 @@ public PdfCleanUpTool addCleanupLocation(PdfCleanUpLocation cleanUpLocation) {
253256 return this ;
254257 }
255258
259+ /**
260+ * Sets the cleanup meta info that will be passed to the {@link com.itextpdf.kernel.counter.EventCounter}
261+ * with {@link PdfSweepEvent} and can be used to determine event origin.
262+ *
263+ * @param metaInfo the meta info to set.
264+ * @return this instance
265+ */
266+ public PdfCleanUpTool setEventCountingMetaInfo (IMetaInfo metaInfo ) {
267+ this .cleanupMetaInfo = metaInfo ;
268+ return this ;
269+ }
270+
256271 /**
257272 * Cleans the document by erasing all the areas which are either provided or
258273 * extracted from redaction annotations.
@@ -268,7 +283,7 @@ public void cleanUp() throws IOException {
268283 removeRedactAnnots ();
269284 }
270285 pdfCleanUpLocations .clear ();
271- EventCounterHandler .getInstance ().onEvent (PdfSweepEvent .CLEANUP , getClass ());
286+ EventCounterHandler .getInstance ().onEvent (PdfSweepEvent .CLEANUP , cleanupMetaInfo , getClass ());
272287 }
273288
274289 /**
0 commit comments