use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method cleanUpTest36.
/**
* In this test, glyph "1" got removed by the clean up area that on first sight is not covering the glyph.
* However, we can't get the particular glyphs height and instead we have the same height for all glyphs.
* Because of this, in case of the big font sizes such situations might occur, that even though visually glyph is
* rather away from the cleanup location we still get it removed because it's bbox intersects with cleanup area rectangle.
*
* @throws IOException
* @throws InterruptedException
*/
@Test
public void cleanUpTest36() throws IOException, InterruptedException {
String input = INPUT_PATH + "bigOne.pdf";
String output = OUTPUT_PATH + "bigOne.pdf";
String cmp = INPUT_PATH + "cmp_bigOne.pdf";
cleanUp(input, output, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(300f, 370f, 215f, 270f), ColorConstants.GRAY)));
compareByContent(cmp, output, OUTPUT_PATH, "diff_36");
}
use of com.itextpdf.kernel.geom.Rectangle 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.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method documentInNonStampingModeTest.
@Test
public void documentInNonStampingModeTest() throws IOException {
PdfDocument pdfDocument = new PdfDocument(new PdfReader(INPUT_PATH + "fontCleanup.pdf"));
List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 500, 500)));
Exception e = Assert.assertThrows(PdfException.class, () -> PdfCleaner.cleanUp(pdfDocument, cleanUpLocations));
Assert.assertEquals(CleanupExceptionMessageConstant.PDF_DOCUMENT_MUST_BE_OPENED_IN_STAMPING_MODE, e.getMessage());
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method cleanUpTest27.
@Test
public void cleanUpTest27() throws IOException, InterruptedException {
String input = INPUT_PATH + "clipPathReduction.pdf";
String output = OUTPUT_PATH + "clipPathReduction.pdf";
String cmp = INPUT_PATH + "cmp_clipPathReduction.pdf";
List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(212, 394, 186, 170), null));
cleanUp(input, output, cleanUpLocations);
compareByContent(cmp, output, OUTPUT_PATH, "diff_27");
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method cleanUpTest10.
@Test
public void cleanUpTest10() throws IOException, InterruptedException {
String input = INPUT_PATH + "simpleImmediate-tm.pdf";
String output = OUTPUT_PATH + "simpleImmediate-tm.pdf";
String cmp = INPUT_PATH + "cmp_simpleImmediate-tm.pdf";
List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(97f, 405f, 480f - 97f, 445f - 405f), ColorConstants.GRAY));
cleanUp(input, output, cleanUpLocations);
compareByContent(cmp, output, OUTPUT_PATH, "diff_10");
}
Aggregations