Example usage for com.itextpdf.text.pdf.parser LineSegment transformBy

List of usage examples for com.itextpdf.text.pdf.parser LineSegment transformBy

Introduction

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

Prototype

public LineSegment transformBy(Matrix m) 

Source Link

Document

Transforms the segment by the specified matrix

Usage

From source file:com.cyberninjas.pdf.TextChunkExtractionStrategy.java

License:Open Source License

@Override
public void renderText(TextRenderInfo renderInfo) {
    LineSegment segment = renderInfo.getBaseline();

    if (renderInfo.getRise() != 0) {
        // remove the rise from the baseline - we do this because the text from a super/subscript render operations should probably be considered as part of the baseline of the text the super/sub is relative to 
        segment = segment.transformBy(new Matrix(0, -renderInfo.getRise()));
    }//from w  w w  . j av  a  2 s  .  c om

    textChunks.add(new TextChunk(renderInfo.getText(), segment.getStartPoint(), segment.getEndPoint(),
            renderInfo.getSingleSpaceWidth()));
}

From source file:DouDownloader.CustomLocationTextExtractionStrategy.java

License:Open Source License

/**
 * /*from   w  w w  .j a  v a 2 s  .  c o m*/
 * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo)
 */
public void renderText(TextRenderInfo renderInfo) {
    LineSegment segment = renderInfo.getBaseline();
    if (renderInfo.getRise() != 0) { // remove the rise from the baseline -
                                     // we do this because the text from
                                     // a
                                     // super/subscript render operations
                                     // should probably be considered as
                                     // part of
                                     // the baseline of the text the
                                     // super/sub is relative to
        Matrix riseOffsetTransform = new Matrix(0, -renderInfo.getRise());
        segment = segment.transformBy(riseOffsetTransform);
    }

    TipoTexto tipo = TipoTexto.NORMAL;

    if (renderInfo.getFont().getFontDescriptor(DocumentFont.CAPHEIGHT, 1000) > 681) {
        /*
         * System.out.println("OPA!!!:-- " + renderInfo.getFont().getFontDescriptor( DocumentFont.CAPHEIGHT, 1000) + " x " +
         * renderInfo.getText());
         */
        tipo = TipoTexto.AUTONOMOS;
    }

    TextChunk location = new TextChunk(renderInfo.getText(), segment.getStartPoint(), segment.getEndPoint(),
            renderInfo.getSingleSpaceWidth(), tipo);
    locationalResult.add(location);
}