| Modifier and Type | Field and Description |
|---|---|
| private final int[] | |
| private static final Map | |
| private float | |
| private final float | |
| private final float | |
| private final PDFont | |
| private final float | |
| private final int | |
| private static final Log | |
| private final float | |
| private final float | |
| private final float | |
| private final int | |
| private final Matrix | |
| private String | |
| private final float | |
| private float[] | |
| private final float | |
| private final float |
| Access | Constructor and Description |
|---|---|
| public | TextPosition(int
rotation of the page that the text is located in pageRotation, float width of the page that the text is located in pageWidth, float height of the page that the text is located in pageHeight, Matrix text rendering matrix for start of text (in display units) textMatrix, float x coordinate of the end position endX, float y coordinate of the end position endY, float Maximum height of text (in display units) maxHeight, float The width of the given character/string. (in text units) individualWidth, float The width of the space character. (in display units) spaceWidth, String The string of Unicode characters to be displayed. unicode, int[] An array of the internal PDF character codes for the glyphs in this text. charCodes, PDFont The current font for this text position. font, float The new font size. fontSize, int The font size in pt units (see fontSizeInPt)getFontSizeInPt() for details).Constructor. |
| Modifier and Type | Method and Description |
|---|---|
| private String | Returns: Normalized stringString to normalize str)Combine the diacritic, for example, convert non-combining diacritic characters to their combining counterparts. |
| public boolean | Returns: True if tp2 is contained completely inside the bounding box of this text.The other TestPosition to compare against tp2)Determine if this TextPosition perfectly contains another (i.e. the other TextPosition overlaps 100% with this one and fits entirely inside its bounding box when they are rendered on top of each other). |
| public boolean | Returns: True if tp2 is contained in the bounding box of this text.The other TestPosition to compare against tp2)Determine if this TextPosition logically contains another (i.e. they overlap and should be rendered on top of each other). |
| private static Map | |
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. Indicates whether some other object is "equal to" this one. |
| public int[] | Returns: an array of internal PDF character codesReturn the internal PDF character codes of the glyphs in this text. |
| public float | Returns: The direction of the text (0, 90, 180, or 270).Return the direction/orientation of the string in this object based on its text matrix. |
| public float | Returns: The unadjusted x coordinate of the end positionThis will get the x coordinate of the end position. |
| public float | Returns: The unadjusted y coordinate of the end positionThis will get the y coordinate of the end position. |
| public PDFont | |
| public float | Returns: The font size.This will get the font size that has been set with the "Tf" operator (Set text font and size). |
| public float | |
| public float | Returns: The maximum height of all characters in this string.This will get the maximum height of all characters in this string. |
| public float | Returns: The maximum height of all characters in this string.This will get the maximum height of all characters in this string. |
| public float[] | Returns: An array that has the same length as the CharacterCodes array.Get the widths of each individual character. |
| public float | Returns: The unadjusted height of the page that the text is located inThis will get the height of the page that the text is located in. This is the unadjusted value passed into the constructor. |
| public float | Returns: The unadjusted width of the page that the text is located inThis will get the width of the page that the text is located in. This is the unadjusted value passed into the constructor. |
| public int | Returns: The unadjusted rotation of the page that the text is located inThis will get the rotation of the page that the text is located in. This is the unadjusted value passed into the constructor. |
| public Matrix | Returns: The Matrix containing the starting text positionThe matrix containing the starting text position and scaling. |
| public String | Returns: The string on the screen.Return the string of characters stored in this object. |
| public String | Returns: The string on the screen in visual order.Same as |
| public float | Returns: The width of the text in display units.This will get the width of the string when page rotation adjusted coordinates are used. |
| public float | Returns: The width of the text in display units.This will get the width of the string when text direction adjusted coordinates are used. |
| public float | Returns: The width of a space character.This will get the width of a space character. |
| private float | Returns: Width of text in display unitsRotation that was used to determine coordinates (0,90,180,270) rotation)Get the length or width of the text, based on a given rotation. |
| public float | Returns: The x coordinate of the character.This will get the page rotation adjusted x position of the character. |
| public float | Returns: The x coordinate of the text.This will get the text direction adjusted x position of the character. |
| private float | Returns: X coordinateRotation to apply (0, 90, 180, or 270). 0 will perform no adjustments. rotation)Return the X starting coordinate of the text, adjusted by the given rotation amount. |
| public float | |
| public float | Returns: The adjusted y coordinate of the character.This will get the page rotation adjusted x position of the character. |
| public float | Returns: The adjusted y coordinate of the character.This will get the y position of the text, adjusted so that 0,0 is upper left and it is adjusted based on the text direction. |
| private float | Returns: The y coordinate of the textRotation to apply to text to adjust the 0,0 location (0,90,180,270) rotation)This will get the y position of the character with 0,0 in lower left. |
| public float | |
| public int | |
| private void | insertDiacritic(int
current character i, TextPosition The diacritic TextPosition diacritic)Inserts the diacritic TextPosition to the str of this TextPosition and updates the widths array to include the extra character width. |
| public boolean | |
| public void | mergeDiacritic(TextPosition
TextPosition to merge into the current TextPosition. diacritic)Merge a single character TextPosition into the current object. |
| pack-priv void | |
| public String | Returns: A human readable form of this object.Overrides java. Show the string data for this text position. |
| charCodes | back to summary |
|---|---|
| private final int[] charCodes | |
| DIACRITICS | back to summary |
|---|---|
| private static final Map<Integer, String> DIACRITICS | |
| direction | back to summary |
|---|---|
| private float direction | |
| endX | back to summary |
|---|---|
| private final float endX | |
| endY | back to summary |
|---|---|
| private final float endY | |
| font | back to summary |
|---|---|
| private final PDFont font | |
| fontSize | back to summary |
|---|---|
| private final float fontSize | |
| fontSizePt | back to summary |
|---|---|
| private final int fontSizePt | |
| LOG | back to summary |
|---|---|
| private static final Log LOG | |
| maxHeight | back to summary |
|---|---|
| private final float maxHeight | |
| pageHeight | back to summary |
|---|---|
| private final float pageHeight | |
| pageWidth | back to summary |
|---|---|
| private final float pageWidth | |
| rotation | back to summary |
|---|---|
| private final int rotation | |
| textMatrix | back to summary |
|---|---|
| private final Matrix textMatrix | |
| unicode | back to summary |
|---|---|
| private String unicode | |
| widthOfSpace | back to summary |
|---|---|
| private final float widthOfSpace | |
| widths | back to summary |
|---|---|
| private float[] widths | |
| x | back to summary |
|---|---|
| private final float x | |
| y | back to summary |
|---|---|
| private final float y | |
| TextPosition | back to summary |
|---|---|
| public TextPosition(int pageRotation, float pageWidth, float pageHeight, Matrix textMatrix, float endX, float endY, float maxHeight, float individualWidth, float spaceWidth, String unicode, int[] charCodes, PDFont font, float fontSize, int fontSizeInPt) Constructor.
| |
| combineDiacritic | back to summary |
|---|---|
| private String combineDiacritic(String str) Combine the diacritic, for example, convert non-combining diacritic characters to their combining counterparts. | |
| completelyContains | back to summary |
|---|---|
| public boolean completelyContains(TextPosition tp2) Determine if this TextPosition perfectly contains another (i.e. the other TextPosition overlaps 100% with this one and fits entirely inside its bounding box when they are rendered on top of each other).
| |
| contains | back to summary |
|---|---|
| public boolean contains(TextPosition tp2) Determine if this TextPosition logically contains another (i.e. they overlap and should be rendered on top of each other).
| |
| createDiacritics | back to summary |
|---|---|
| private static Map | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getCharacterCodes | back to summary |
|---|---|
| public int[] getCharacterCodes() Return the internal PDF character codes of the glyphs in this text.
| |
| getDir | back to summary |
|---|---|
| public float getDir() Return the direction/orientation of the string in this object based on its text matrix. Only angles of 0, 90, 180, or 270 are supported. To get other angles, use this code: TextPosition text = ... Matrix m = text.getTextMatrix().clone(); m.concatenate(text.getFont().getFontMatrix()); int angle = (int) Math.round(Math.toDegrees(Math.atan2(m.getShearY(), m.getScaleY())));
| |
| getEndX | back to summary |
|---|---|
| public float getEndX() This will get the x coordinate of the end position. This is the unadjusted value passed into the constructor.
| |
| getEndY | back to summary |
|---|---|
| public float getEndY() This will get the y coordinate of the end position. This is the unadjusted value passed into the constructor.
| |
| getFont | back to summary |
|---|---|
| public PDFont getFont() This will get the font for the text being drawn.
| |
| getFontSize | back to summary |
|---|---|
| public float getFontSize() This will get the font size that has been set with the "Tf" operator (Set text font and size). When the text is rendered, it may appear bigger or smaller depending on the current transformation matrix (set by the "cm" operator) and the text matrix (set by the "Tm" operator).
| |
| getFontSizeInPt | back to summary |
|---|---|
| public float getFontSizeInPt() This will get the font size in pt. To get this size we have to multiply the font size from
| |
| getHeight | back to summary |
|---|---|
| public float getHeight() This will get the maximum height of all characters in this string.
| |
| getHeightDir | back to summary |
|---|---|
| public float getHeightDir() This will get the maximum height of all characters in this string.
| |
| getIndividualWidths | back to summary |
|---|---|
| public float[] getIndividualWidths() Get the widths of each individual character.
| |
| getPageHeight | back to summary |
|---|---|
| public float getPageHeight() This will get the height of the page that the text is located in. This is the unadjusted value passed into the constructor.
| |
| getPageWidth | back to summary |
|---|---|
| public float getPageWidth() This will get the width of the page that the text is located in. This is the unadjusted value passed into the constructor.
| |
| getRotation | back to summary |
|---|---|
| public int getRotation() This will get the rotation of the page that the text is located in. This is the unadjusted value passed into the constructor.
| |
| getTextMatrix | back to summary |
|---|---|
| public Matrix getTextMatrix() The matrix containing the starting text position and scaling. Despite the name, it is not the text matrix set by the "Tm" operator, it is really the effective text rendering matrix (which is dependent on the current transformation matrix (set by the "cm" operator), the text matrix (set by the "Tm" operator), the font size (set by the "Tf" operator) and the page cropbox).
| |
| getUnicode | back to summary |
|---|---|
| public String getUnicode() Return the string of characters stored in this object. The length can be different than the CharacterCodes length e.g. if ligatures are used ("fi", "fl", "ffl") where one glyph represents several unicode characters.
| |
| getVisuallyOrderedUnicode | back to summary |
|---|---|
| public String getVisuallyOrderedUnicode() Same as
| |
| getWidth | back to summary |
|---|---|
| public float getWidth() This will get the width of the string when page rotation adjusted coordinates are used.
| |
| getWidthDirAdj | back to summary |
|---|---|
| public float getWidthDirAdj() This will get the width of the string when text direction adjusted coordinates are used.
| |
| getWidthOfSpace | back to summary |
|---|---|
| public float getWidthOfSpace() This will get the width of a space character. This is useful for some algorithms such as the text stripper, that need to know the width of a space character.
| |
| getWidthRot | back to summary |
|---|---|
| private float getWidthRot(float rotation) Get the length or width of the text, based on a given rotation.
| |
| getX | back to summary |
|---|---|
| public float getX() This will get the page rotation adjusted x position of the character. This is adjusted based on page rotation so that the upper left is 0,0 which is unlike PDF coordinates, which start at the bottom left. See also this answer by Michael Klink for further details and PDFBOX-4597 for a sample file.
| |
| getXDirAdj | back to summary |
|---|---|
| public float getXDirAdj() This will get the text direction adjusted x position of the character.
This is adjusted based on text direction so that the first character
in that direction is in the upper left at 0,0.
This method ignores the page rotation but takes the text rotation (see
| |
| getXRot | back to summary |
|---|---|
| private float getXRot(float rotation) Return the X starting coordinate of the text, adjusted by the given rotation amount. The rotation adjusts where the 0,0 location is relative to the text.
| |
| getXScale | back to summary |
|---|---|
| public float getXScale() This will get the X scaling factor. This is dependent on the current transformation matrix (set by the "cm" operator), the text matrix (set by the "Tm" operator) and the font size (set by the "Tf" operator).
| |
| getY | back to summary |
|---|---|
| public float getY() This will get the page rotation adjusted x position of the character. This is adjusted based on page rotation so that the upper left is 0,0 which is unlike PDF coordinates, which start at the bottom left. See also this answer by Michael Klink for further details and PDFBOX-4597 for a sample file.
| |
| getYDirAdj | back to summary |
|---|---|
| public float getYDirAdj() This will get the y position of the text, adjusted so that 0,0 is upper left and it is adjusted based on the text direction. This method ignores the page rotation but takes the text rotation and adjusts the coordinates to awt. This is useful when doing text extraction, to compare the glyph positions when imagining these to be horizontal. See also this answer by Michael Klink for further details and PDFBOX-4597 for a sample file.
| |
| getYLowerLeftRot | back to summary |
|---|---|
| private float getYLowerLeftRot(float rotation) This will get the y position of the character with 0,0 in lower left. This will be adjusted by the given rotation.
| |
| getYScale | back to summary |
|---|---|
| public float getYScale() This will get the Y scaling factor. This is dependent on the current transformation matrix (set by the "cm" operator), the text matrix (set by the "Tm" operator) and the font size (set by the "Tf" operator).
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| insertDiacritic | back to summary |
|---|---|
| private void insertDiacritic(int i, TextPosition diacritic) Inserts the diacritic TextPosition to the str of this TextPosition and updates the widths array to include the extra character width.
| |
| isDiacritic | back to summary |
|---|---|
public boolean isDiacritic()
| |
| mergeDiacritic | back to summary |
|---|---|
| public void mergeDiacritic(TextPosition diacritic) Merge a single character TextPosition into the current object. This is to be used only for cases where we have a diacritic that overlaps an existing TextPosition. In a graphical display, we could overlay them, but for text extraction we need to merge them. Use the contains() method to test if two objects overlap.
| |
| setUnicode | back to summary |
|---|---|
| pack-priv void setUnicode(String unicode) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Show the string data for this text position. | |