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();
}
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");
}
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");
}
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);
}
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);
}
Aggregations