setasign\SetaPDF2\Core\Canvas

Text A canvas helper class for text operators

File: /SetaPDF v2/Core/Canvas/Text.php
Old class name (alias): \SetaPDF_Core_Canvas_Text

Class hierarchy

Summary

Constants

RENDERING_MODE_CLIP

public const int Text::RENDERING_MODE_CLIP = 7

Rendering mode

RENDERING_MODE_FILL

public const int Text::RENDERING_MODE_FILL = 0

Rendering mode

RENDERING_MODE_FILL_AND_CLIP

public const int Text::RENDERING_MODE_FILL_AND_CLIP = 4

Rendering mode

RENDERING_MODE_FILL_AND_STROKE

public const int Text::RENDERING_MODE_FILL_AND_STROKE = 2

Rendering mode

RENDERING_MODE_FILL_STROKE_AND_CLIP

Rendering mode

RENDERING_MODE_INVISIBLE

public const int Text::RENDERING_MODE_INVISIBLE = 3

Rendering mode

RENDERING_MODE_STROKE

public const int Text::RENDERING_MODE_STROKE = 1

Rendering mode

RENDERING_MODE_STROKE_AND_CLIP

public const int Text::RENDERING_MODE_STROKE_AND_CLIP = 5

Rendering mode


Properties

$_canvas

The origin canvas object


Methods

__construct()

public Operators::__construct (
Canvas $canvas
)

The constructor.

Parameters
$canvas : Canvas
 

addCurrentTransformationMatrix()

public StandardOperators::addCurrentTransformationMatrix (
float|int $a,
float|int $b,
float|int $c,
float|int $d,
float|int $e,
float|int $f
): $this

Proxy method for adding a transformation matrix on the canvas.

Parameters
$a : float|int
 
$b : float|int
 
$c : float|int
 
$d : float|int
 
$e : float|int
 
$f : float|int
 
See

begin()

public Text::begin (
void
): Text

Begin a text object.

beginText()

WARNING: This method is marked as deprecated!

public Text::beginText (
void
): Text

Alias for begin()

See

cleanUp()

public Operators::cleanUp (
void
): void

Release objects to free memory and cycled references.

After calling this method the instance of this object is unusable!

draw()

public Operators::draw (
void
): Draw

Get the draw helper.

end()

public Text::end (
void
): Text

End a text object.

endText()

WARNING: This method is marked as deprecated!

public Text::endText (
void
): Text

Alias for end()

See

markedContent()

Get the marked content helper.

moveToNextLine()

public Text::moveToNextLine (
float $x,
float $y,
bool $setLeading = false
): Text

Move to the next line.

Parameters
$x : float
 
$y : float
 
$setLeading : bool
 

moveToNextLineAndShowText()

public Text::moveToNextLineAndShowText (
string|string[] $text,
float $wordSpacing = null,
float $charSpacing = null
): Text

Move to the next line and show text.

Parameters
$text : string|string[]
 
$wordSpacing : float
 
$charSpacing : float
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

moveToStartOfNextLine()

public Text::moveToStartOfNextLine (
void
): Text

Move to the start of the next line.

path()

public Operators::path (
void
): Path

Get the path helper.

restoreGraphicState()

Proxy method for restoring the graphic state on the canvas.

See

rotate()

public StandardOperators::rotate (
int|float $x,
int|float $y,
int|float $angle
): $this

Proxy method for rotating the transformation matrix on the canvas.

Parameters
$x : int|float

X-coordinate of rotation point

$y : int|float

Y-coordinate of rotation point

$angle : int|float

Angle to rotate in degrees

See

saveGraphicState()

Proxy method for saving the graphic state on the canvas.

See

scale()

public StandardOperators::scale (
int|float $scaleX,
int|float $scaleY
): $this

Proxy method for scaling the transformation matrix on the canvas.

Parameters
$scaleX : int|float

Scale factor on X

$scaleY : int|float

Scale factor on Y

See

setCharSpacing()

WARNING: This method is marked as deprecated!

public Text::setCharSpacing (
float $charSpacing = 0.0
): Text

Alias for setCharacterSpacing()

Parameters
$charSpacing : float
 
See

setCharacterSpacing()

public Text::setCharacterSpacing (
float $charSpacing = 0.0
): Text

Set the char spacing.

Parameters
$charSpacing : float
 

setColor()

public StandardOperators::setColor (
\setasign\SetaPDF2\Core\DataStructure\Color\AbstractColor|int[]|int|string $color,
bool $stroking = true
): $this

Proxy method for setting the color on the canvas.

Parameters
$color : \setasign\SetaPDF2\Core\DataStructure\Color\AbstractColor|int[]|int|string
 
$stroking : bool
 
See

setGraphicState()

Proxy method for setting a graphic state on the canvas.

Parameters
$graphicState : \setasign\SetaPDF2\Core\Resource\ExtGState
 
See

setLeading()

public Text::setLeading (
float $leading = 0.0
): Text

Set the leading.

Parameters
$leading : float
 

setNonStrokingColor()

Proxy method for setting the non-stroking color on the canvas.

Parameters
$color : \setasign\SetaPDF2\Core\DataStructure\Color\AbstractColor|int[]|int|string
 
See

setRenderingMode()

public Text::setRenderingMode (
int $renderingMode = 0
): Text

Set the rendering mode.

The available rendering modes are also available through class constants such as Text::RENDERING_MODE_CLIP.

Parameters
$renderingMode : int
 
See
  • PDF reference 32000-1:2008 9.3.6 Text Rendering Mode

setRise()

public Text::setRise (
float $rise = 0.0
): Text

Set text rise.

Parameters
$rise : float
 

setScaling()

public Text::setScaling (
float $scaling = 100.0
): Text

Set the horizontal scaling.

Parameters
$scaling : float
 

setStrokingColor()

Proxy method for setting the stroking color on the canvas.

Parameters
$color : \setasign\SetaPDF2\Core\DataStructure\Color\AbstractColor|int[]|int|string
 
See

setTextMatrix()

public Text::setTextMatrix (
float $a,
float $b,
float $c,
float $d,
float $e,
float $f
): Text

Set the text matrix.

Parameters
$a : float
 
$b : float
 
$c : float
 
$d : float
 
$e : float
 
$f : float
 

setTextRise()

WARNING: This method is marked as deprecated!

public Text::setTextRise (
float $textRise = 0.0
): Text

Alias for setRise()

Parameters
$textRise : float
 
See

setWordSpacing()

public Text::setWordSpacing (
float $wordSpacing = 0.0
): Text

Set the word spacing.

You shall notice that this word spacing property affects the character which is assigned to "\x20" of a font which uses a single byte encoding. When e.g. using subset fonts this setting will end in unwanted results.

Parameters
$wordSpacing : float
 

showText()

public Text::showText (
string|string[] $text
): Text

Show text.

Parameters
$text : string|string[]
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

showTextStrings()

public Text::showTextStrings (
array|string $textStrings
): Text

Shows text strings.

Parameters
$textStrings : array|string
 
Exceptions

Throws \setasign\SetaPDF2\Core\Exception

skew()

public StandardOperators::skew (
int|float $angleX,
int|float $angleY,
int|float $x = 0,
int|float $y = 0
): $this

Proxy method for skewing the transformation matrix on the canvas.

Parameters
$angleX : int|float

Angle to x-axis in degrees

$angleY : int|float

Angle to y-axis in degrees

$x : int|float

Points to stretch on x-axis

$y : int|float

Point to stretch on y-axis

See

text()

public Operators::text (
void
): Text

Get the text helper.

translate()

public StandardOperators::translate (
int|float $shiftX,
int|float $shiftY
): $this

Proxy method for moving the transformation matrix on the canvas.

Parameters
$shiftX : int|float

Points to move on x-axis

$shiftY : int|float

Points to move on y-axis

See