Search in sources :

Example 86 with Rectangle

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

the class PdfCleanUpToolTest method simpleCleanUpOnRotatedPages.

@Test
public void simpleCleanUpOnRotatedPages() throws IOException, InterruptedException {
    String fileName = "simpleCleanUpOnRotatedPages";
    String input = INPUT_PATH + "documentWithRotatedPages.pdf";
    String output = OUTPUT_PATH + fileName + ".pdf";
    String cmp = INPUT_PATH + "cmp_" + fileName + ".pdf";
    List<PdfCleanUpLocation> locationsList = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        locationsList.add(new PdfCleanUpLocation(i + 1, new Rectangle(100, 100, 200, 100), ColorConstants.GREEN));
    }
    cleanUp(input, output, locationsList);
    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)

Example 87 with Rectangle

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

the class PdfCleanUpToolTest method cleanUpTest40.

@Test
public void cleanUpTest40() throws IOException, InterruptedException {
    String input = INPUT_PATH + "emptyTj01.pdf";
    String output = OUTPUT_PATH + "emptyTj01.pdf";
    String cmp = INPUT_PATH + "cmp_emptyTj01.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(70f, 555f, 200f, 5f), ColorConstants.ORANGE));
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, OUTPUT_PATH, "diff_40");
}
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 88 with Rectangle

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

the class PdfCleanUpToolTest method cleanUpTest45.

@Test
public void cleanUpTest45() throws IOException, InterruptedException {
    String input = INPUT_PATH + "emptyPdf.pdf";
    String output = OUTPUT_PATH + "emptyPdf.pdf";
    String cmp = INPUT_PATH + "cmp_emptyPdf.pdf";
    PdfAnnotation redactAnnotation = new PdfRedactAnnotation(new Rectangle(97, 405, 383, 40)).setOverlayText(new PdfString("OverlayTest")).setDefaultAppearance(new PdfString("/Helv 0 Tf 0 g"));
    PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));
    pdfDocument.getFirstPage().addAnnotation(redactAnnotation);
    PdfCleaner.cleanUpRedactAnnotations(pdfDocument);
    pdfDocument.close();
    compareByContent(cmp, output, OUTPUT_PATH, "diff_45");
}
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) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 89 with Rectangle

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

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

the class PdfCleanUpToolTest method cleanUpTest33.

@Test
public void cleanUpTest33() throws IOException, InterruptedException {
    String input = INPUT_PATH + "viewer_prefs_dict_table.pdf";
    String output = OUTPUT_PATH + "complexTextPositioning.pdf";
    String cmp = INPUT_PATH + "cmp_complexTextPositioning.pdf";
    cleanUp(input, output, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(300f, 370f, 215f, 270f))));
    compareByContent(cmp, output, OUTPUT_PATH, "diff_33");
}
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)

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