use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class CleanUpImageIndexedColorSpaceTest method noWhiteColorTest.
@Test
public void noWhiteColorTest() throws Exception {
String input = inputPath + "indexedImageNoWhite.pdf";
String output = outputPath + "indexedImageNoWhite.pdf";
String cmp = inputPath + "cmp_indexedImageNoWhite.pdf";
try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output))) {
PdfCleaner.cleanUp(pdfDocument, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(150, 250, 100, 100))));
}
/*
Result in Java and .NET is different.
Java is able to process images with indexed colorspace same as others and
doesn't preserve indexed colorspace. .NET requires special processing for
indexed colorspace images, but preserves indexed colorspace.
In .NET color of cleaned area is the first color of indexed color palette.
In Java color of cleaned area is white.
*/
Assert.assertNull(new CompareTool().compareByContent(output, cmp, outputPath));
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class CleanUpTransformedImageTest method skewedRgbImageBBoxCleanUpTest.
@Test
public void skewedRgbImageBBoxCleanUpTest() throws Exception {
// TODO DEVSIX-5089 skewed images cleanup is not supported
String input = inputPath + "skewedRgbImage.pdf";
String output = outputPath + "skewedRgbImage.pdf";
String cmp = inputPath + "cmp_skewedRgbImage.pdf";
Rectangle cleanupRegion = new Rectangle(150, 250, 100, 100);
cleanFirstPageAndDrawCleanupRegion(cleanupRegion, input, output);
Assert.assertNull(findDifferencesBetweenOutputAndCmp(output, cmp));
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class CleanupImageWithColorSpaceTest method cleanUpTestColorSpaceJpegBaselineEncodedWithApp14Segment.
@Test
public void cleanUpTestColorSpaceJpegBaselineEncodedWithApp14Segment() throws Exception {
// cleanup jpeg image with baseline encoded data and app14 segment with unknown color type
// Adobe Photoshop will always add an APP14 segment into the resulting jpeg file.
// To make Unknown color type we have set the quality of an image to maximum during the "save as" operation
String input = inputPath + "imgSeparationCsJpegBaselineEncodedWithApp14Segment.pdf";
String output = outputPath + "imgSeparationCsJpegBaselineEncodedWithApp14Segment.pdf";
String cmp = inputPath + "cmp_imgSeparationCsJpegBaselineEncodedWithApp14Segment.pdf";
cleanUp(input, output, Arrays.asList(new PdfCleanUpLocation(1, new Rectangle(60f, 600f, 100f, 50f), ColorConstants.GREEN)));
compareByContent(cmp, output, outputPath, "10");
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class CustomLocationExtractionStrategy method toRectangles.
@Override
public List<Rectangle> toRectangles(List<CharacterRenderInfo> cris) {
Color col = ((CCharacterRenderInfo) cris.get(0)).getFillColor();
List<Rectangle> rects = new ArrayList<>(super.toRectangles(cris));
for (Rectangle rect : rects) {
colorByRectangle.put(rect, col);
}
return rects;
}
use of com.itextpdf.kernel.geom.Rectangle in project i7j-pdfsweep by itext.
the class BigDocumentCleanUpTest method bigUntaggedDocument.
@Test
public void bigUntaggedDocument() throws IOException, InterruptedException {
String input = inputPath + "iphone_user_guide_untagged.pdf";
String output = outputPath + "bigUntaggedDocument.pdf";
String cmp = inputPath + "cmp_bigUntaggedDocument.pdf";
List<Rectangle> rects = Arrays.asList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle(300f, 370f, 215f, 260f));
cleanUp(input, output, initLocations(rects, 130));
compareByContent(cmp, output, outputPath, "4");
}
Aggregations