setasign\SetaPDF2\Stamper\Stamp
PdfStamp The PDF stamp class
File: /SetaPDF v2/Stamper/Stamp/PdfStamp.php
Old class name (alias):
\SetaPDF_Stamper_Stamp_Pdf
To initiate an instance it is needed to pass a document instance to the constructor. The second parameter could be used to set the page number of the page which will be used as the stamp appearance.
$document = \setasign\SetaPDF2\Core\Document::loadByFilename('path/to/document.pdf'); $stamp = new \setasign\SetaPDF2\Stamper\Stamp\Pdf($document, 2); // use page 2
Class hierarchy
Summary
Methods
- __construct()
- _cacheStampData()
- _ensureResources()
- _getOpacityGraphicState()
- _getPage()
- _getVisibilityGroup()
- _postStamp()
- _preStamp()
- _putAction()
- _stamp()
- _stampByCache()
- getAction()
- getBoundaryBox()
- getDimensions()
- getDocument()
- getHeight()
- getOpacity()
- getOpacityBlendMode()
- getOptionalContentGroup()
- getOriginX()
- getOriginY()
- getPageNumber()
- getVisibility()
- getWidth()
- getXObject()
- setAction()
- setBoundaryBox()
- setDimensions()
- setHeight()
- setLink()
- setOpacity()
- setOptionalContentGroup()
- setPageNumber()
- setVisibility()
- setWidth()
- stamp()
- updateCacheCounter()
Constants
VISIBILITY_ALL
Visibility constant
VISIBILITY_PRINT
Visibility constant
VISIBILITY_VIEW
Visibility constant
Properties
$_dataCache
$_document
The document instance
$_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
$_pageNumber
The page number
Methods
__construct()
int $pageNumber = 1,
string $boundaryBox = \setasign\SetaPDF2\Core\PageBoundaries::CROP_BOX
The constructor.
Parameters
- $filenameOrDocument : \setasign\SetaPDF2\Core\Document|string
Filename of the pdf or a document instance of the pdf
- $pageNumber : int
The page number for the page which should be used for the stamp appearance
- $boundaryBox : string
Use the boundary constants \setasign\SetaPDF2\Core\PageBoundaries::XXX_BOX
Exceptions
Throws \setasign\SetaPDF2\Core\Parser\CrossReferenceTable\Exception
_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
_getPage()
_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.
A page is internally converted into a xobject.
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 pdf page stamp.
If no individual height is given the height will be received from the page object. Also a defined individual width (if available) will be used to keep the aspect ratio.
Exceptions
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 pdf page stamp.
If no individual width is given the width will be received from the page object. Also a defined individual height (if available) will be used to keep the aspect ratio.
Exceptions
getXObject()
Get the form XObject from the page object.
Parameters
- $document : \setasign\SetaPDF2\Core\Document
The document instance
setAction()
Add an action object to the stamp object.
Parameters
- $action : \setasign\SetaPDF2\Core\Document\Action\Action
The action object
setBoundaryBox()
Set the boundary box of the imported page.
Parameters
- $boundaryBox : string
Use the boundary constants \setasign\SetaPDF2\Core\PageBoundaries::XXX_BOX
setDimensions()
Set the dimensions of this stamp.
Parameters
- $width : float|int
The new width
- $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
setPageNumber()
Set the page number for the page which should be used for the stamp appearance.
Parameters
- $pageNumber : int
The page number
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()
\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