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

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

Introduction

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

Prototype

public float getRise() 

Source Link

Document

The rise represents how far above the nominal baseline the text should be rendered.

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()));
    }// w ww.  j a  v a 2 s. c o m

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

From source file:DouDownloader.CustomLocationTextExtractionStrategy.java

License:Open Source License

/**
 * /* www  . j ava2s.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);
}