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));
}
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations