Search in sources :

Example 11 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7j-pdfsweep by itext.

the class CleanUpImageIndexedColorSpaceTest method noWhiteColorTest.

@Test
public void noWhiteColorTest() throws Exception {
    String input = inputPath + "indexedImageNoWhite.pdf";
    String output = outputPath + "indexedImageNoWhite.pdf";
    String cmp = inputPath + "cmp_indexedImageNoWhite.pdf";
    try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output))) {
        PdfCleaner.cleanUp(pdfDocument, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(150, 250, 100, 100))));
    }
    /*
          Result in Java and .NET is different.

          Java is able to process images with indexed colorspace same as others and
          doesn't preserve indexed colorspace. .NET requires special processing for
          indexed colorspace images, but preserves indexed colorspace.

          In .NET color of cleaned area is the first color of indexed color palette.
          In Java color of cleaned area is white.
         */
    Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfCleanUpLocation(com.itextpdf.pdfcleanup.PdfCleanUpLocation) Rectangle(com.itextpdf.kernel.geom.Rectangle) CompareTool(com.itextpdf.kernel.utils.CompareTool) 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 12 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7j-pdfsweep by itext.

the class CleanUpTextTest method compareByContent.

private void compareByContent(String cmp, String output, String targetDir) throws IOException, InterruptedException {
    CompareTool cmpTool = new CompareTool();
    String errorMessage = cmpTool.compareByContent(output, cmp, targetDir);
    if (errorMessage != null) {
        Assert.fail(errorMessage);
    }
}
Also used : CompareTool(com.itextpdf.kernel.utils.CompareTool)

Example 13 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7j-pdfsweep by itext.

the class CleanUpAnnotationTest method compareByContent.

private void compareByContent(String cmp, String output, String targetDir, String diffPrefix) throws IOException, InterruptedException {
    CompareTool cmpTool = new CompareTool();
    String errorMessage = cmpTool.compareByContent(output, cmp, targetDir, diffPrefix + "_");
    if (errorMessage != null) {
        Assert.fail(errorMessage);
    }
}
Also used : CompareTool(com.itextpdf.kernel.utils.CompareTool)

Example 14 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method cleanUpTestFontColor.

@Test
public void cleanUpTestFontColor() throws IOException, InterruptedException {
    String filename = "fontCleanup.pdf";
    PdfDocument pdfDoc = new PdfDocument(new PdfReader(INPUT_PATH + filename), new PdfWriter(OUTPUT_PATH + filename));
    PdfCleaner.cleanUpRedactAnnotations(pdfDoc);
    pdfDoc.close();
    Assert.assertNull(new CompareTool().compareVisually(OUTPUT_PATH + filename, INPUT_PATH + "cmp_" + filename, OUTPUT_PATH, "diff_"));
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompareTool(com.itextpdf.kernel.utils.CompareTool) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfString(com.itextpdf.kernel.pdf.PdfString) 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)

Aggregations

CompareTool (com.itextpdf.kernel.utils.CompareTool)14 CleanUpImagesCompareTool (com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)6 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)5 PdfReader (com.itextpdf.kernel.pdf.PdfReader)5 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)5 ExtendedITextTest (com.itextpdf.test.ExtendedITextTest)5 IntegrationTest (com.itextpdf.test.annotations.type.IntegrationTest)5 Test (org.junit.Test)5 Rectangle (com.itextpdf.kernel.geom.Rectangle)3 PdfString (com.itextpdf.kernel.pdf.PdfString)3 PdfCleanUpLocation (com.itextpdf.pdfcleanup.PdfCleanUpLocation)2 CompositeCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy)2 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)1 RegexBasedCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy)1 ArrayList (java.util.ArrayList)1