public final class TextFragmentState extends TextState
Represents a text state of a text fragment.
The example demonstrates how to change text color and font size of the text withTextStateobject.// Open document Document doc = new Document("D:\\Tests\\input.pdf"); // Create TextFragmentAbsorber object to find all "hello world" text occurrences TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world"); // Accept the absorber for first page doc.getPages().get(1).accept(absorber); // Change foreground color of the first text occurrence absorber.TgetextFragments().get(1).getTextState().setForegroundColor ( java.awt.Color.RED); // Change font size of the first text occurrence absorber.getTextFragments().get(1).getTextState().setFontSize ( 15); // Save document doc.save("D:\\Tests\\output.pdf");
TextFragmentState.Font
property) font size (TextFragmentState.FontSize property) font style (
TextFragmentState.FontStyle property) foreground color (
TextFragmentState.ForegroundColor property) background color (
TextFragmentState.BackgroundColor property)
Note that changing TextFragmentState properties may change inner
TextFragment.Segments collection because TextFragment is an aggregate object and it may
rearrange internal segments or merge them into single segment. If your requirement is to leave
the TextFragment.Segments collection unchanged, please change inner segments
individually.
TextFragmentAbsorber,
IDocumentTabstopDefaultValue, TabTag| Constructor and Description |
|---|
TextFragmentState(TextFragment fragment)
Initializes new instance of the
TextFragmentState object with specified
TextFragment object. |
| Modifier and Type | Method and Description |
|---|---|
void |
applyChangesFrom(TextState textState)
Applies settings from another textState
|
void |
applyChangesFrom(TextState textState,
boolean groupChangesOnly)
Applies settings from another textState
|
float |
getCharacterSpacing()
Gets character spacing of the text, represented by the
TextFragment object. |
Font |
getFont()
Gets font of the text, represented by the
TextFragment object |
float |
getFontSize()
Gets font size of the text, represented by the
TextFragment object |
Color |
getForegroundColor()
Gets foreground color of the text, represented by the
TextFragment object |
int |
getHorizontalAlignment()
Gets horizontal alignment for the text.
|
float |
getHorizontalScaling()
Gets horizontal scaling of the text, represented by the
TextFragment object. |
float |
getLineSpacing()
Gets line spacing of the text.
|
TabStops |
getTabStops()
Gets tabstops for the text.
|
float |
getWordSpacing()
Gets word spacing of the text.
|
boolean |
isInvisible()
Gets invisibility of the text.
|
boolean |
isSubscript()
Gets or sets subscript of the text, represented by the
TextFragment object. |
boolean |
isSuperscript()
Gets or sets superscript of the text, represented by the
TextFragment object. |
double |
measureString(String str)
Measures the string.
|
void |
setBackgroundColor(Color value)
Sets background color of the text, represented by the
TextFragment object |
void |
setCharacterSpacing(float value)
Sets character spacing of the text, represented by the
TextFragment object. |
void |
setFont(Font value)
Sets font of the text, represented by the
TextFragment object |
void |
setFontSize(float value)
Sets font size of the text, represented by the
TextFragment object |
void |
setFontStyle(int value)
Sets font style of the text, represented by the
TextFragment object |
void |
setForegroundColor(Color value)
Sets foreground color of the text, represented by the
TextFragment object |
void |
setHorizontalAlignment(int value)
Sets horizontal alignment for the text.
|
void |
setHorizontalScaling(float value)
Sets horizontal scaling of the text, represented by the
TextFragment object. |
void |
setInvisible(boolean value)
Sets invisibility of the text.
|
void |
setLineSpacing(float value)
Sets line spacing of the text.
|
void |
setStrikeOut(boolean value)
Sets strikeout for the text, represented by the
TextFragment object |
void |
setSubscript(boolean value)
Gets or sets subscript of the text, represented by the
TextFragment object. |
void |
setSuperscript(boolean value)
Gets or sets superscript of the text, represented by the
TextFragment object. |
void |
setUnderline(boolean value)
Sets underline for the text, represented by the
TextFragment object |
void |
setWordSpacing(float value)
Sets word spacing of the text.
|
calculateFontSize, getBackgroundColor, getStrikeOut, isUnderlinepublic TextFragmentState(TextFragment fragment)
Initializes new instance of the TextFragmentState object with specified
TextFragment object. This TextFragmentState initialization is not supported.
TextFragmentState is only available with TextFragment.TextState property.
fragment - Text fragment object.public float getCharacterSpacing()
Gets character spacing of the text, represented by the TextFragment object.
getCharacterSpacing in class TextStatepublic void setCharacterSpacing(float value)
Sets character spacing of the text, represented by the TextFragment object.
setCharacterSpacing in class TextStatevalue - float valuepublic float getHorizontalScaling()
Gets horizontal scaling of the text, represented by the TextFragment object.
getHorizontalScaling in class TextStatepublic void setHorizontalScaling(float value)
Sets horizontal scaling of the text, represented by the TextFragment object.
setHorizontalScaling in class TextStatevalue - float valuepublic float getWordSpacing()
Gets word spacing of the text.
getWordSpacing in class TextStatepublic void setWordSpacing(float value)
Sets word spacing of the text.
setWordSpacing in class TextStatevalue - float valuepublic boolean isSubscript()
Gets or sets subscript of the text, represented by the TextFragment object.
isSubscript in class TextStatepublic void setSubscript(boolean value)
Gets or sets subscript of the text, represented by the TextFragment object.
setSubscript in class TextStatevalue - boolean valuepublic boolean isInvisible()
Gets invisibility of the text.
isInvisible in class TextStatepublic void setInvisible(boolean value)
Sets invisibility of the text.
setInvisible in class TextStatevalue - boolean valuepublic boolean isSuperscript()
Gets or sets superscript of the text, represented by the TextFragment object.
isSuperscript in class TextStatepublic void setSuperscript(boolean value)
Gets or sets superscript of the text, represented by the TextFragment object.
setSuperscript in class TextStatevalue - boolean valuepublic TabStops getTabStops()
Gets tabstops for the text.
TextFragment initialization. Tabstops must be constructed before the
text.
public float getLineSpacing()
Gets line spacing of the text.
getLineSpacing in class TextState
public void setLineSpacing(float value)
Sets line spacing of the text.
setLineSpacing in class TextStatevalue - float value
public Color getForegroundColor()
Gets foreground color of the text, represented by the TextFragment object
getForegroundColor in class TextStatepublic void setForegroundColor(Color value)
Sets foreground color of the text, represented by the TextFragment object
setForegroundColor in class TextStatevalue - Color objectpublic void setBackgroundColor(Color value)
Sets background color of the text, represented by the TextFragment object
setBackgroundColor in class TextStatevalue - Color objectpublic void setUnderline(boolean value)
Sets underline for the text, represented by the TextFragment object
setUnderline in class TextStatevalue - boolean valuepublic void setStrikeOut(boolean value)
Sets strikeout for the text, represented by the TextFragment object
setStrikeOut in class TextStatevalue - boolean valuepublic void setFontStyle(int value)
Sets font style of the text, represented by the TextFragment object
setFontStyle in class TextStatevalue - int valueFontStylespublic Font getFont()
Gets font of the text, represented by the TextFragment object
public void setFont(Font value)
Sets font of the text, represented by the TextFragment object
public float getFontSize()
Gets font size of the text, represented by the TextFragment object
getFontSize in class TextStatepublic void setFontSize(float value)
Sets font size of the text, represented by the TextFragment object
setFontSize in class TextStatevalue - float valuepublic int getHorizontalAlignment()
Gets horizontal alignment for the text.
getHorizontalAlignment in class TextStateHorizontalAlignmentpublic void setHorizontalAlignment(int value)
Sets horizontal alignment for the text.
setHorizontalAlignment in class TextStatevalue - HorizontalAlignment valueHorizontalAlignmentpublic double measureString(String str)
Measures the string.
measureString in class TextStatestr - The string.public void applyChangesFrom(TextState textState)
Applies settings from another textState
applyChangesFrom in class TextStatetextState - Text state object.
public void applyChangesFrom(TextState textState, boolean groupChangesOnly)
Applies settings from another textState
textState - Text state object.groupChangesOnly - if true inherit group changes only (without isolating the segments into single segment)Copyright © 2016 Aspose. All Rights Reserved.