Example usage for com.itextpdf.text.pdf.parser Matrix Matrix

List of usage examples for com.itextpdf.text.pdf.parser Matrix Matrix

Introduction

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

Prototype

public Matrix(float tx, float ty) 

Source Link

Document

Constructs a matrix that represents translation

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 va  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

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