SetaPDF_Core_Canvas A class representing a Canvas
File: /SetaPDF v2/Core/Canvas.php
Class hierarchy
Implements
Summary
Methods
- __construct()
- addCurrentTransformationMatrix()
- addResource()
- cleanUp()
- clear()
- draw()
- drawXObject()
- getCache()
- getContainer()
- getGraphicStateSync()
- getHeight()
- getResources()
- getStream()
- getStreamProxy()
- getUserSpaceXY()
- getWidth()
- graphicState()
- markedContent()
- normalizeRotation()
- normalizeRotationAndOrigin()
- path()
- restoreGraphicState()
- rotate()
- saveGraphicState()
- scale()
- setColor()
- setColorSpace()
- setGraphicState()
- setGraphicStateSync()
- setNonStrokingColor()
- setNonStrokingColorSpace()
- setResource()
- setStrokingColor()
- setStrokingColorSpace()
- skew()
- startCache()
- stopCache()
- text()
- toUserSpace()
- translate()
- write()
Constants
GS_SYNC_COLOR
GS_SYNC_CURRENT_TRANSFORMATION_MATRIX
GS_SYNC_TEXT
Properties
$_draw
Draw helper instance
$_path
Path helper instance
$_text
Text helper instance
Methods
__construct()
The constructor.
Parameters
- $canvasContainer : SetaPDF_Core_Canvas_ContainerInterface
The canvas container
addCurrentTransformationMatrix()
Add a transformation matrix to the matrix stack of the current graphic state.
Parameters
- $a : int|float
A
- $b : int|float
B
- $c : int|float
C
- $d : int|float
D
- $e : int|float
E
- $f : int|float
F
See
- PDF-Reference PDF 32000-1:2008 8.3.4 Transformation Matrices
addResource()
Add a resource to the pages/xobjects resources dictionary.
Parameters
- $type : string|SetaPDF_Core_Resource
The resource type (Font, XObject, ExtGState,...) or an implementation of
SetaPDF_Core_Resource
- $object : SetaPDF_Core_Resource|SetaPDF_Core_Type_IndirectObjectInterface
The resource to add
- $document : SetaPDF_Core_Document
The document instance
Return Values
The name of the added resource.
Exceptions
Throws InvalidArgumentException
cleanUp()
Release objects to free memory and cycled references.
After calling this method the instance of this object is unusable!
drawXObject()
Draw an external object.
If a form XObject instance is passed, it will be added to the resources automatically.
Parameters
- $name : string|SetaPDF_Core_XObject
The name or a form XObject instance.
Exceptions
Throws SetaPDF_Core_Type_Exception
Throws InvalidArgumentException
getGraphicStateSync()
Get the bitmask that defines which values should be synced with the graphic state object.
See
getResources()
Returns the resources dictionary or an entry of it.
If no resource dictionary exists it is possible to automatically create it and/or the desired entry.
Parameters
- $inherited : boolean
Check for a resources dictionary in parent nodes
- $create : boolean
Create dictionary/ies if they do not exists
- $entryKey : string
The entries key (Font, XObject,...)
Return Values
Returns the resources dictionary, a dictionary by an entry key or false if none was found.
Exceptions
Throws SetaPDF_Core_Type_Exception
getUserSpaceXY()
WARNING: This method is marked as deprecated!
Use toUserSpace() instead.
Returns the user space coordinates of the transformation matrix.
Parameters
- $x : int
x-coordinate
- $y : int
y-coordinate
Return Values
('x' => $x, 'y' => $y)
See
graphicState()
Return the graphic state object if no graphic state is defined an new instance will be initialized.
normalizeRotation()
Normalize the graphic state in view to an outer rotation (e.g. page rotation).
Parameters
- $rotation : number
- $box : SetaPDF_Core_DataStructure_Rectangle
normalizeRotationAndOrigin()
Normalize the graphic state in view to an outer rotation (e.g. page rotation) and shifted origin.
Parameters
- $rotation : number
- $box : SetaPDF_Core_DataStructure_Rectangle
restoreGraphicState()
Restore the last graphic state and pop all matrices of the current graphic state out of the matrix stack.
rotate()
Rotate the transformation matrix by $angle degrees at the origin defined by $x and $y.
Parameters
- $x : int|float
X-coordinate of rotation point
- $y : int|float
Y-coordinate of rotation point
- $angle : float
Angle to rotate in degrees
saveGraphicState()
Open a new graphic state and copy the entire graphic state onto the stack of the new graphic state.
scale()
Scale the transformation matrix by the factor $scaleX and $scaleY.
Parameters
- $scaleX : int|float
Scale factor on X
- $scaleY : int|float
Scale factor on Y
setColor()
Set the color.
Parameters
- $color : SetaPDF_Core_DataStructure_Color|int[]|int|string
The color
- $stroking : boolean
Do stroking?
setColorSpace()
Set the current color space.
Parameters
- $colorSpace : SetaPDF_Core_ColorSpace|SetaPDF_Core_Type_Name|string
The color space
- $stroking : bool
Do stroking?
setGraphicState()
Set a named graphic state.
Parameters
- $graphicState : SetaPDF_Core_Resource_ExtGState
The graphic state
- $document : SetaPDF_Core_Document
Exceptions
Throws InvalidArgumentException
setGraphicStateSync()
Set the bitmask defining, which values should be synced with the graphic state object.
Parameters
- $graphicStateSync : integer
setNonStrokingColor()
Set the non-stroking color.
Parameters
- $color : SetaPDF_Core_DataStructure_Color|int[]|int|string
The non-stroking color
setNonStrokingColorSpace()
Set the non-stroking color space.
Parameters
- $colorSpace : SetaPDF_Core_ColorSpace|SetaPDF_Core_Type_Name|string
The color space
setResource()
Set a resource for the canvas.
Parameters
- $type : string
The resource type (Font, XObject, ExtGState,...) or an implementation of
SetaPDF_Core_Resource
- $name : string
The name of the resource
- $object : SetaPDF_Core_Resource|SetaPDF_Core_Type_IndirectObjectInterface
- $document : SetaPDF_Core_Document
Exceptions
Throws InvalidArgumentException
setStrokingColor()
Set the stroking color.
Parameters
- $color : SetaPDF_Core_DataStructure_Color|int[]|int|string
The stroking color
setStrokingColorSpace()
Set the stroking color space.
Parameters
- $colorSpace : SetaPDF_Core_ColorSpace|SetaPDF_Core_Type_Name|string
The color space
skew()
Skew the transformation matrix.
Parameters
- $angleX : float
Angle to x-axis in degrees
- $angleY : float
Angle to y-axis in degrees
- $x : int
Points to stretch on x-axis
- $y : int
Point to stretch on y-axis
toUserSpace()
Returns the user space coordinates vector.
Parameters
- $vector : SetaPDF_Core_Geometry_Vector
translate()
Move the transformation matrix by $shiftX and $shiftY on x-axis and y-axis.
Parameters
- $shiftX : int|float
Points to move on x-axis
- $shiftY : int|float
Points to move on y-axis