setasign\SetaPDF2\Stamper\Stamp
XObjectStamp The XObject stamp class
File: /SetaPDF v2/Stamper/Stamp/XObjectStamp.php
Old class name (alias):
\SetaPDF_Stamper_Stamp_XObject
This stamp class is able to use a \setasign\SetaPDF2\Core\XObject\XObject instance as its stamp appearance. XObjects could be images or so called form XObjects.
A form XObject is a PDF content stream that is a self-contained description of any sequence of graphics objects (including path objects, text objects and sampled images).
This stamp class allows you to stamp separately form XObjects or image XObjects. A form XObject could include for example drawing operations:
// Create a form XObject with the dimensions of 100 x 100 $xObject = \setasign\SetaPDF2\Core\XObject\Form::create($document, array(0, 0, 100, 100)); $canvas = $xObject->getCanvas(); $canvas->path()->setLineWidth(1); $canvas->draw() ->rect(0, 0, 100, 100) // Draw a rectangle into the form XObject ->circle(50, 50, 50); // Draw a circle into the form XObject $stamp = new \setasign\SetaPDF2\Stamper\Stamp\XObject($xObject);
Class hierarchy
Summary
Methods
- __construct()
- _cacheStampData()
- _ensureResources()
- _getOpacityGraphicState()
- _getVisibilityGroup()
- _postStamp()
- _preStamp()
- _putAction()
- _stamp()
- _stampByCache()
- cleanUp()
- getAction()
- getDimensions()
- getHeight()
- getOpacity()
- getOpacityBlendMode()
- getOptionalContentGroup()
- getOriginX()
- getOriginY()
- getVisibility()
- getWidth()
- getXObject()
- setAction()
- setDimensions()
- setHeight()
- setLink()
- setOpacity()
- setOptionalContentGroup()
- setVisibility()
- setWidth()
- setXObject()
- stamp()
- updateCacheCounter()
Constants
VISIBILITY_ALL
Visibility constant
VISIBILITY_PRINT
Visibility constant
VISIBILITY_VIEW
Visibility constant
Properties
$_dataCache
$_height
The individual height of the image
$_opacityGs
Graphic state objects for handling transparency
Array of \setasign\SetaPDF2\Core\Resource\ExtGState objects
$_optionalContentGroup
An optional content groups that should be used for the stamp
$_width
The individual width of the image
Methods
__construct()
_cacheStampData()
string $stream,
array $quadPoints
Caches a content stream part.
Parameters
- $cacheKey : string
- $stream : string
- $quadPoints : array
_ensureResources()
Ensures that all stamp resources are added to the page.
This is needed to reuse a cached stamp stream.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
Return Values
An array of resource names
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
Throws \setasign\SetaPDF2\Core\Type\Exception
See
_getOpacityGraphicState()
Get and caches opacity graphic states.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $opacity : float
_getVisibilityGroup()
Get and adds the visibility group of this stamp to a document.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
Exceptions
_postStamp()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData
Method which is called after the main stamp method is executed.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
- $stampData : array
Exceptions
_preStamp()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData
Method which is called before the main stamp method is executed.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
- $stampData : array
Exceptions
_putAction()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData,
array{x: number, y: number} $xy1,
array{x: number, y: number} $xy2,
array{x: number, y: number} $xy3,
array{x: number, y: number} $xy4
Put the action via an link annotation above the stamp object.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
- $stampData : array
- $xy1 : array{x: number, y: number}
- $xy2 : array{x: number, y: number}
- $xy3 : array{x: number, y: number}
- $xy4 : array{x: number, y: number}
Exceptions
_stamp()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData
Writes the xobject draw operators of this stamp onto the canvas.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
- $stampData : array
Exceptions
_stampByCache()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData
Try to stamp with the page with a cached content stream part.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
- $page : \setasign\SetaPDF2\Core\Document\Page
- $stampData : array
Return Values
True if the stamp was written by a cache object, a cache key if it was not found
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception
getHeight()
Get the height of the XObject stamp.
If no individual height is given the height will be received from the XObject object by forwarding an individual width (if available) to keep the aspect ratio.
getOptionalContentGroup()
Get the optional content group for this stamp.
getOriginX()
Get the x-origin in view to the position of the stamp object.
Parameters
- $page : \setasign\SetaPDF2\Core\Document\Page
The page instance
- $position : string
Position constant \setasign\SetaPDF2\Stamper\Stamper::POSITION_XXX
Exceptions
getOriginY()
Get the y-origin in view to the position of the stamp object.
Parameters
- $page : \setasign\SetaPDF2\Core\Document\Page
The page instance
- $position : string
Position constant \setasign\SetaPDF2\Stamper\Stamper::POSITION_XXX
Exceptions
getWidth()
Get the width of the XObject stamp.
If no individual width is given the width will be received from the XObject object by forwarding an individual height (if available) to keep the aspect ratio.
setAction()
Add an action object to the stamp object.
Parameters
- $action : \setasign\SetaPDF2\Core\Document\Action\Action
The action object
setDimensions()
Set the dimensions of this stamp.
Parameters
- $width : float|int
The new width
- $height : float|int
The new height
setHeight()
Set the individual height if the XObject stamp.
Parameters
- $height : float|int
The new height
setLink()
Set a link onto the stamp.
Parameters
- $uri : string
The link
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception
See
setOpacity()
Set the opacity and blend mode of the stamp object.
Parameters
- $alpha : float
A value between 0 and 1, whereas 1 is defined as 100% opacity
- $blendMode : string
A blend mode defined in PDF 32000-1:2008 - 11.3.5, "Blend Mode"
Exceptions
Throws \InvalidArgumentException
setOptionalContentGroup()
Set the optional content group for this stamp.
Parameters
- $optionalContentGroup : ?\setasign\SetaPDF2\Core\Document\OptionalContent\Group
setVisibility()
Set the visibility of the stamp object.
This method controls the visibility of the stamp object on screen view and/or printer output.
Parameters
- $visibility : ?string
Use the constants VISIBILITY_XXX or null(equal to VISIBILITY_ALL)
Exceptions
Throws \InvalidArgumentException
setXObject()
Set the XObject.
Parameters
- $xObject : \setasign\SetaPDF2\Core\XObject\XObject
The new xobject instance
stamp()
\setasign\SetaPDF2\Core\Document\Page $page,
array $stampData
Stamp this stamp object onto a page.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
The document object
- $page : \setasign\SetaPDF2\Core\Document\Page
The page object
- $stampData : array
The stampData array
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception