TextAppearance Class
Contains appearance settings used to render text in a PDF document.
Declaration
public class TextAppearance extends JavaObject implements ICloneable
Remarks
The TextAppearance class specifies the font, font size, character spacing, word spacing, horizontal scaling, and fill used to draw text.
The following code snippet creates a free text annotation with custom metadata, formatting, and text appearance (font, spacing, scaling, and fill color of the annotation text):
static void createFreeTextAnnotation(Page page) {
FreeTextAnnotation annotation =
new FreeTextAnnotation(
new RectangleF(200, 520, 260, 220));
annotation.setTitle("John Smith");
annotation.setSubject("Editorial Review");
annotation.setContent("Update this section.");
annotation.setTextJustification(TextJustification.LEFT_JUSTIFIED);
annotation.setOpacity(0.5);
// Create a text appearance.
TextAppearance appearance = new TextAppearance();
appearance.setFont(new TextFont("Arial", TextFontStyle.ITALIC));
appearance.setFontSize(24);
appearance.setCharacterSpacing(4);
appearance.setWordSpacing(10);
appearance.setHorizontalScaling(100);
appearance.setFill(
Fill.createSolid(PdfColor.getRed())
);
annotation.setTextAppearance(appearance);
page.getAnnotations().add(annotation);
}
Refer to the following help topic for additional information: Free Text Annotations.
Implements
Inherited Members
Inheritance
TextAppearance()
Initializes a new instance of the TextAppearance class.
Declaration
public TextAppearance()
Methods
clone(DocumentCloneContext context) Method
Creates a copy of the current object.
Declaration
public TextAppearance clone(DocumentCloneContext context)
Parameters
| Name | Type | Description |
|---|---|---|
| context | DocumentCloneContext | The document clone context. |
Returns
| Type | Description |
|---|---|
TextAppearance |
A deep copy of the current object. |
deepClone() Method
Creates a deep copy of the current object.
Declaration
public TextAppearance deepClone()
Returns
| Type | Description |
|---|---|
TextAppearance |
A deep copy of the current object. |
getCharacterSpacing() Method
Returns the spacing between characters.
Declaration
public double getCharacterSpacing()
Returns
| Type | Description |
|---|---|
| double | The character spacing. |
getFill() Method
Returns the fill used to render text.
Declaration
public Fill getFill()
Returns
| Type | Description |
|---|---|
| Fill | The text fill. |
getFont() Method
Returns the font used to render text.
Declaration
public TextFont getFont()
Returns
| Type | Description |
|---|---|
| TextFont | The text font. |
getFontSize() Method
Returns the font size.
Declaration
public double getFontSize()
Returns
| Type | Description |
|---|---|
| double | The font size. |
getHorizontalScaling() Method
Returns the horizontal scaling applied to text.
Declaration
public double getHorizontalScaling()
Returns
| Type | Description |
|---|---|
| double | The horizontal scaling percentage. |
objectClone() Method
Creates a copy of the current object.
Declaration
public Object objectClone()
Returns
| Type | Description |
|---|---|
| Object | A copy of the current object. |
setCharacterSpacing(double value) Method
Sets the spacing between characters.
Declaration
public void setCharacterSpacing(double value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | double | The character spacing. |
setFill(Fill value) Method
Sets the fill used to render text.
Declaration
public void setFill(Fill value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Fill | The text fill. |
setFont(TextFont value) Method
Sets the font used to render text.
Declaration
public void setFont(TextFont value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | TextFont | The text font. |
setFontSize(double value) Method
Sets the font size.
Declaration
public void setFontSize(double value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | double | The font size. |
setHorizontalScaling(double value) Method
Sets the horizontal scaling applied to text.
Declaration
public void setHorizontalScaling(double value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | double | The horizontal scaling percentage. |