Java Code Examples for org.apache.pdfbox.text.TextPosition#getXDirAdj()

The following examples show how to use org.apache.pdfbox.text.TextPosition#getXDirAdj() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtractWordCoordinates.java    From testarea-pdfbox2 with Apache License 2.0 5 votes vote down vote up
void printWord(List<TextPosition> word) {
    Rectangle2D boundingBox = null;
    StringBuilder builder = new StringBuilder();
    for (TextPosition text : word) {
        Rectangle2D box = new Rectangle2D.Float(text.getXDirAdj(), text.getYDirAdj(), text.getWidthDirAdj(), text.getHeightDir());
        if (boundingBox == null)
            boundingBox = box;
        else
            boundingBox.add(box);
        builder.append(text.getUnicode());
    }
    System.out.println(builder.toString() + " [(X=" + boundingBox.getX() + ",Y=" + boundingBox.getY()
             + ") height=" + boundingBox.getHeight() + " width=" + boundingBox.getWidth() + "]");
}
 
Example 2
Source File: TextPositionSequence.java    From testarea-pdfbox2 with Apache License 2.0 4 votes vote down vote up
public float getWidth()
{
    TextPosition first = textPositions.get(start);
    TextPosition last = textPositions.get(end);
    return last.getWidthDirAdj() + last.getXDirAdj() - first.getXDirAdj();
}