Package com.evopdf

Class TextElement


public class TextElement extends PageGraphicElement
Represents a text element to be added to a PDF page or template
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextElement(float x, float y, float width, float height, String text, PdfFont font)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, height and font.
    TextElement(float x, float y, float width, float height, String text, PdfFont font, RgbColor textColor)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, height, font and color.
    TextElement(float x, float y, float width, String text, PdfFont font)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width and font.
    TextElement(float x, float y, float width, String text, PdfFont font, RgbColor textColor)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, font and color.
    TextElement(float x, float y, String text, PdfFont font)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified font.
    TextElement(float x, float y, String text, PdfFont font, RgbColor textColor)
    Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified font and color.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Gets the additional spacing between characters
    boolean
    Gets the flag indicating if the font associated with this text element should be embedded in the generated PDF document
    float
    Gets the height of destination rectangle in PDF where this text element will be rendered
    float
    Gets the value that indicates the vertical distance between the baselines of adjacent lines of text
    boolean
    Gets the flag indicating if the text can be paginated to render many PDF pages if necessary
    boolean
    Gets the flag indicating if the text is in a RTL language
    void
    setCharacterSpacing(float characterSpacing)
    Sets the additional spacing between characters
    void
    setEmbedSysFont(boolean embedSysFont)
    Sets the flag indicating if the font associated with this text element should be embedded in the generated PDF document
    void
    setHeight(float height)
    Sets the height of destination rectangle in PDF where this text element will be rendered
    void
    setLineSpacing(float leading)
    Sets the value that indicates the vertical distance between the baselines of adjacent lines of text
    void
    setPaginate(boolean paginate)
    Sets the flag indicating if the text can be paginated to render many PDF pages if necessary
    void
    setRightToLeftLanguage(boolean rightToLeft)
    Sets the flag indicating if the text is in a RTL language
    void
    Sets the text to be written
    void
    Sets the horizontal alignment of the text rendered by this element in PDF
    void
    setTextAngle(float textAngle)
    Sets the angle to control text counter-clockwise direction.
    void
    Sets the font of the text rendered by this element in PDF
    void
    setTextRise(float textRise)
    Sets the distance to move the text baseline up or down from its default location.
    void
    Sets the vertical alignment of the text rendered by this element in PDF
    void
    setWidth(float width)
    Sets the width of destination rectangle in PDF where this text element will be rendered
    void
    setWordSpacing(float wordSpacing)
    Sets the additional spacing between words.
    void
    setX(float x)
    Sets the start X position of this element relative to the PDF elements container
    void
    setY(float y)
    Sets the start Y position of this element relative to the PDF elements container
    Gets the text to be written
    Gets the horizontal alignment of the text rendered by this element in PDF
    float
    Gets the angle to control text counter-clockwise direction
    Gets the font of the text rendered by this element in PDF
    float
    Gets the distance to move the text baseline up or down from its default location
    Gets the vertical alignment of the text rendered by this element in PDF
    float
    Gets the width of destination rectangle in PDF where this text element will be rendered
    float
    Gets the additional spacing between words
    float
    x()
    Gets the start X position of this element relative to the PDF elements container
    float
    y()
    Gets the start Y position of this element relative to the PDF elements container

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TextElement

      public TextElement(float x, float y, String text, PdfFont font)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified font. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
    • TextElement

      public TextElement(float x, float y, String text, PdfFont font, RgbColor textColor)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified font and color. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
      textColor - the text color
    • TextElement

      public TextElement(float x, float y, float width, String text, PdfFont font)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width and font. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      width - the width of the destination rectangle. Use a negative value allow text to flow freely in PDF page width
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
    • TextElement

      public TextElement(float x, float y, float width, float height, String text, PdfFont font)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, height and font. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height.
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      width - the width of the destination rectangle. Use a negative value allow text to flow freely in PDF page width
      height - the height of the destination rectangle. Use a negative value allow text to flow freely in PDF document
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
    • TextElement

      public TextElement(float x, float y, float width, String text, PdfFont font, RgbColor textColor)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, font and color. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      width - the width of the destination rectangle. Use a negative value allow text to flow freely in PDF page width
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
      textColor - the text color
    • TextElement

      public TextElement(float x, float y, float width, float height, String text, PdfFont font, RgbColor textColor)
      Constructs a paginable text element that will be rendered at the specified (x,y) position using the specified width, height, font and color. The height of the rendered text will be auto-determined. The width is the available width in page. The Unicode text is supported only for embedded true type fonts. A flag indicating if the font is embedded or not in PDF can be specified when the font is added to PDF document. If the text pagination is not allowed ( paginate() property is false ), the text will be written on current page, the rendered text height being limited by the available height on page. If the text pagination is allowed ( paginate() property is true ) and the text needs pagination (the auto-determined text height is bigger than the available space on page), all the text will be rendered using the necessary height
      Parameters:
      x - the start x coordinate where the text will be rendered
      y - the start y coordinate where the text
      width - the width of the destination rectangle. Use a negative value allow text to flow freely in PDF page width
      height - the height of the destination rectangle. Use a negative value allow text to flow freely in PDF document
      text - the text to be rendered
      font - the text font. The true type fonts must be embedded in PDF when it is added to the document in order to support Unicode texts
      textColor - the text color
  • Method Details

    • textAlign

      public HorizontalTextAlign textAlign()
      Gets the horizontal alignment of the text rendered by this element in PDF
      Returns:
      the horizontal alignment of the text rendered by this element in PDF
    • setTextAlign

      public void setTextAlign(HorizontalTextAlign textAlign)
      Sets the horizontal alignment of the text rendered by this element in PDF
      Parameters:
      textAlign - the horizontal alignment of the text rendered by this element in PDF
    • verticalTextAlign

      public VerticalTextAlign verticalTextAlign()
      Gets the vertical alignment of the text rendered by this element in PDF
      Returns:
      the vertical alignment of the text rendered by this element in PDF
    • setVerticalTextAlign

      public void setVerticalTextAlign(VerticalTextAlign verticalTextAlign)
      Sets the vertical alignment of the text rendered by this element in PDF
      Parameters:
      verticalTextAlign - the vertical alignment of the text rendered by this element in PDF
    • rightToLeftLanguage

      public boolean rightToLeftLanguage()
      Gets the flag indicating if the text is in a RTL language
      Returns:
      the flag value
    • setRightToLeftLanguage

      public void setRightToLeftLanguage(boolean rightToLeft)
      Sets the flag indicating if the text is in a RTL language
      Parameters:
      rightToLeft - the flag value to set
    • characterSpacing

      public float characterSpacing()
      Gets the additional spacing between characters
      Returns:
      the additional spacing between characters
    • setCharacterSpacing

      public void setCharacterSpacing(float characterSpacing)
      Sets the additional spacing between characters
      Parameters:
      characterSpacing - additional spacing between characters
    • wordSpacing

      public float wordSpacing()
      Gets the additional spacing between words
      Returns:
      the additional spacing between words
    • setWordSpacing

      public void setWordSpacing(float wordSpacing)
      Sets the additional spacing between words. The words separator is consider the space character with code 32
      Parameters:
      wordSpacing - the additional spacing between words
    • lineSpacing

      public float lineSpacing()
      Gets the value that indicates the vertical distance between the baselines of adjacent lines of text
      Returns:
      value that indicates the vertical distance between the baselines of adjacent lines of text
    • setLineSpacing

      public void setLineSpacing(float leading)
      Sets the value that indicates the vertical distance between the baselines of adjacent lines of text
      Parameters:
      leading - value that indicates the vertical distance between the baselines of adjacent lines of text
    • textAngle

      public float textAngle()
      Gets the angle to control text counter-clockwise direction
      Returns:
      the angle to control text counter-clockwise direction
    • setTextAngle

      public void setTextAngle(float textAngle)
      Sets the angle to control text counter-clockwise direction. The default value is 0
      Parameters:
      textAngle - the angle to control text counter-clockwise direction
    • textRise

      public float textRise()
      Gets the distance to move the text baseline up or down from its default location
      Returns:
      the distance to move the text baseline up or down from its default location
    • setTextRise

      public void setTextRise(float textRise)
      Sets the distance to move the text baseline up or down from its default location. Adjustments to the baseline are useful for drawing superscripts or subscripts. Positive values of text rise move the baseline up and creates a superscript text. Negative values of text rise move the baseline down and creates a subscript text
      Parameters:
      textRise - the distance to move the text baseline up or down from its default location
    • text

      public String text()
      Gets the text to be written
      Returns:
      the text to be written
    • setText

      public void setText(String text)
      Sets the text to be written
      Parameters:
      text - the text to be written
    • x

      public float x()
      Gets the start X position of this element relative to the PDF elements container
      Returns:
      the start X position of this element relative to the PDF elements container
    • setX

      public void setX(float x)
      Sets the start X position of this element relative to the PDF elements container
      Parameters:
      x - the start X position of this element relative to the PDF elements container
    • y

      public float y()
      Gets the start Y position of this element relative to the PDF elements container
      Returns:
      the start Y position of this element relative to the PDF elements container
    • setY

      public void setY(float y)
      Sets the start Y position of this element relative to the PDF elements container
      Parameters:
      y - the start Y position of this element relative to the PDF elements container
    • width

      public float width()
      Gets the width of destination rectangle in PDF where this text element will be rendered
      Returns:
      the width of destination rectangle in PDF where this text element will be rendered
    • setWidth

      public void setWidth(float width)
      Sets the width of destination rectangle in PDF where this text element will be rendered
      Parameters:
      width - the width of destination rectangle in PDF where this text element will be rendered
    • height

      public float height()
      Gets the height of destination rectangle in PDF where this text element will be rendered
      Returns:
      the height of destination rectangle in PDF where this text element will be rendered
    • setHeight

      public void setHeight(float height)
      Sets the height of destination rectangle in PDF where this text element will be rendered
      Parameters:
      height - the height of destination rectangle in PDF where this text element will be rendered
    • textFont

      public PdfFont textFont()
      Gets the font of the text rendered by this element in PDF
      Returns:
      the font of the text rendered by this element in PDF
    • setTextFont

      public void setTextFont(PdfFont pdfFont)
      Sets the font of the text rendered by this element in PDF
      Parameters:
      pdfFont - the font of the text rendered by this element in PDF
    • embedSysFont

      public boolean embedSysFont()
      Gets the flag indicating if the font associated with this text element should be embedded in the generated PDF document
      Returns:
      the flag indicating if the font associated with this text element should be embedded in the generated PDF document
    • setEmbedSysFont

      public void setEmbedSysFont(boolean embedSysFont)
      Sets the flag indicating if the font associated with this text element should be embedded in the generated PDF document
      Parameters:
      embedSysFont - the flag indicating if the font associated with this text element should be embedded in the generated PDF document
    • paginate

      public boolean paginate()
      Gets the flag indicating if the text can be paginated to render many PDF pages if necessary
      Returns:
      the flag value
    • setPaginate

      public void setPaginate(boolean paginate)
      Sets the flag indicating if the text can be paginated to render many PDF pages if necessary
      Parameters:
      paginate - the flag value to set