Search in sources :

Example 91 with Rectangle

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

the class PdfCleanUpToolTest method cleanUpTest46.

@Test
public void cleanUpTest46() throws IOException {
    String input = INPUT_PATH + "emptyPdf.pdf";
    String output = OUTPUT_PATH + "emptyPdf.pdf";
    PdfAnnotation redactAnnotation = new PdfRedactAnnotation(new Rectangle(97, 405, 383, 40)).setOverlayText(new PdfString("OverlayTest"));
    try (PdfReader reader = new PdfReader(input);
        PdfWriter writer = new PdfWriter(output);
        PdfDocument pdfDocument = new PdfDocument(reader, writer)) {
        pdfDocument.getFirstPage().addAnnotation(redactAnnotation);
        Exception e = Assert.assertThrows(PdfException.class, () -> PdfCleaner.cleanUpRedactAnnotations(pdfDocument));
        Assert.assertEquals(CleanupExceptionMessageConstant.DEFAULT_APPEARANCE_NOT_FOUND, e.getMessage());
    }
}
Also used : PdfRedactAnnotation(com.itextpdf.kernel.pdf.annot.PdfRedactAnnotation) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) PdfAnnotation(com.itextpdf.kernel.pdf.annot.PdfAnnotation) Rectangle(com.itextpdf.kernel.geom.Rectangle) PdfString(com.itextpdf.kernel.pdf.PdfString) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfString(com.itextpdf.kernel.pdf.PdfString) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument) IOException(java.io.IOException) PdfException(com.itextpdf.kernel.exceptions.PdfException) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 92 with Rectangle

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

the class CleanUpAnnotationTest method cleanTextAnnotation01.

@Test
public void cleanTextAnnotation01() throws IOException, InterruptedException {
    String input = inputPath + "cleanAnnotation.pdf";
    String output = outputPath + "cleanAnnotation_Text01.pdf";
    String cmp = inputPath + "cmp_cleanAnnotation_Text01.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
    PdfCleanUpLocation textLoc = new PdfCleanUpLocation(1, new Rectangle(150, 650, 0, 0), ColorConstants.RED);
    cleanUpLocations.add(textLoc);
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, outputPath, "diff_Annotation_text01");
}
Also used : ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 93 with Rectangle

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

the class CleanUpAnnotationTest method cleanLineAnnotation01.

@Test
public void cleanLineAnnotation01() throws IOException, InterruptedException {
    String input = inputPath + "cleanAnnotation.pdf";
    String output = outputPath + "cleanAnnotation_Line01.pdf";
    String cmp = inputPath + "cmp_cleanAnnotation_Line01.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
    PdfCleanUpLocation lineLoc = new PdfCleanUpLocation(1, new Rectangle(20, 20, 555, 0), ColorConstants.GREEN);
    cleanUpLocations.add(lineLoc);
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, outputPath, "diff_Annotation_line01");
}
Also used : ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 94 with Rectangle

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

the class CleanUpAnnotationTest method cleanFormAnnotations01.

@Test
public void cleanFormAnnotations01() throws IOException, InterruptedException {
    String input = inputPath + "formAnnotation.pdf";
    String output = outputPath + "formAnnotation01.pdf";
    String cmp = inputPath + "cmp_formAnnotation01.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
    PdfCleanUpLocation highLightLoc = new PdfCleanUpLocation(1, new Rectangle(20, 600, 500, 170), ColorConstants.YELLOW);
    cleanUpLocations.add(highLightLoc);
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, outputPath, "diff_form01");
}
Also used : ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 95 with Rectangle

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

the class CleanUpAnnotationTest method cleanFormAnnotations02.

@Test
public void cleanFormAnnotations02() throws IOException, InterruptedException {
    String input = inputPath + "formAnnotation.pdf";
    String output = outputPath + "formAnnotation02.pdf";
    String cmp = inputPath + "cmp_formAnnotation02.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
    PdfCleanUpLocation highLightLoc = new PdfCleanUpLocation(1, new Rectangle(20, 600, 300, 100), ColorConstants.YELLOW);
    cleanUpLocations.add(highLightLoc);
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, outputPath, "diff_form02");
}
Also used : ArrayList(java.util.ArrayList) Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

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