use of com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method autoCleanPageTest.
@Test
public void autoCleanPageTest() throws Exception {
String input = INPUT_PATH + "fontCleanup.pdf";
String output = OUTPUT_PATH + "autoCleanPageTest.pdf";
String cmp = INPUT_PATH + "cmp_autoCleanPageTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
try (PdfReader reader = new PdfReader(input);
PdfWriter writer = new PdfWriter(output);
PdfDocument document = new PdfDocument(reader, writer)) {
PdfCleaner.autoSweepCleanUp(document.getPage(1), strategy);
}
compareByContent(cmp, output, OUTPUT_PATH, "autoCleanPageTest");
}
use of com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method autoCleanWithLocationAndStreamParamsTest.
@Test
public void autoCleanWithLocationAndStreamParamsTest() throws Exception {
String input = INPUT_PATH + "fontCleanup.pdf";
String output = OUTPUT_PATH + "autoCleanWithLocationAndStreamParamsTest.pdf";
String cmp = INPUT_PATH + "cmp_autoCleanWithLocationAndStreamParamsTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
List<PdfCleanUpLocation> additionalLocation = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 200, 100)));
PdfCleaner.autoSweepCleanUp(new FileInputStream(input), new FileOutputStream(output), strategy, additionalLocation);
compareByContent(cmp, output, OUTPUT_PATH, "autoCleanWithLocationAndStreamParamsTest");
}
use of com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method redactLipsum.
@Test
public void redactLipsum() throws IOException, InterruptedException {
String input = INPUT_PATH + "Lipsum.pdf";
String output = OUTPUT_PATH + "cleanUpDocument.pdf";
String cmp = INPUT_PATH + "cmp_cleanUpDocument.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, strategy);
pdf.close();
// compare
compareByContent(cmp, output, OUTPUT_PATH, "diff_cleanUpDocument_");
}
use of com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method autoCleanPageWithAdditionalLocationTest.
@Test
public void autoCleanPageWithAdditionalLocationTest() throws Exception {
String input = INPUT_PATH + "fontCleanup.pdf";
String output = OUTPUT_PATH + "autoCleanPageWithAdditionalLocationTest.pdf";
String cmp = INPUT_PATH + "cmp_autoCleanPageWithAdditionalLocationTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
List<PdfCleanUpLocation> additionalLocation = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 200, 100), ColorConstants.RED));
try (PdfReader reader = new PdfReader(input);
PdfWriter writer = new PdfWriter(output);
PdfDocument document = new PdfDocument(reader, writer)) {
PdfCleaner.autoSweepCleanUp(document.getPage(1), strategy, additionalLocation);
}
compareByContent(cmp, output, OUTPUT_PATH, "autoCleanPageWithAdditionalLocationTest");
}
use of com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method autoCleanWithCleaUpPropertiesTest.
@Test
public void autoCleanWithCleaUpPropertiesTest() throws Exception {
String input = INPUT_PATH + "absentICentry.pdf";
String output = OUTPUT_PATH + "autoCleanWithCleaUpPropertiesTest.pdf";
String cmp = INPUT_PATH + "cmp_autoCleanWithCleaUpPropertiesTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
List<PdfCleanUpLocation> additionalLocation = new ArrayList<>();
additionalLocation.add(new PdfCleanUpLocation(1, new Rectangle(100, 100, 500, 500)));
PdfCleaner.autoSweepCleanUp(new FileInputStream(input), new FileOutputStream(output), strategy, additionalLocation, new CleanUpProperties());
compareByContent(cmp, output, OUTPUT_PATH, "autoCleanWithCleaUpPropertiesTest");
}
Aggregations