Search in sources :

Example 1 with Color

use of com.itextpdf.kernel.colors.Color in project i7j-pdfsweep by itext.

the class PdfCleanUpTool method extractLocationsFromSingleRedactAnnotation.

/**
 * Note: annotation can consist not only of one area specified by the RECT entry, but also of multiple areas specified
 * by the QuadPoints entry in the annotation dictionary.
 */
private void extractLocationsFromSingleRedactAnnotation(PdfRedactAnnotation redactAnnotation) {
    List<Rectangle> regions;
    PdfArray quadPoints = redactAnnotation.getQuadPoints();
    if (quadPoints != null && !quadPoints.isEmpty()) {
        regions = translateQuadPointsToRectangles(quadPoints);
    } else {
        regions = new ArrayList<>();
        regions.add(redactAnnotation.getRectangle().toRectangle());
    }
    redactAnnotations.put(redactAnnotation, regions);
    int page = pdfDocument.getPageNumber(redactAnnotation.getPage());
    Color cleanUpColor = redactAnnotation.getInteriorColor();
    PdfDictionary ro = redactAnnotation.getRedactRolloverAppearance();
    if (ro != null) {
        cleanUpColor = null;
    }
    for (Rectangle region : regions) {
        addCleanupLocation(new PdfCleanUpLocation(page, region, cleanUpColor));
    }
}
Also used : PdfArray(com.itextpdf.kernel.pdf.PdfArray) PdfDictionary(com.itextpdf.kernel.pdf.PdfDictionary) Color(com.itextpdf.kernel.colors.Color) Rectangle(com.itextpdf.kernel.geom.Rectangle)

Example 2 with Color

use of com.itextpdf.kernel.colors.Color 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;
}
Also used : Color(com.itextpdf.kernel.colors.Color) Rectangle(com.itextpdf.kernel.geom.Rectangle) ArrayList(java.util.ArrayList)

Aggregations

Color (com.itextpdf.kernel.colors.Color)2 Rectangle (com.itextpdf.kernel.geom.Rectangle)2 PdfArray (com.itextpdf.kernel.pdf.PdfArray)1 PdfDictionary (com.itextpdf.kernel.pdf.PdfDictionary)1 ArrayList (java.util.ArrayList)1