SetaPDF_Stamper_Stamp_Pdf The PDF stamp class

File: /SetaPDF/Stamper/Stamp/Pdf.php

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 = SetaPDF_Core_Document::loadByFilename('path/to/document.pdf');
$stamp = new SetaPDF_Stamper_Stamp_Pdf($document, 2); // use page 2

Class hierarchy

Summary

Properties

$_action

The currently attached action object

$_blendMode

protected string SetaPDF_Stamper_Stamp_Pdf::$_blendMode = 'Normal'

The blend mode

$_boundaryBox

protected string SetaPDF_Stamper_Stamp_Pdf::$_boundaryBox = 'CropBox'

The boundary box to use

$_cacheCounter

An internal used id for forcing a recreation if a property was changed

$_dataCache

The cache data for the stamp

See

$_document

$_height

protected float|integer SetaPDF_Stamper_Stamp_Pdf::$_height

The individual height of the page

$_opacity

protected float SetaPDF_Stamper_Stamp_Pdf::$_opacity = 1.0

The opacity

$_opacityGs

protected array Array of SetaPDF_Core_Resource_ExtGState objects SetaPDF_Stamper_Stamp_Pdf::$_opacityGs = array()

Graphic state objects for handling transparency

$_optionalContentGroup

An optional content groups that should be used for the stamp

$_pageNumber

The page number

$_visibility

protected string SetaPDF_Stamper_Stamp_Pdf::$_visibility = 'all'

The visibility property

$_width

protected float|integer SetaPDF_Stamper_Stamp_Pdf::$_width

The individual width of the page

$_xObject


Methods

__construct()

public SetaPDF_Stamper_Stamp_Pdf::__construct ( SetaPDF_Core_Document|string $filenameOrDocument [, integer $pageNumber = 1 [, string $boundaryBox = \SetaPDF_Core_PageBoundaries::CROP_BOX ]] )

The constructor.

Parameters
$filenameOrDocument : SetaPDF_Core_Document|string

Filename of the pdf or a document instance of the pdf

$pageNumber : integer

The page number for the page which should be used for the stamp appearance

$boundaryBox : string

Use the boundary constants SetaPDF_Core_PageBoundaries::XXX_BOX

_cacheStampData()

protected void SetaPDF_Stamper_Stamp::_cacheStampData ( string $cacheKey, 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

See

_getOpacityGraphicState()

Get and caches opacity graphic states.

Parameters
$document : SetaPDF_Core_Document
 
$opacity : float
 

_getPage()

Get the page object.

_getVisibilityGroup()

Get and adds the visibility group of this stamp to a document.

Parameters
$document : SetaPDF_Core_Document
 

_postStamp()

protected array|null SetaPDF_Stamper_Stamp::_postStamp ( SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData )

Method which is called after the main stamp method is executed.

Parameters
$document : SetaPDF_Core_Document
 
$page : SetaPDF_Core_Document_Page
 
$stampData : array
 

_preStamp()

protected void SetaPDF_Stamper_Stamp::_preStamp ( SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData )

Method which is called before the main stamp method is executed.

Parameters
$document : SetaPDF_Core_Document
 
$page : SetaPDF_Core_Document_Page
 
$stampData : array
 

_putAction()

protected void SetaPDF_Stamper_Stamp::_putAction ( SetaPDF_Core_Document $document, 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
 

_stamp()

protected bool SetaPDF_Stamper_Stamp_Pdf::_stamp ( SetaPDF_Core_Document $document, SetaPDF_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 : SetaPDF_Core_Document
 
$page : SetaPDF_Core_Document_Page
 
$stampData : array
 

_stampByCache()

protected true|string SetaPDF_Stamper_Stamp::_stampByCache ( SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData )

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 SetaPDF_Stamper_Exception

getAction()

Get the current attached action.

getBoundaryBox()

Get the current boundary box name.

getDimensions()

public array SetaPDF_Stamper_Stamp::getDimensions ( void )

Get the stamp dimension.

getDocument()

Get the document instance.

getHeight()

public float|integer SetaPDF_Stamper_Stamp_Pdf::getHeight ( void )

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.

getOpacity()

public number SetaPDF_Stamper_Stamp::getOpacity ( void )

Get the opacity.

getOpacityBlendMode()

Get the blend mode.

See
  • PDF 32000-1:2008 - 11.3.5, "Blend Mode"

getOptionalContentGroup()

Get the optional content group for this stamp.

getOriginX()

public float|int SetaPDF_Stamper_Stamp::getOriginX ( SetaPDF_Core_Document_Page $page, string $position )

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 SetaPDF_Stamper::POSITION_XXX

getOriginY()

public float|int SetaPDF_Stamper_Stamp::getOriginY ( SetaPDF_Core_Document_Page $page, string $position )

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 SetaPDF_Stamper::POSITION_XXX

getPageNumber()

Get the page number of the page that should be used for the stamp appearance.

getVisibility()

public null|string SetaPDF_Stamper_Stamp::getVisibility ( void )

Get the visibility of the stamp object.

getWidth()

public float|integer SetaPDF_Stamper_Stamp_Pdf::getWidth ( void )

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.

getXObject()

Get the form XObject from the page 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

setBoundaryBox()

public void SetaPDF_Stamper_Stamp_Pdf::setBoundaryBox ( string $boundaryBox )

Set the boundary box of the imported page.

Parameters
$boundaryBox : string

Use the boundary constants SetaPDF_Core_PageBoundaries::XXX_BOX

setDimensions()

public void SetaPDF_Stamper_Stamp_Pdf::setDimensions ( float|integer $width, float|integer $height )

Set the dimensions of this stamp.

Parameters
$width : float|integer

The new width

$height : float|integer

The new height

setHeight()

public void SetaPDF_Stamper_Stamp_Pdf::setHeight ( float|integer $height )

Set the individual height if the pdf page stamp.

Parameters
$height : float|integer

The new height

setLink()

public void SetaPDF_Stamper_Stamp::setLink ( string $uri )

Set a link onto the stamp.

Parameters
$uri : string

The link

See

setOpacity()

public void SetaPDF_Stamper_Stamp::setOpacity ( float $alpha [, string $blendMode = 'Normal' ] )

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|null
 

setPageNumber()

public void SetaPDF_Stamper_Stamp_Pdf::setPageNumber ( integer $pageNumber )

Set the page number for the page which should be used for the stamp appearance.

Parameters
$pageNumber : integer

The page number

setVisibility()

public void SetaPDF_Stamper_Stamp::setVisibility ( null|string $visibility )

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 : null|string

Use the constants VISIBILITY_XXX or null(equal to VISIBILITY_ALL)

Exceptions

Throws InvalidArgumentException

setWidth()

public void SetaPDF_Stamper_Stamp_Pdf::setWidth ( float|integer $width )

Set the individual width of the pdf page stamp.

Parameters
$width : float|integer

The new width

stamp()

public bool SetaPDF_Stamper_Stamp::stamp ( SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData )

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

updateCacheCounter()

Updates the cache counter.