SetaPDF_Core_Text_Block Class representing a text block which can be drawn onto a canvas object

File: /SetaPDF/Core/Text/Block.php

Class hierarchy

Summary

Properties

$_align

protected string SetaPDF_Core_Text_Block::$_align = 'left'

The text alignment

$_backgroundColor

$_borderColor

$_borderWidth

The border width

$_charSpacing

The character spacing value

$_dataCache

protected array SetaPDF_Core_Text_Block::$_dataCache = array()

An array for caching calculation results

$_dataCacheClearCallback

A callback which is called if the internal data cache is cleared

$_encoding

protected string SetaPDF_Core_Text_Block::$_encoding = 'UTF-8'

The encoding of the text

$_font

The font to use

$_fontSize

protected float|integer SetaPDF_Core_Text_Block::$_fontSize = 12

The font size

$_internalText

The text string in UTF-16BE encoding for internal usage

$_lineHeight

protected null|number SetaPDF_Core_Text_Block::$_lineHeight

The line height

$_outlineColor

The color of the text outline

$_outlineWidth

protected number SetaPDF_Core_Text_Block::$_outlineWidth = 1.0

The outline width

$_paddingBottom

Padding bottom value

$_paddingLeft

Padding left value

$_paddingRight

Padding right value

$_paddingTop

Padding top value

$_renderingMode

The rendering mode

$_text

protected string SetaPDF_Core_Text_Block::$_text

The text in user defined encoding

$_textColor

$_width

protected number SetaPDF_Core_Text_Block::$_width

A specific width of this text stamp

$_wordSpacing

Word spacing value


Methods

__construct()

public SetaPDF_Core_Text_Block::__construct ( SetaPDF_Core_Font $font [, number $fontSize = null ] )

The constructor.

Parameters
$font : SetaPDF_Core_Font
 
$fontSize : number
 

_clearDataCache()

protected void SetaPDF_Core_Text_Block::_clearDataCache ( void )

Clears the internal data cache.

_drawBorderAndBackground()

protected void SetaPDF_Core_Text_Block::_drawBorderAndBackground ( SetaPDF_Core_Canvas $canvas, number $x, number $y )

Draws the border and background onto the canvas.

Parameters
$canvas : SetaPDF_Core_Canvas
 
$x : number

The lower left x-value of the text block

$y : number

The lower left y-value of the text block

_drawRenderingMode()

Adds rendering mode specific data onto the canvas.

Parameters
$canvas : SetaPDF_Core_Canvas
 

_drawText()

protected void SetaPDF_Core_Text_Block::_drawText ( SetaPDF_Core_Canvas $canvas, number $x, number $y )

Draws the text onto the canvas.

Parameters
$canvas : SetaPDF_Core_Canvas
 
$x : number

The lower left x-value of the text block

$y : number

The lower left y-value of the text block

_fixX()

protected number SetaPDF_Core_Text_Block::_fixX ( number $x )

Get the correct x-value for the text string to start writing.

Parameters
$x : number
 

_fixY()

protected number SetaPDF_Core_Text_Block::_fixY ( number $y )

Get the correct y-value for the text string to start writing.

Parameters
$y : number
 

_getLines()

protected array SetaPDF_Core_Text_Block::_getLines ( void )

Get the text as lines and caches the result.

_getTextWidth()

private int|mixed SetaPDF_Core_Text_Block::_getTextWidth ( $fontSize $fontSize, array $lines )

Get the text width by an array of text lines.

Parameters
$fontSize : $fontSize
 
$lines : array
 

cleanUp()

public void SetaPDF_Core_Text_Block::cleanUp ( void )

Release resources / cycled references.

draw()

public void SetaPDF_Core_Text_Block::draw ( SetaPDF_Core_Canvas $canvas, number $x, number $y )

Draws the text block onto a canvas.

Parameters
$canvas : SetaPDF_Core_Canvas
 
$x : number

The lower left x-value of the text block

$y : number

The lower left y-value of the text block

getAlign()

public string SetaPDF_Core_Text_Block::getAlign ( void )

Get the text alignment.

getBackgroundColor()

Get the background color object.

getBorderColor()

Get the border color object.

If no border color is defined the a greyscale black color will be returned.

getBorderWidth()

public number SetaPDF_Core_Text_Block::getBorderWidth ( void )

Get the border width.

getCharSpacing()

public number SetaPDF_Core_Text_Block::getCharSpacing ( void )

Get the character spacing value.

getFont()

Get the font object.

getFontSize()

public number SetaPDF_Core_Text_Block::getFontSize ( void )

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()

public number SetaPDF_Core_Text_Block::getHeight ( void )

Get the height of this text block.

Calculation is done by number of lines, line-height and top and bottom padding values.

See

getLineCount()

public integer SetaPDF_Core_Text_Block::getLineCount ( void )

Get the line count of the text block.

getLineHeight()

public number SetaPDF_Core_Text_Block::getLineHeight ( void )

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 the 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.

getPaddingBottom()

Get the bottom padding.

getPaddingLeft()

public number SetaPDF_Core_Text_Block::getPaddingLeft ( void )

Get the left padding.

getPaddingRight()

Get the right padding.

getPaddingTop()

public number SetaPDF_Core_Text_Block::getPaddingTop ( void )

Get the top padding.

getRenderingMode()

Get the defined rendering mode.

See

getText()

public string SetaPDF_Core_Text_Block::getText ( [ string $encoding = 'UTF-8' ] )

Get the text.

Parameters
$encoding : string
 

getTextColor()

Get the text color object.

If no text color is defined the a greyscale black color will be returned

getTextHeight()

public number SetaPDF_Core_Text_Block::getTextHeight ( void )

Get the height of the text.

getTextWidth()

public number SetaPDF_Core_Text_Block::getTextWidth ( void )

Get the width of the longest text line.

getWidth()

public number SetaPDF_Core_Text_Block::getWidth ( void )

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.

The value set in setWidth() may be differ to the one returned by this method because of padding values.

getWordSpacing()

public number SetaPDF_Core_Text_Block::getWordSpacing ( void )

Get the word spacing value.

setAlign()

public void SetaPDF_Core_Text_Block::setAlign ( string $align )

Set the text alignment.

Parameters
$align : string
 

setBackgroundColor()

setBorderWidth()

public void SetaPDF_Core_Text_Block::setBorderWidth ( number $borderWidth )

Set the border width.

Parameters
$borderWidth : number
 

setCharSpacing()

public void SetaPDF_Core_Text_Block::setCharSpacing ( number $charSpacing )

Set the character spacing value.

Parameters
$charSpacing : number
 

setDataCacheClearCallback()

public void SetaPDF_Core_Text_Block::setDataCacheClearCallback ( callback $callback )

Sets a callback function which is called if the internal cache is cleared.

Parameters
$callback : callback
 

setFont()

public void SetaPDF_Core_Text_Block::setFont ( SetaPDF_Core_Font $font [, number $fontSize = null ] )

Set the font object and size.

Parameters
$font : SetaPDF_Core_Font
 
$fontSize : number
 

setFontSize()

public void SetaPDF_Core_Text_Block::setFontSize ( number $fontSize )

Set the font size.

If -1 is passed the font size is calculated based on the available width and the text content.

Parameters
$fontSize : number
 

setLineHeight()

public void SetaPDF_Core_Text_Block::setLineHeight ( float|integer|null $lineHeight )

Set the line height / leading.

Parameters
$lineHeight : float|integer|null
 

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|number
 
See

setOutlineWidth()

public void SetaPDF_Core_Text_Block::setOutlineWidth ( float $outlineWidth )

Set the outline width.

The outline width is only used at specific rendering modes.

Parameters
$outlineWidth : float
 

setPadding()

public void SetaPDF_Core_Text_Block::setPadding ( number $padding )

Set the padding.

Parameters
$padding : number
 

setPaddingBottom()

public void SetaPDF_Core_Text_Block::setPaddingBottom ( number $paddingBottom )

Set the bottom padding.

Parameters
$paddingBottom : number
 

setPaddingLeft()

public void SetaPDF_Core_Text_Block::setPaddingLeft ( number $paddingLeft )

Set the left padding.

Parameters
$paddingLeft : number
 

setPaddingRight()

public void SetaPDF_Core_Text_Block::setPaddingRight ( number $paddingRight )

Set the right padding.

Parameters
$paddingRight : number
 

setPaddingTop()

public void SetaPDF_Core_Text_Block::setPaddingTop ( number $paddingTop )

Set the top padding.

Parameters
$paddingTop : number
 

setRenderingMode()

public void SetaPDF_Core_Text_Block::setRenderingMode ( [ integer $renderingMode = 0 ] )

Set the rendering mode.

Parameters
$renderingMode : integer
 
See

setText()

public void SetaPDF_Core_Text_Block::setText ( string $text [, string $encoding = 'UTF-8' ] )

Set the text.

Parameters
$text : string
 
$encoding : string

The encoding of $text

setWidth()

public void SetaPDF_Core_Text_Block::setWidth ( number $width )

Set the width of the text block.

Parameters
$width : number
 

setWordSpacing()

public void SetaPDF_Core_Text_Block::setWordSpacing ( number $wordSpacing )

Set the word spacing value.

Parameters
$wordSpacing : number