use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class CleanUpTextTest method cleanZeroWidthTextInvalidFont.
@Test
@LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.FONT_DICTIONARY_WITH_NO_FONT_DESCRIPTOR), @LogMessage(messageTemplate = IoLogMessageConstant.FONT_DICTIONARY_WITH_NO_WIDTHS) })
public void cleanZeroWidthTextInvalidFont() throws IOException, InterruptedException {
String input = inputPath + "cleanZeroWidthTextInvalidFont.pdf";
String output = outputPath + "cleanZeroWidthTextInvalidFont.pdf";
String cmp = inputPath + "cmp_cleanZeroWidthTextInvalidFont.pdf";
cleanUp(input, output, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(50, 50, 500, 500))));
compareByContent(cmp, output, outputPath);
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class MaskedImagesTest method imageTransparencyTextOnTransparentField.
@Test
public void imageTransparencyTextOnTransparentField() throws IOException, InterruptedException {
String fileName = "textOnTransparentField";
String input = inputPath + fileName + ".pdf";
String output = outputPath + fileName + "_cleaned.pdf";
String cmp = inputPath + "cmp_" + fileName + ".pdf";
List<PdfCleanUpLocation> cleanUpLocations = Collections.singletonList(new PdfCleanUpLocation(1, new Rectangle(280, 360, 200, 75)));
PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
PdfCleaner.cleanUp(pdfDocument, cleanUpLocations);
new PdfCanvas(pdfDocument.getFirstPage().newContentStreamBefore(), pdfDocument.getFirstPage().getResources(), pdfDocument).setColor(ColorConstants.LIGHT_GRAY, true).rectangle(0, 0, 1000, 1000).fill().setColor(ColorConstants.BLACK, true);
pdfDocument.close();
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class MaskedImagesTest method runTest.
private static void runTest(String fileName, String fuzzValue) throws IOException, InterruptedException {
String input = inputPath + fileName + ".pdf";
String output = outputPath + fileName + "_cleaned.pdf";
String cmp = inputPath + "cmp_" + fileName + ".pdf";
List<PdfCleanUpLocation> cleanUpLocations = Collections.singletonList(new PdfCleanUpLocation(1, new Rectangle(308, 520, 200, 75)));
PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
PdfCleaner.cleanUp(pdfDocument, cleanUpLocations);
pdfDocument.close();
CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
String errorMessage = cmpTool.extractAndCompareImages(output, cmp, outputPath, fuzzValue);
String compareByContentResult = cmpTool.compareByContent(output, cmp, outputPath);
if (compareByContentResult != null) {
errorMessage += compareByContentResult;
}
if (!errorMessage.equals("")) {
Assert.fail(errorMessage);
}
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class PdfCleanUpToolTest method cleanUpTest13.
@Test
public void cleanUpTest13() throws IOException, InterruptedException {
String input = INPUT_PATH + "maskImage.pdf";
String output = OUTPUT_PATH + "maskImage.pdf";
String cmp = INPUT_PATH + "cmp_maskImage.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_13");
}
use of com.itextpdf.kernel.geom.Rectangle 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");
}
Aggregations