Skip to content

Commit 54e4d0f

Browse files
committed
Support event meta info
DEVSIX-1958
1 parent 0554653 commit 54e4d0f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/com/itextpdf/pdfcleanup/PdfCleanUpTool.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ This file is part of the iText (R) project.
5252
import com.itextpdf.kernel.colors.DeviceGray;
5353
import com.itextpdf.kernel.colors.DeviceRgb;
5454
import com.itextpdf.kernel.counter.EventCounterHandler;
55+
import com.itextpdf.kernel.counter.event.IMetaInfo;
5556
import com.itextpdf.kernel.font.PdfFont;
5657
import com.itextpdf.kernel.font.PdfFontFactory;
5758
import 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

Comments
 (0)