SetaPDF_Stamper_Stamp_Image The image stamp class

File: /SetaPDF v2/Stamper/Stamp/Image.php

To initiate an instance it's needed to pass an image instance of SetaPDF_Core_Image to the constructor:

$image = SetaPDF_Core_Image::getByPath('path/to/an/image.jpg');
$stamp = new SetaPDF_Stamper_Stamp_Image($image);

Class hierarchy

Summary

Constants

VISIBILITY_ALL

public const string SetaPDF_Stamper_Stamp::VISIBILITY_ALL = 'all'

Visibility constant

VISIBILITY_PRINT

public const string SetaPDF_Stamper_Stamp::VISIBILITY_PRINT = 'print'

Visibility constant

VISIBILITY_VIEW

public const string SetaPDF_Stamper_Stamp::VISIBILITY_VIEW = 'view'

Visibility constant


Properties

$_action

The currently attached action object

$_blendMode

protected string SetaPDF_Stamper_Stamp::$_blendMode = 'Normal'

The blend mode

$_cacheCounter

protected integer SetaPDF_Stamper_Stamp::$_cacheCounter = 0

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

$_dataCache

The cache data for the stamp

See

$_height

protected float|integer SetaPDF_Stamper_Stamp_Image::$_height

The individual height of the image

$_image

$_opacity

protected float SetaPDF_Stamper_Stamp::$_opacity = 1.0

The opacity

$_opacityGs

protected array SetaPDF_Stamper_Stamp::$_opacityGs = array()

Graphic state objects for handling transparency

Array of SetaPDF_Core_Resource_ExtGState objects

$_optionalContentGroup

An optional content groups that should be used for the stamp

$_visibility

protected string SetaPDF_Stamper_Stamp::$_visibility = 'all'

The visibility property

$_width

protected float|integer SetaPDF_Stamper_Stamp_Image::$_width

The individual width of the image

$_xObject

The XObject instance of the image


Methods

__construct()

The constructor.

Parameters
$image : SetaPDF_Core_Image

The image object

_cacheStampData()

protected SetaPDF_Stamper_Stamp::_cacheStampData (
$cacheKey, $stream, $quadPoints
): void

Caches a content stream part.

Parameters
$cacheKey
 
$stream
 
$quadPoints
 

_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
 

_getVisibilityGroup()

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

Parameters
$document : SetaPDF_Core_Document
 

_postStamp()

protected 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 SetaPDF_Stamper_Stamp::_preStamp (
SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData
): void

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 SetaPDF_Stamper_Stamp::_putAction (
SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData, $xy1, $xy2, $xy3, $xy4
): void

Put the action via an link annotation above the stamp object.

Parameters
$document : SetaPDF_Core_Document
 
$page : SetaPDF_Core_Document_Page
 
$stampData : array
 
$xy1
 
$xy2
 
$xy3
 
$xy4
 

_stamp()

protected SetaPDF_Stamper_Stamp_Image::_stamp (
SetaPDF_Core_Document $document, SetaPDF_Core_Document_Page $page, array $stampData
):

Writes the image draw operators of this stamp onto the canvas.

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

_stampByCache()

protected 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

cleanUp()

public SetaPDF_Stamper_Stamp_Image::cleanUp (
void
): void

Release resources / cycled references.

getAction()

public SetaPDF_Stamper_Stamp::getAction (
void
):

Get the current attached action.

getDimensions()

Get the stamp dimension.

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.

getImage()

Get the image.

getOpacity()

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()

Get the x-origin in view to the position of the stamp object.

Parameters
$page : SetaPDF_Core_Document_Page

The page instance

$position

Position constant SetaPDF_Stamper::POSITION_XXX

getOriginY()

Get the y-origin in view to the position of the stamp object.

Parameters
$page : SetaPDF_Core_Document_Page

The page instance

$position

Position constant SetaPDF_Stamper::POSITION_XXX

getVisibility()

Get the visibility of the stamp object.

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()

public SetaPDF_Stamper_Stamp_Image::setDimensions (
$width, $height
): void

Set the dimensions of this stamp.

Parameters
$width

The width

$height

The height

setHeight()

public SetaPDF_Stamper_Stamp_Image::setHeight (
$height
): void

Set the individual height if the image stamp.

Parameters
$height

The height

setImage()

Set the image.

Parameters
$image : SetaPDF_Core_Image

The image object

setLink()

public SetaPDF_Stamper_Stamp::setLink (
$uri
): void

Set a link onto the stamp.

Parameters
$uri

The link

See

setOpacity()

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

Set the opacity and blend mode of the stamp object.

Parameters
$alpha

A value between 0 and 1, whereas 1 is defined as 100% opacity

$blendMode

A blend mode defined in PDF 32000-1:2008 - 11.3.5, "Blend Mode"

Exceptions

Throws InvalidArgumentException

setOptionalContentGroup()

public SetaPDF_Stamper_Stamp::setOptionalContentGroup (
[ SetaPDF_Core_Document_OptionalContent_Group|null $optionalContentGroup = null ]
): void

Set the optional content group for this stamp.

Parameters
$optionalContentGroup : SetaPDF_Core_Document_OptionalContent_Group|null
 

setVisibility()

public SetaPDF_Stamper_Stamp::setVisibility (
$visibility
): void

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

Use the constants VISIBILITY_XXX or null(equal to VISIBILITY_ALL)

Exceptions

Throws InvalidArgumentException

setWidth()

public SetaPDF_Stamper_Stamp_Image::setWidth (
$width
): void

Set the individual width of the image stamp.

Parameters
$width

The width

stamp()

public 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.