Search in sources :

Example 6 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool 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));
}
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) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfCanvas(com.itextpdf.kernel.pdf.canvas.PdfCanvas) 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 7 with CompareTool

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

the class PdfCleanUpToolTest 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) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) PdfString(com.itextpdf.kernel.pdf.PdfString)

Example 8 with CompareTool

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

the class PdfCleanUpToolWithInlineImagesTest 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) CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)

Example 9 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7js-highlevel by itext.

the class HighLevelWrapperTest method comparePdf.

@Override
protected void comparePdf(String outPath, String dest, String cmp) throws Exception {
    CompareTool compareTool = new CompareTool();
    addError(compareTool.compareByContent(dest, cmp, outPath, "diff_"));
    addError(compareTool.compareDocumentInfo(dest, cmp));
}
Also used : CompareTool(com.itextpdf.kernel.utils.CompareTool)

Example 10 with CompareTool

use of com.itextpdf.kernel.utils.CompareTool in project i7js-highlevel by itext.

the class HighLevelWrapperWithEncryptionTest method comparePdf.

@Override
protected void comparePdf(String outPath, String dest, String cmp) throws Exception {
    CompareTool compareTool = new CompareTool();
    byte[] ownerPass = "abcdefg".getBytes();
    compareTool.enableEncryptionCompare();
    addError(compareTool.compareByContent(dest, cmp, outPath, "diff_", ownerPass, ownerPass));
    addError(compareTool.compareDocumentInfo(dest, cmp, ownerPass, ownerPass));
}
Also used : CompareTool(com.itextpdf.kernel.utils.CompareTool)

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