Example usage for com.itextpdf.text.pdf.parser TextRenderInfo getAscentLine

List of usage examples for com.itextpdf.text.pdf.parser TextRenderInfo getAscentLine

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf.parser TextRenderInfo getAscentLine.

Prototype

public LineSegment getAscentLine() 

Source Link

Document

Gets the ascentline for the text (i.e.

Usage

From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpRegionFilter.java

License:Open Source License

/**
 * Checks if the text is inside render filter region.
 *//*  w  w w . j ava2  s. c  o m*/
@Override
public boolean allowText(TextRenderInfo renderInfo) {
    LineSegment ascent = renderInfo.getAscentLine();
    LineSegment descent = renderInfo.getDescentLine();

    Point2D[] glyphRect = new Point2D[] {
            new Point2D.Float(ascent.getStartPoint().get(0), ascent.getStartPoint().get(1)),
            new Point2D.Float(ascent.getEndPoint().get(0), ascent.getEndPoint().get(1)),
            new Point2D.Float(descent.getEndPoint().get(0), descent.getEndPoint().get(1)),
            new Point2D.Float(descent.getStartPoint().get(0), descent.getStartPoint().get(1)), };

    for (Rectangle rectangle : rectangles) {
        Point2D[] redactRect = getVertices(rectangle);

        if (intersect(glyphRect, redactRect)) {
            return false;
        }
    }

    return true;
}