Search in sources :

Example 6 with LogMessages

use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.

the class PdfCleanUpToolWithInlineImagesTest method cleanUpTest31.

@Test
@LogMessages(messages = { @LogMessage(messageTemplate = IoLogMessageConstant.IMAGE_SIZE_CANNOT_BE_MORE_4KB) })
public void cleanUpTest31() throws IOException, InterruptedException {
    String input = inputPath + "inlineImageCleanup.pdf";
    String output = outputPath + "inlineImageCleanup.pdf";
    String cmp = inputPath + "cmp_inlineImageCleanup.pdf";
    cleanUp(input, output, null);
    CleanUpImagesCompareTool cmpTool = new CleanUpImagesCompareTool();
    String errorMessage = cmpTool.extractAndCompareImages(output, cmp, outputPath, "1");
    String compareByContentResult = cmpTool.compareByContent(output, cmp, outputPath);
    if (compareByContentResult != null) {
        errorMessage += compareByContentResult;
    }
    if (!errorMessage.equals("")) {
        Assert.fail(errorMessage);
    }
}
Also used : CleanUpImagesCompareTool(com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 7 with LogMessages

use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method pathAndIncorrectCMTest.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX, count = 7))
public void pathAndIncorrectCMTest() throws IOException, InterruptedException {
    String fileName = "pathAndIncorrectCM";
    String input = INPUT_PATH + "pathAndIncorrectCM.pdf";
    String output = OUTPUT_PATH + fileName + ".pdf";
    String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
    List<PdfCleanUpLocation> dummyLocationsList = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        dummyLocationsList.add(new PdfCleanUpLocation(i + 1, new Rectangle(0, 0, 0, 0), null));
    }
    cleanUp(input, output, dummyLocationsList);
    compareByContent(cmp, output, OUTPUT_PATH, "diff_pathAndIncorrectCMTest");
}
Also used : ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) PdfString(com.itextpdf.kernel.pdf.PdfString) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 8 with LogMessages

use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method redactPdfWithNoninvertibleMatrix.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX, count = 2))
public void redactPdfWithNoninvertibleMatrix() throws IOException, InterruptedException {
    String input = INPUT_PATH + "noninvertibleMatrix.pdf";
    String output = OUTPUT_PATH + "redactPdfWithNoninvertibleMatrix.pdf";
    String cmp = INPUT_PATH + "cmp_redactPdfWithNoninvertibleMatrix.pdf";
    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new RegexBasedCleanupStrategy("Hello World!").setRedactionColor(ColorConstants.GREEN));
    PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output));
    // sweep
    PdfCleaner.autoSweepCleanUp(pdf, strategy);
    pdf.close();
    // compare
    compareByContent(cmp, output, OUTPUT_PATH, "diff_redactPdfWithNoninvertibleMatrix_");
}
Also used : RegexBasedCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) 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) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 9 with LogMessages

use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method noninvertibleMatrixRemoveAllTest02.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.FAILED_TO_PROCESS_A_TRANSFORMATION_MATRIX))
public void noninvertibleMatrixRemoveAllTest02() throws IOException, InterruptedException {
    String fileName = "noninvertibleMatrixRemoveAllTest02";
    String input = INPUT_PATH + "noninvertibleMatrix.pdf";
    String output = OUTPUT_PATH + fileName + ".pdf";
    String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
    PdfCleanUpLocation wholePageLocation = new PdfCleanUpLocation(1, new Rectangle(-1000, -1000, 2000, 2000), null);
    cleanUp(input, output, Arrays.asList(wholePageLocation));
    compareByContent(cmp, output, OUTPUT_PATH, "diff_noninvertibleMatrixRemoveAllTest");
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) PdfString(com.itextpdf.kernel.pdf.PdfString) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 10 with LogMessages

use of com.itextpdf.test.annotations.LogMessages in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method noPropertiesInResourcesTest.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY))
public void noPropertiesInResourcesTest() throws IOException, InterruptedException {
    String fileName = "noPropertiesInResourcesTest";
    String input = INPUT_PATH + fileName + ".pdf";
    String output = OUTPUT_PATH + fileName + ".pdf";
    String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
    List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 595, 842), ColorConstants.RED));
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, OUTPUT_PATH, "diff_" + fileName);
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) PdfString(com.itextpdf.kernel.pdf.PdfString) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Aggregations

ExtendedITextTest (com.itextpdf.test.ExtendedITextTest)12 LogMessages (com.itextpdf.test.annotations.LogMessages)12 IntegrationTest (com.itextpdf.test.annotations.type.IntegrationTest)12 Test (org.junit.Test)12 Rectangle (com.itextpdf.kernel.geom.Rectangle)9 PdfString (com.itextpdf.kernel.pdf.PdfString)7 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)1 PdfNumber (com.itextpdf.kernel.pdf.PdfNumber)1 PdfReader (com.itextpdf.kernel.pdf.PdfReader)1 PdfStream (com.itextpdf.kernel.pdf.PdfStream)1 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)1 PdfImageXObject (com.itextpdf.kernel.pdf.xobject.PdfImageXObject)1 PdfCleanUpLocation (com.itextpdf.pdfcleanup.PdfCleanUpLocation)1 CompositeCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy)1 RegexBasedCleanupStrategy (com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy)1 CleanUpImagesCompareTool (com.itextpdf.pdfcleanup.util.CleanUpImagesCompareTool)1 ArrayList (java.util.ArrayList)1