Search in sources :

Example 1 with CleanUpImagesCompareTool

use of com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool in project i7j-pdfsweep by itext.

the class FilteredImagesCacheTest method compareByContent.

private void compareByContent(String cmp, String output, String targetDir, String fuzzValue) throws IOException, InterruptedException {
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, targetDir, fuzzValue);
    String compareByContentResult = cmpTool.compareByContent(output, cmp, targetDir);
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)

Example 2 with CleanUpImagesCompareTool

use of com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool in project i7j-pdfsweep by itext.

the class CustomLocationExtractionStrategy method redactIPhoneUserManualMatchColor.

@Test
public void redactIPhoneUserManualMatchColor() throws IOException, InterruptedException {
    String input = inputPath + "iphone_user_guide_untagged.pdf";
    String output = outputPath + "redactIPhoneUserManualMatchColor.pdf";
    String cmp = inputPath + "cmp_redactIPhoneUserManualMatchColor.pdf";
    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new CustomLocationExtractionStrategy("(iphone)|(iPhone)"));
    PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));
    // sweep
    PdfCleaner.autoSweepCleanUp(pdf, strategy);
    pdf.close();
    // compare
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, outputPath, "4");
    // TODO DEVSIX-4047 Switch to compareByContent() when the ticket will be resolved
    String compareByContentResult = cmpTool.compareVisually(output, cmp, outputPath, "diff_redactIPhoneUserManualMatchColor_", cmpTool.getIgnoredImagesAreas());
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 3 with CleanUpImagesCompareTool

use of com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool in project i7j-pdfsweep by itext.

the class BigDocumentCleanUpTest method compareByContent.

private void compareByContent(String cmp, String output, String targetDir, String fuzzValue) throws IOException, InterruptedException {
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, targetDir, fuzzValue);
    String compareByContentResult = cmpTool.compareByContent(output, cmp, targetDir);
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)

Example 4 with CleanUpImagesCompareTool

use of com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method cleanUpTest39.

@Test
public void cleanUpTest39() throws IOException, InterruptedException {
    String input = INPUT_PATH + "corruptJpeg.pdf";
    String output = OUTPUT_PATH + "corruptJpeg.pdf";
    String cmp = INPUT_PATH + "cmp_corruptJpeg.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(100, 350, 100, 200), ColorConstants.ORANGE));
    cleanUp(input, output, cleanUpLocations);
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, OUTPUT_PATH, "1.2");
    String compareByContentResult = cmpTool.compareByContent(output, cmp, OUTPUT_PATH);
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfString(com.itextpdf.kernel.pdf.PdfString) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 5 with CleanUpImagesCompareTool

use of com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method cleanUpTest05.

@Test
public void cleanUpTest05() throws IOException, InterruptedException {
    String input = INPUT_PATH + "BigImage-jpg.pdf";
    String output = OUTPUT_PATH + "BigImage-jpg.pdf";
    String cmp = INPUT_PATH + "cmp_BigImage-jpg.pdf";
    cleanUp(input, output, null);
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, OUTPUT_PATH, "1");
    String compareByContentResult = cmpTool.compareByContent(output, cmp, OUTPUT_PATH);
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfString(com.itextpdf.kernel.pdf.PdfString) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Aggregations

CleanUpImagesCompareTool (com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)12 ExtendedITextTest (com.itextpdf.test.ExtendedITextTest)6 IntegrationTest (com.itextpdf.test.annotations.type.IntegrationTest)6 Test (org.junit.Test)6 Rectangle (com.itextpdf.kernel.geom.Rectangle)3 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)3 PdfReader (com.itextpdf.kernel.pdf.PdfReader)3 PdfString (com.itextpdf.kernel.pdf.PdfString)3 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)3 CompositeCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy)2 PdfCleanUpLocation (com.itextpdf.pdfcleanup.PdfCleanUpLocation)1 RegexBasedCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy)1 LogMessages (com.itextpdf.test.annotations.LogMessages)1