Package com.datalogics.PDFL
Class Text
java.lang.Object
com.datalogics.PDFL.Element
com.datalogics.PDFL.Text
A container that represents a series of text elements and characters. A Text object is container that represents both a series of TextRun elements and a series of text characters. Operations can be performed on individual TextRuns within a Text or on individual characters within a Text by specifying the index of the individual TextRun or character. All indices start at 0.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlyphs(List<Character> glyphIDs, List<Character> uniText, Font font, GraphicState gState, TextState state, Matrix matrix, EnumSet<TextFlags> flags) Adds Unicode text to a Text objectvoidaddGlyphs(List<Character> glyphIDs, List<Character> uniText, Font font, GraphicState gState, TextState state, Matrix matrix, EnumSet<TextFlags> flags, int index) Adds Unicode text to a Text objectvoidAdds a TextRun to the end of this text element.voidAdds a TextRun at the specified index.voidchangeMatrixForTextRun(Matrix newMatrix, int textRunIndex) Changes the transformation matrix from user space to the current text space for the specified TextRun.voidchangeTextMatrixForTextRun(Matrix newMatrix, int textRunIndex) Changes the transformation matrix from user space to the current text space for the specified TextRun.clone()Makes a copy of the text.clone(EnumSet<ElementCloneFlags> cloneFlags) Makes a copy of the text.colorConvert(Document document, ColorProfile prof, RenderIntent intent, boolean embed) Applies the specified ICC ColorProfile to the Text objectvoiddelete()intfindTextRunIndexForCharacter(int characterIndex) Finds the index of the TextRun that contains the nth character in a Text object.getAdvanceForCharacter(int characterIndex) Gets the advance width of a character, in user space.getAdvanceForTextRun(int textRunIndex) Gets the advance width of a TextRun, in user space.getBoundingBoxForCharacter(int characterIndex) The bounding box for a character in this text element.intThe number of characters in this text element.intThe number of text runs in this text element.getRun(int index) Obtains the TextRun at the specified index.getTextMatrixForCharacter(int characterIndex) Gets the transformation matrix from user space to the current text space for the specified character.getTextMatrixForTextRun(int textRunIndex) Gets the transformation matrix from user space to the current text space for the specified TextRun.booleanpointIntersectsCharacter(Point p, int index) Tests whether a point is on a specified character within this Text object.booleanpointIntersectsTextRun(Point p, int index) Tests whether a point is on a specified TextRun within this Text object.booleanrectIntersectsCharacter(Rect r, int index) Tests whether any part of a rectangle is on a specified character within this Text object.booleanrectIntersectsTextRun(Rect r, int index) Tests whether any part of a rectangle is on a specified TextRun within this Text object.voidremoveRuns(int index, int count) Removes a count of TextRuns, starting from indexvoidsplitTextRunAtCharacter(int splitLocation) Splits the TextRun containing the character at the specified location into two contiguous TextRuns.
-
Constructor Details
-
Text
public Text()
-
-
Method Details
-
delete
public void delete() -
getNumberOfRuns
public int getNumberOfRuns()The number of text runs in this text element. -
getRun
Obtains the TextRun at the specified index. -
addRun
Adds a TextRun to the end of this text element. -
addRun
Adds a TextRun at the specified index.- Parameters:
run- TextRun to be addedindex- Index, where TextRun should be placed
-
removeRuns
public void removeRuns(int index, int count) Removes a count of TextRuns, starting from index- Parameters:
index- Start position of range to deletecount- Count of TextRuns to delete
-
addGlyphs
public void addGlyphs(List<Character> glyphIDs, List<Character> uniText, Font font, GraphicState gState, TextState state, Matrix matrix, EnumSet<TextFlags> flags) Adds Unicode text to a Text object- Parameters:
glyphIDs- Glyphs IDs in the specified font for adding to the page's contentuniText- Unicode codes for the specified glyph IDsfont- Font for wich GlyphIDs were specifiedgState- The GraphicsState for Text elementstate- TextState flagsmatrix- matrix for the Text elementflags- TextFlags that specifies what kind of text to add
-
addGlyphs
public void addGlyphs(List<Character> glyphIDs, List<Character> uniText, Font font, GraphicState gState, TextState state, Matrix matrix, EnumSet<TextFlags> flags, int index) Adds Unicode text to a Text object- Parameters:
glyphIDs- Glyphs IDs in the specified font to add to the page's contentuniText- Unicode codes for the specified glyph IDsfont- Font for wich GlyphIDs were specifiedgState- The GraphicsState for Text elementstate- TextState flagsmatrix- matrix for the Text elementflags- TextFlags that specifies what kind of text to addindex- The index after which to add the character or text run.
-
clone
Makes a copy of the text.Make a copy of an text to obtain a new text that has a distinct set of attributes.
-
clone
Makes a copy of the text.Make a copy of an text to obtain a new text that has a distinct set of attributes.
-
pointIntersectsCharacter
Tests whether a point is on a specified character within this Text object.- Parameters:
p- The point to test, in user space coordinates.index- The index of the character. The first character in the Text has an index of 0.- Returns:
- true if the point is on the character, false if the point is not on the character.
-
pointIntersectsTextRun
Tests whether a point is on a specified TextRun within this Text object.- Parameters:
p- The point to test, in user space coordinates.index- The index of the TextRun. The first TextRun in the Text has an index of 0.- Returns:
- true if the point is on the TextRun, false if the point is not on the TextRun.
-
rectIntersectsCharacter
Tests whether any part of a rectangle is on a specified character within this Text object.- Parameters:
r- The rect to test, in user space coordinates.index- The index of the character. The first character in the Text has an index of 0.- Returns:
- true if any part of the rectangle is on the character, false if no part of the rectangle is on the character.
-
rectIntersectsTextRun
Tests whether any part of a rectangle is on a specified TextRun within this Text object.- Parameters:
r- The rect to test, in user space coordinates.index- The index of the TextRun. The first TextRun in the Text has an index of 0.- Returns:
- true if any part of the rectangle is on the TextRun, false if no part of the rectangle is on the TextRun.
-
splitTextRunAtCharacter
public void splitTextRunAtCharacter(int splitLocation) Splits the TextRun containing the character at the specified location into two contiguous TextRuns. The character at the specified index will be part of the first TextRun.- Parameters:
splitLocation- The split location, relative to the Text object.
-
findTextRunIndexForCharacter
public int findTextRunIndexForCharacter(int characterIndex) Finds the index of the TextRun that contains the nth character in a Text object.- Parameters:
characterIndex- The index of a character, relative to the Text object (the first character in the Text object is at index 0).- Returns:
- The index of the TextRun that contains the character specified by characterIndex.
-
getTextMatrixForCharacter
Gets the transformation matrix from user space to the current text space for the specified character. The H and V values of the matrix indicate the origin of the first character.- Parameters:
characterIndex- The index of a character, relative to the Text object (the first character in the Text object is at index 0).- Returns:
- The transformation matrix for the character specified by characterIndex.
-
getTextMatrixForTextRun
Gets the transformation matrix from user space to the current text space for the specified TextRun. The H and V values of the matrix indicate the origin of the first character.- Parameters:
textRunIndex- The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).- Returns:
- The transformation matrix for the TextRun specified by TextRunIndex.
-
changeTextMatrixForTextRun
Changes the transformation matrix from user space to the current text space for the specified TextRun. The H and V values of the matrix indicate the origin of the first character.- Parameters:
newMatrix- The new transformation matrix to use for the TextRun.textRunIndex- The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).
-
changeMatrixForTextRun
Changes the transformation matrix from user space to the current text space for the specified TextRun. Unlike ChangeTextMatrixForTextRun(), this function does not change fontSize, hScale, and textRise in the textState of PDEText. The H and V values of the matrix indicate the origin of the first character.- Parameters:
newMatrix- The new transformation matrix to use for the TextRun.textRunIndex- The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).
-
getAdvanceForCharacter
Gets the advance width of a character, in user space. The advance width is the amount by which the current point advances when the character is drawn.Advance width may be horizontal or vertical, depending on the writing style. Thus, the return value has both a horizontal and a vertical component.
- Parameters:
characterIndex- The index of a character, relative to the Text object (the first character in the Text object is at index 0).- Returns:
- A value specifying both the horizontal and vertical components of the advance width of a character in user space.
-
getAdvanceForTextRun
Gets the advance width of a TextRun, in user space. The advance width is the amount by which the current point advances when the TextRun is drawn.Advance width may be horizontal or vertical, depending on the writing style. Thus, the return value has both a horizontal and a vertical component.
- Parameters:
textRunIndex- The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).- Returns:
- A value specifying both the horizontal and vertical components of the advance width of a TextRun in user space.
-
getNumberOfCharacters
public int getNumberOfCharacters()The number of characters in this text element. -
getBoundingBoxForCharacter
The bounding box for a character in this text element.- Parameters:
characterIndex- The index of a character, relative to the Text object (the first character in the Text object is at index 0)- Returns:
- A Rect specifying the bounding box for the character.
-
colorConvert
Applies the specified ICC ColorProfile to the Text object- Parameters:
document- The document the element belongs to.prof- The ICC ColorProfile to be applied.intent- The ICC Rendering Intent for the ColorProfileembed- If true, embed the color space and make the object calibrated. If it is false and the target profile is CMYK, RGB, or Gray, the colors space of the resulting object, after conversion, will be DeviceCMYK, DeviceRGB, or DeviceGray, respectively.- Returns:
- A new Text object with the applied ICC ColorProfile.
-