Search in sources :

Example 1 with CompareTool

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

the class HighLevelWrapperC01E02Cardo2Test method comparePdf.

@Override
protected void comparePdf(String outPath, String dest, String cmp) throws Exception {
    for (int i = 0; i < 3; i++) {
        String currentDest = String.format(dest, ++i);
        String currentOutPath = String.format(outPath, ++i);
        String currentCmp = String.format(cmp, ++i);
        CompareTool compareTool = new CompareTool();
        addError(compareTool.compareByContent(currentDest, currentCmp, currentOutPath, "diff_"));
        addError(compareTool.compareDocumentInfo(currentDest, currentCmp));
    }
}
Also used : CompareTool(com.itextpdf.kernel.utils.CompareTool)

Example 2 with CompareTool

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

the class PdfAutoSweepToolsTest 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 3 with CompareTool

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

the class CustomLocationExtractionStrategy method cleanUpAreaCalculationPrecisionTest.

@Test
public void cleanUpAreaCalculationPrecisionTest() throws IOException, InterruptedException {
    String input = inputPath + "cleanUpAreaCalculationPrecision.pdf";
    String output = outputPath + "cleanUpAreaCalculationPrecision.pdf";
    String cmp = inputPath + "cmp_cleanUpAreaCalculationPrecision.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
    CompareTool compareTool = new CompareTool();
    String errorMessage = compareTool.compareByContent(output, cmp, outputPath);
    Assert.assertNull(errorMessage);
}
Also used : PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) CompareTool(com.itextpdf.kernel.utils.CompareTool) 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 4 with CompareTool

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

the class CleanUpTaggedPdfTest 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 5 with CompareTool

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

the class PdfCleanUpToolTest method autoSweepCleanUpWithAdditionalLocationTest.

@Test
public void autoSweepCleanUpWithAdditionalLocationTest() throws Exception {
    String in = INPUT_PATH + "page229.pdf";
    String out = OUTPUT_PATH + "autoSweepCleanUpWithAdditionalLocationTest.pdf";
    String cmp = INPUT_PATH + "cmp_autoSweepCleanUpWithAdditionalLocationTest.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<>();
    cleanUpLocations.add(new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30)));
    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new RegexBasedCleanupStrategy(" (T|t)o ").setRedactionColor(ColorConstants.GREEN));
    try (PdfReader reader = new PdfReader(in);
        PdfWriter writer = new PdfWriter(out);
        PdfDocument document = new PdfDocument(reader, writer)) {
        PdfCleaner.autoSweepCleanUp(document, strategy, cleanUpLocations);
    }
    CompareTool cmpTool = new CompareTool();
    String errorMessage = cmpTool.compareVisually(out, cmp, OUTPUT_PATH, "diff_autoSweepCleanUpWithAdditionalLocationTest_");
    if (errorMessage != null) {
        Assert.fail(errorMessage);
    }
}
Also used : RegexBasedCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) 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