com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class TextState

  • Direct Known Subclasses:
    TextFragmentState


    public class TextState
    extends Object

    Represents a text state of a text

    • Field Detail

      • TabTag

        public final String TabTag

        You can place this tag in text to declare tabulation.


        It has effect only in couple with TabStops.

        See Also:
        Constant Field Values
      • TabstopDefaultValue

        public final float TabstopDefaultValue

        Default value of tabulation in widths of space character of default font.

        See Also:
        Constant Field Values
    • Constructor Detail

      • TextState

        public TextState()

        Creates text state object.

      • TextState

        public TextState(double fontSize)

        Creates text state object with font size specification.

        Parameters:
        fontSize - Font size.
      • TextState

        public TextState(Color foregroundColor)

        Creates text state object with foreground color specification.

        Parameters:
        foregroundColor - Foreground color.
      • TextState

        public TextState(Color foregroundColor,
                 double fontSize)

        Creates text state object with foreground color and font size specification.

        Parameters:
        foregroundColor - Foreground color.
        fontSize - Font size.
      • TextState

        public TextState(String fontFamily)

        Creates text state object with font family specification.

        Parameters:
        fontFamily - Font family.
      • TextState

        public TextState(String fontFamily,
                 boolean bold,
                 boolean italic)

        Creates text state object with font family and font style specification.

        Parameters:
        fontFamily - Font family.
        bold - Bold font style.
        italic - Italic font style.
      • TextState

        public TextState(String fontFamily,
                 double fontSize)

        Creates text state object with font family and font size specification.

        Parameters:
        fontFamily - Font family.
        fontSize - Font size.
    • Method Detail

      • applyChangesFrom

        public void applyChangesFrom(TextState textState)

        Applies settings from another textState


        Only those properties will be copied that were changed explicitly.

        Parameters:
        textState - Text state object.
      • getCharacterSpacing

        public float getCharacterSpacing()

        Gets character spacing of the text.

        Returns:
        float value
      • setCharacterSpacing

        public void setCharacterSpacing(float value)

        Sets character spacing of the text.

        Parameters:
        value - float value
      • getLineSpacing

        public float getLineSpacing()

        Gets line spacing of the text.

        Returns:
        float value

        Note that the value is not preserved as a text characteristic within the document. The LineSpacing property getter works for an object in case it was explicitly set previously with LineSpacing setter for those object. The property is used by runtime in context of current generation/modification process.

      • setLineSpacing

        public void setLineSpacing(float value)

        Sets line spacing of the text.

        Parameters:
        value - float value

        Note that the value is not preserved as a text characteristic within the document. The LineSpacing property getter works for an object in case it was explicitly set previously with LineSpacing setter for those object. The property is used by runtime in context of current generation/modification process.

      • getHorizontalScaling

        public float getHorizontalScaling()

        Gets horizontal scaling of the text.

        Returns:
        float value
      • setHorizontalScaling

        public void setHorizontalScaling(float value)

        Sets horizontal scaling of the text.

        Parameters:
        value - float value
      • isSubscript

        public boolean isSubscript()

        Gets or sets subscript of the text.

        Returns:
        boolean value
      • setSubscript

        public void setSubscript(boolean value)

        Gets or sets subscript of the text.

        Parameters:
        value - boolean value
      • isSuperscript

        public boolean isSuperscript()

        Gets superscript of the text.

        Returns:
        boolean value
      • setSuperscript

        public void setSuperscript(boolean value)

        Sets superscript of the text.

        Parameters:
        value - boolean value
      • getWordSpacing

        public float getWordSpacing()

        Gets word spacing of the text.

        Returns:
        float value
      • setWordSpacing

        public void setWordSpacing(float value)

        Sets word spacing of the text.

        Parameters:
        value - float value
      • isInvisible

        public boolean isInvisible()

        Gets invisibility of the text.

        Returns:
        boolean value
      • setInvisible

        public void setInvisible(boolean value)

        Sets invisibility of the text.

        Parameters:
        value - boolean value
      • getFontSize

        public float getFontSize()

        Gets font size of the text.

        Returns:
        float value
      • setFontSize

        public void setFontSize(float value)

        Sets font size of the text.

        Parameters:
        value - float value
      • getFont

        public Font getFont()

        Gets font of the text.

        Returns:
        Font object
      • setFont

        public void setFont(Font value)

        Gets font of the text.

        Parameters:
        value - Font object
      • getForegroundColor

        public Color getForegroundColor()

        Gets foreground color of the text.

        Returns:
        Color value
      • setForegroundColor

        public void setForegroundColor(Color value)

        Sets foreground color of the text.

        Parameters:
        value - Color value
      • isUnderline

        public boolean isUnderline()

        Gets underline for the text, represented by the TextFragment object

        Returns:
        boolean value
      • setUnderline

        public void setUnderline(boolean value)

        Sets underline for the text, represented by the TextFragment object

        Parameters:
        value - boolean value
      • getStrikeOut

        public boolean getStrikeOut()

        Gets strikeout for the text, represented by the TextFragment object

        Returns:
        boolean value
      • setStrikeOut

        public void setStrikeOut(boolean value)

        Sets strikeout for the text, represented by the TextFragment object

        Parameters:
        value - boolean value
      • getBackgroundColor

        public Color getBackgroundColor()

        Gets background color of the text.


        Note that the value is not preserved as a text characteristic within the document. The BackgroundColor property getter works for an object in case it was explicitly set previously with BackgroundColor setter for those object. The property is used by runtime in context of current generation/modification process.

        Returns:
        Color value
      • setBackgroundColor

        public void setBackgroundColor(Color value)

        Sets background color of the text.


        Note that the value is not preserved as a text characteristic within the document. The BackgroundColor property getter works for an object in case it was explicitly set previously with BackgroundColor setter for those object. The property is used by runtime in context of current generation/modification process.

        Parameters:
        value - Color value
      • setFontStyle

        public void setFontStyle(int value)

        Sets font style of the text.

        Parameters:
        value - FontStyles value
        See Also:
        FontStyles
      • getHorizontalAlignment

        public int getHorizontalAlignment()

        Gets horizontal alignment for the text.


        HorizontalAlignment.None is equal to HorizontalAlignment.Left. Note that TextState.HorizontalAlignment property works in new document generation scenarios only.

        Returns:
        HorizontalAlignment value
        See Also:
        HorizontalAlignment
      • setHorizontalAlignment

        public void setHorizontalAlignment(int value)

        Sets horizontal alignment for the text.


        HorizontalAlignment.None is equal to HorizontalAlignment.Left. Note that TextState.HorizontalAlignment property works in new document generation scenarios only.

        Parameters:
        value - HorizontalAlignment value
        See Also:
        HorizontalAlignment
      • measureString

        public double measureString(String str)
        Measures the string.
        Parameters:
        str - The string.
        Returns:
        Width of the string represented with this text state.
      • calculateFontSize

        public double calculateFontSize(String str,
                               Rectangle rect)

        Calculates the font size for the rectangle.

        Parameters:
        str - String value
        rect - Rectangle object
        Returns:
        double value