use of com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method cleanUpPageTest.
@Test
public void cleanUpPageTest() throws IOException, InterruptedException {
String input = INPUT_PATH + "Lipsum.pdf";
String output = OUTPUT_PATH + "cleanUpPage.pdf";
String cmp = INPUT_PATH + "cmp_cleanUpPage.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("(D|d)olor").setRedactionColor(ColorConstants.GREEN));
PdfWriter writer = new PdfWriter(output);
writer.setCompressionLevel(0);
PdfDocument pdf = new PdfDocument(new PdfReader(input), writer);
// sweep
PdfCleaner.autoSweepCleanUp(pdf.getPage(1), strategy);
pdf.close();
// compare
compareByContent(cmp, output, OUTPUT_PATH, "diff_cleanUpPage_");
}
use of com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method lineArtsDrawingOnCanvasTest.
@Test
@Ignore("DEVSIX-4047")
public void lineArtsDrawingOnCanvasTest() throws IOException, InterruptedException {
String input = INPUT_PATH + "lineArtsDrawingOnCanvas.pdf";
String output = OUTPUT_PATH + "lineArtsDrawingOnCanvas.pdf";
String cmp = INPUT_PATH + "cmp_lineArtsDrawingOnCanvas.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("(iphone)|(iPhone)"));
PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));
PdfCleaner.autoSweepCleanUp(pdf, strategy);
pdf.close();
compareByContent(cmp, output, OUTPUT_PATH, "diff_lineArtsDrawingOnCanvasTest_");
}
use of com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method autoCleanWithFalseProcessAnnotationTest.
@Test
public void autoCleanWithFalseProcessAnnotationTest() throws Exception {
String input = INPUT_PATH + "absentICentry.pdf";
String output = OUTPUT_PATH + "autoCleanWithFalseProcessAnnotationTest.pdf";
String cmp = INPUT_PATH + "cmp_autoCleanWithFalseProcessAnnotationTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
List<PdfCleanUpLocation> additionalLocation = new ArrayList<>();
additionalLocation.add(new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30)));
CleanUpProperties properties = new CleanUpProperties();
properties.setProcessAnnotations(false);
PdfCleaner.autoSweepCleanUp(new FileInputStream(input), new FileOutputStream(output), strategy, additionalLocation, properties);
compareByContent(cmp, output, OUTPUT_PATH, "autoCleanWithFalseProcessAnnotationTest");
}
Aggregations