Search in sources :

Example 21 with Rectangle

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

the class CleanUpImageUtil method cleanImage.

/**
 * Clean up a BufferedImage using a List of Rectangles that need to be redacted.
 *
 * @param image            the image to be cleaned up
 * @param areasToBeCleaned the List of Rectangles that need to be redacted out of the image
 */
private static void cleanImage(BufferedImage image, List<Rectangle> areasToBeCleaned) {
    Graphics2D graphics = image.createGraphics();
    graphics.setColor(CLEANED_AREA_FILL_COLOR);
    // invert and shear the y axe.
    for (Rectangle rect : areasToBeCleaned) {
        int imgHeight = image.getHeight();
        int imgWidth = image.getWidth();
        int[] scaledRectToClean = CleanUpHelperUtil.getImageRectToClean(rect, imgWidth, imgHeight);
        graphics.fillRect(scaledRectToClean[0], scaledRectToClean[1], scaledRectToClean[2], scaledRectToClean[3]);
    }
    graphics.dispose();
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 22 with Rectangle

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

the class BigDocumentCleanUpTest method textPositioning.

@Test
public void textPositioning() throws IOException, InterruptedException {
    String input = inputPath + "textPositioning.pdf";
    String output = outputPath + "textPositioning.pdf";
    String cmp = inputPath + "cmp_textPositioning.pdf";
    // just to enable cleanup processing of the pages
    List<Rectangle> rects = Arrays.asList(new Rectangle(0f, 0f, 1f, 1f));
    cleanUp(input, output, initLocations(rects, 163));
    compareByContent(cmp, output, outputPath, "4");
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test)

Example 23 with Rectangle

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

the class BigDocumentCleanUpTest method bigTaggedDocument.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.CREATED_ROOT_TAG_HAS_MAPPING))
public void bigTaggedDocument() throws IOException, InterruptedException {
    String input = inputPath + "chapter8_Interactive_features.pdf";
    String output = outputPath + "bigTaggedDocument.pdf";
    String cmp = inputPath + "cmp_bigTaggedDocument.pdf";
    List<Rectangle> rects = Arrays.asList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle(300f, 370f, 215f, 270f));
    cleanUp(input, output, initLocations(rects, 131));
    compareByContent(cmp, output, outputPath, "4");
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 24 with Rectangle

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

the class CleanUpAnnotationTest method cleanWatermarkAnnotation.

@Test
@LogMessages(messages = @LogMessage(messageTemplate = CleanUpLogMessageConstant.REDACTION_OF_ANNOTATION_TYPE_WATERMARK_IS_NOT_SUPPORTED))
public // TODO: update cmp file after DEVSIX-2471 fix
void cleanWatermarkAnnotation() throws IOException, InterruptedException {
    String input = inputPath + "watermarkAnnotation.pdf";
    String output = outputPath + "watermarkAnnotation.pdf";
    String cmp = inputPath + "cmp_watermarkAnnotation.pdf";
    cleanUp(input, output, Collections.singletonList(new PdfCleanUpLocation(1, new Rectangle(410, 410, 50, 50), ColorConstants.YELLOW)));
    compareByContent(cmp, output, outputPath);
}
Also used : Rectangle(com.itextpdf.kernel.geom.Rectangle) IntegrationTest(com.itextpdf.test.annotations.type.IntegrationTest) ExtendedITextTest(com.itextpdf.test.ExtendedITextTest) Test(org.junit.Test) LogMessages(com.itextpdf.test.annotations.LogMessages)

Example 25 with Rectangle

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

the class CleanUpAnnotationTest method cleanLineAnnotation02.

@Test
public void cleanLineAnnotation02() throws IOException, InterruptedException {
    String input = inputPath + "lineAnnotationLeaders.pdf";
    String output = outputPath + "cleanLineAnnotation02.pdf";
    String cmp = inputPath + "cmp_cleanLineAnnotation02.pdf";
    List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
    PdfCleanUpLocation lineLoc = new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30), ColorConstants.GREEN);
    cleanUpLocations.add(lineLoc);
    cleanUp(input, output, cleanUpLocations);
    compareByContent(cmp, output, outputPath);
}
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