setasign\SetaPDF2\Stamper\Stamp
ImageStamp The image stamp class
File: /SetaPDF v2/Stamper/Stamp/ImageStamp.php
Old class name (alias):
\SetaPDF_Stamper_Stamp_Image
To initiate an instance it's needed to pass an image instance of \setasign\SetaPDF2\Core\Image\Image to the constructor:
$image = \SetaPDF_Core_Image::getByPath('path/to/an/image.jpg'); $stamp = new \SetaPDF_Stamper_Stamp_Image($image);
Class hierarchy
Summary
Methods
- __construct()
- _cacheStampData()
- _ensureResources()
- _getOpacityGraphicState()
- _getVisibilityGroup()
- _postStamp()
- _preStamp()
- _putAction()
- _stamp()
- _stampByCache()
- cleanUp()
- getAction()
- getDimensions()
- getHeight()
- getImage()
- getOpacity()
- getOpacityBlendMode()
- getOptionalContentGroup()
- getOriginX()
- getOriginY()
- getVisibility()
- getWidth()
- getXObject()
- setAction()
- setDimensions()
- setHeight()
- setImage()
- setLink()
- setOpacity()
- setOptionalContentGroup()
- setVisibility()
- setWidth()
- stamp()
- updateCacheCounter()
Constants
VISIBILITY_ALL
Visibility constant
VISIBILITY_PRINT
Visibility constant
VISIBILITY_VIEW
Visibility constant
Properties
$_action
The currently attached action object
$_dataCache
$_height
The individual height of the image
$_image
The image instance
$_opacityGs
Graphic state objects for handling transparency
Array of \setasign\SetaPDF2\Core\Resource\ExtGState objects
$_width
The individual width of the image
$_xObject
The XObject instance 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 : \SetaPDF_Core_Document
- $page : \SetaPDF_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 : \SetaPDF_Core_Document
- $opacity : float
_getVisibilityGroup()
Get and adds the visibility group of this stamp to a document.
Parameters
- $document : \SetaPDF_Core_Document
Exceptions
_postStamp()
Method which is called after the main stamp method is executed.
Parameters
- $document : \SetaPDF_Core_Document
- $page : \SetaPDF_Core_Document_Page
- $stampData : array
Exceptions
_preStamp()
Method which is called before the main stamp method is executed.
Parameters
- $document : \SetaPDF_Core_Document
- $page : \SetaPDF_Core_Document_Page
- $stampData : array
Exceptions
_putAction()
\SetaPDF_Core_Document_Page $page,
array $stampData,
number $xy1,
number $xy2,
number $xy3,
number $xy4
Put the action via an link annotation above the stamp object.
Parameters
- $document : \SetaPDF_Core_Document
- $page : \SetaPDF_Core_Document_Page
- $stampData : array
- $xy1 : number
- $xy2 : number
- $xy3 : number
- $xy4 : number
Exceptions
_stamp()
Writes the image draw operators of this stamp onto the canvas.
Parameters
- $document : \SetaPDF_Core_Document
- $page : \SetaPDF_Core_Document_Page
- $stampData : array
_stampByCache()
Try to stamp with the page with a cached content stream part.
Parameters
- $document : \SetaPDF_Core_Document
- $page : \SetaPDF_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 image stamp.
If no individual height is given the height will be received from the image 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 : \SetaPDF_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 : \SetaPDF_Core_Document_Page
The page instance
- $position : string
Position constant \setasign\SetaPDF2\Stamper\Stamper::POSITION_XXX
Exceptions
getWidth()
Get the width of the image stamp.
If no individual width is given the width will be received from the image object by forwarding an individual height (if available) to keep the aspect ratio.
getXObject()
Get the XObject from the image object.
Parameters
- $document : \SetaPDF_Core_Document
The document instance
setAction()
Add an action object to the stamp object.
Parameters
- $action : \SetaPDF_Core_Document_Action
The action object
setDimensions()
Set the dimensions of this stamp.
Parameters
- $width : float|int
The width
- $height : float|int
The height
setImage()
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 : ?\SetaPDF_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
stamp()
Stamp this stamp object onto a page.
Parameters
- $document : \SetaPDF_Core_Document
The document object
- $page : \SetaPDF_Core_Document_Page
The page object
- $stampData : array
The stampData array
Exceptions
Throws \setasign\SetaPDF2\Core\SecHandler\Exception