Search in sources :

Example 56 with Rectangle

use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method cleanUpTest37.

/**
 * In this test we check that line style operators (such as 'w') are processed correctly
 */
@Test
public void cleanUpTest37() throws IOException, InterruptedException {
    String input = INPUT_PATH + "helloHelvetica.pdf";
    String output = OUTPUT_PATH + "helloHelvetica.pdf";
    String cmp = INPUT_PATH + "cmp_helloHelvetica.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0f, 0f, 595f, 680f), ColorConstants.GRAY));
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, OUTPUT_PATH, "diff_37");
}
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)

Example 57 with Rectangle

use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method autoCleanWithCleaUpPropertiesTest.

@Test
public void autoCleanWithCleaUpPropertiesTest() throws Exception {
    String input = INPUT_PATH + "absentICentry.pdf";
    String output = OUTPUT_PATH + "autoCleanWithCleaUpPropertiesTest.pdf";
    String cmp = INPUT_PATH + "cmp_autoCleanWithCleaUpPropertiesTest.pdf";
    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new RegexBasedCleanupStrategy("leonard"));
    List<PdfCleanUpLocation> additionalLocation = new ArrayList<>();
    additionalLocation.add(new PdfCleanUpLocation(1, new Rectangle(100, 100, 500, 500)));
    PdfCleaner.autoSweepCleanUp(new FileInputStream(input), new FileOutputStream(output), strategy, additionalLocation, new CleanUpProperties());
    compareByContent(cmp, output, OUTPUT_PATH, "autoCleanWithCleaUpPropertiesTest");
}
Also used : RegexBasedCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) PdfString(com.itextpdf.kernel.pdf.PdfString) FileInputStream(java.io.FileInputStream) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 58 with Rectangle

use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method autoCleanPageWithAdditionalLocationAndPropertyTest.

@Test
public void autoCleanPageWithAdditionalLocationAndPropertyTest() throws Exception {
    String input = INPUT_PATH + "fontCleanup.pdf";
    String output = OUTPUT_PATH + "autoCleanPageWithAdditionalLocationAndPropertyTest.pdf";
    String cmp = INPUT_PATH + "cmp_autoCleanPageWithAdditionalLocationAndPropertyTest.pdf";
    CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
    strategy.add(new RegexBasedCleanupStrategy("leonard"));
    List<PdfCleanUpLocation> additionalLocation = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(0, 0, 200, 100), ColorConstants.RED));
    try (PdfReader reader = new PdfReader(input);
        PdfWriter writer = new PdfWriter(output);
        PdfDocument document = new PdfDocument(reader, writer)) {
        PdfCleaner.autoSweepCleanUp(document.getPage(1), strategy, additionalLocation, new CleanUpProperties());
    }
    compareByContent(cmp, output, OUTPUT_PATH, "autoCleanPageWithAdditionalLocationAndPropertyTest");
}
Also used : RegexBasedCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.RegexBasedCleanupStrategy) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) CompositeCleanupStrategy(com.itextpdf.pdfcleanup.autosweep.CompositeCleanupStrategy) Rectangle(com.itextpdf.kernel.geom.Rectangle) 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)

Example 59 with Rectangle

use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.

the class PdfCleanUpToolTest method cleanUpTest42.

@Test
public void cleanUpTest42() throws IOException, InterruptedException {
    String input = INPUT_PATH + "newLines02.pdf";
    String output = OUTPUT_PATH + "newLines02.pdf";
    String cmp = INPUT_PATH + "cmp_newLines02.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(36f, 733f, 270f, 5f), ColorConstants.ORANGE));
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, OUTPUT_PATH, "diff_42");
}
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)

Example 60 with Rectangle

use of com.itextpdf.kernel.geom.Rectangle 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)

Aggregations

Rectangle (com.itextpdf.kernel.geom.Rectangle)118 ExtendedITextTest (com.itextpdf.test.ExtendedITextTest)76 IntegrationTest (com.itextpdf.test.annotations.type.IntegrationTest)76 Test (org.junit.Test)76 PdfString (com.itextpdf.kernel.pdf.PdfString)42 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)41 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)37 ArrayList (java.util.ArrayList)29 PdfReader (com.itextpdf.kernel.pdf.PdfReader)22 PdfCanvas (com.itextpdf.kernel.pdf.canvas.PdfCanvas)16 Paragraph (com.itextpdf.layout.element.Paragraph)15 PdfFont (com.itextpdf.kernel.font.PdfFont)12 Document (com.itextpdf.layout.Document)12 Canvas (com.itextpdf.layout.Canvas)11 PdfPage (com.itextpdf.kernel.pdf.PdfPage)10 ColumnDocumentRenderer (com.itextpdf.layout.ColumnDocumentRenderer)9 LogMessages (com.itextpdf.test.annotations.LogMessages)9 AreaBreak (com.itextpdf.layout.element.AreaBreak)8 PdfCleanUpLocation (com.itextpdf.pdfcleanup.PdfCleanUpLocation)8 HyphenationConfig (com.itextpdf.layout.hyphenation.HyphenationConfig)7