setasign\SetaPDF2\Core\Text
TextBlock Class representing a text block which can be drawn onto a canvas object
File: /SetaPDF v2/Core/Text/TextBlock.php
Old class name (alias):
\SetaPDF_Core_Text_Block
Class hierarchy
Summary
Methods
- __construct()
- _clearDataCache()
- _drawBorderAndBackground()
- _drawRenderingMode()
- _drawText()
- _fixX()
- _fixY()
- _getLines()
- _getManualLineBreaks()
- _getTextWidth()
- cleanUp()
- draw()
- getAlign()
- getBackgroundColor()
- getBorderColor()
- getBorderWidth()
- getCharSpacing()
- getFont()
- getFontSize()
- getHeight()
- getLineCount()
- getLineHeight()
- getOutlineColor()
- getOutlineWidth()
- getPaddingBottom()
- getPaddingLeft()
- getPaddingRight()
- getPaddingTop()
- getRenderingMode()
- getText()
- getTextColor()
- getTextHeight()
- getTextWidth()
- getUnderline()
- getUnderlineColor()
- getWidth()
- getWordSpacing()
- setAlign()
- setBackgroundColor()
- setBorderColor()
- setBorderWidth()
- setCharSpacing()
- setDataCacheClearCallback()
- setFont()
- setFontSize()
- setLineHeight()
- setOutlineColor()
- setOutlineWidth()
- setPadding()
- setPaddingBottom()
- setPaddingLeft()
- setPaddingRight()
- setPaddingTop()
- setRenderingMode()
- setText()
- setTextColor()
- setTextWidth()
- setUnderline()
- setUnderlineColor()
- setWidth()
- setWordSpacing()
Properties
- $_align
- $_backgroundColor
- $_borderColor
- $_borderWidth
- $_charSpacing
- $_dataCache
- $_dataCacheClearCallback
- $_encoding
- $_font
- $_fontSize
- $_internalText
- $_lineHeight
- $_outlineColor
- $_outlineWidth
- $_paddingBottom
- $_paddingLeft
- $_paddingRight
- $_paddingTop
- $_renderingMode
- $_text
- $_textColor
- $_underline
- $_underlineColor
- $_width
- $_wordSpacing
Properties
$_borderColor
The border color
$_dataCacheClearCallback
A callback which is called if the internal data cache is cleared
$_font
The font to use
$_lineHeight
The line height
$_outlineColor
The color of the text outline
$_textColor
The text color
$_underlineColor
The color of the text underline.
If the color is defined as null, we will use the text color instead.
Methods
__construct()
The constructor.
Parameters
- $font : \SetaPDF_Core_Font_FontInterface
- $fontSize : int|float
_drawBorderAndBackground()
Draws the border and background onto the canvas.
Parameters
- $canvas : \SetaPDF_Core_Canvas
- $x : int|float
The lower left x-value of the text block
- $y : int|float
The lower left y-value of the text block
_drawRenderingMode()
_drawText()
Draws the text onto the canvas.
Parameters
- $canvas : \SetaPDF_Core_Canvas
- $x : int|float
The lower left x-value of the text block
- $y : int|float
The lower left y-value of the text block
Exceptions
Throws \setasign\SetaPDF2\Core\Exception
Throws \setasign\SetaPDF2\Core\Font\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
_getTextWidth()
Get the text width by an array of text lines.
Parameters
- $fontSize : int|float
- $lines : array
draw()
Draws the text block onto a canvas.
Parameters
- $canvas : \SetaPDF_Core_Canvas
- $x : int|float
The lower left x-value of the text block
- $y : int|float
The lower left y-value of the text block
Exceptions
Throws \setasign\SetaPDF2\Core\Exception
Throws \setasign\SetaPDF2\Core\Font\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
Throws \setasign\SetaPDF2\Core\Type\IndirectReference\Exception
getBorderColor()
Get the border color object.
If no border color is defined a greyscale black color will be returned.
getFontSize()
Get the font size.
If the font size was initially set to -1 this method will calculate the font size based on the available width and the text content.
getHeight()
Get the height of this text block.
Calculation is done by number of lines, line-height and top and bottom padding values.
See
getLineHeight()
Get the line height / leading.
If no explicit line height is defined this method will return a line height based on the lly and ury values of the font bounding box.
getOutlineColor()
Get the texts outline color object.
If no outline color is defined a greyscale black color will be returned. The outline color is only used at specific rendering modes.
See
getOutlineWidth()
Get the outline width.
The outline width is only used at specific rendering modes.
getTextColor()
Get the text color object.
If no text color is defined a greyscale black color will be returned.
getUnderlineColor()
Get the underline color.
If no underline color is defined the text color is returned.
getWidth()
Get the width of the stamp object.
This method returns the complete width of the text block. To get only the width of the text use the getTextWidth() method.
setBackgroundColor()
Set the background color.
Parameters
- $color : \SetaPDF_Core_DataStructure_Color|\SetaPDF_Core_Type_Array|array|null|string|int|float
See
setBorderColor()
Set the border color.
Parameters
- $color : \SetaPDF_Core_DataStructure_Color|int|float|string|array|\SetaPDF_Core_Type_Array|null
See
setDataCacheClearCallback()
Sets a callback function which is called if the internal cache is cleared.
Parameters
- $callback : callback
setFont()
Set the font object and size.
Parameters
- $font : \SetaPDF_Core_Font_FontInterface
- $fontSize : int|float
setFontSize()
Set the font size.
If -1 is passed the font size is calculated based on the available width and the text content.
Parameters
- $fontSize : int|float
setOutlineColor()
Set the texts outline color.
Only used with a specific text rendering mode.
Parameters
- $color : \SetaPDF_Core_DataStructure_Color|\SetaPDF_Core_Type_Array|array
See
setOutlineWidth()
Set the outline width.
The outline width is only used at specific rendering modes.
Parameters
- $outlineWidth : float
setTextColor()
Set the text color.
Parameters
- $color : \SetaPDF_Core_DataStructure_Color|\SetaPDF_Core_Type_Array|array|string|null
See
setUnderline()
Set whether to draw an underline or not.
If you want an underline color that differs from the text color use setUnderlineColor().
Parameters
- $underline : bool
setUnderlineColor()
Set the underline color.
Parameters
- $color : \SetaPDF_Core_DataStructure_Color|\SetaPDF_Core_Type_Array|array|null
See
setWidth()
WARNING: This method is marked as deprecated!
Use setTextWidth() instead.
Parameters
- $width : int|float