SetaPDF_Stamper The main class of the SetaPDF-Stamper Component

File: /SetaPDF v2/Stamper.php

Class hierarchy

Summary

Constants

PAGES_ALL

const string SetaPDF_Stamper::PAGES_ALL = 'all'

Page constant

PAGES_EVEN

const string SetaPDF_Stamper::PAGES_EVEN = 'even'

Page constant

PAGES_FIRST

const string SetaPDF_Stamper::PAGES_FIRST = 'first'

Page constant

PAGES_LAST

const string SetaPDF_Stamper::PAGES_LAST = 'last'

Page constant

PAGES_ODD

const string SetaPDF_Stamper::PAGES_ODD = 'odd'

Page constant

POSITION_CENTER_BOTTOM

const string SetaPDF_Stamper::POSITION_CENTER_BOTTOM = 'CB'

Position constant

POSITION_CENTER_MIDDLE

const string SetaPDF_Stamper::POSITION_CENTER_MIDDLE = 'CM'

Position constant

POSITION_CENTER_TOP

const string SetaPDF_Stamper::POSITION_CENTER_TOP = 'CT'

Position constant

POSITION_LEFT_BOTTOM

const string SetaPDF_Stamper::POSITION_LEFT_BOTTOM = 'LB'

Position constant

POSITION_LEFT_MIDDLE

const string SetaPDF_Stamper::POSITION_LEFT_MIDDLE = 'LM'

Position constant

POSITION_LEFT_TOP

const string SetaPDF_Stamper::POSITION_LEFT_TOP = 'LT'

Position constant

POSITION_RIGHT_BOTTOM

const string SetaPDF_Stamper::POSITION_RIGHT_BOTTOM = 'RB'

Position constant

POSITION_RIGHT_MIDDLE

const string SetaPDF_Stamper::POSITION_RIGHT_MIDDLE = 'RM'

Position constant

POSITION_RIGHT_TOP

const string SetaPDF_Stamper::POSITION_RIGHT_TOP = 'RT'

Position constant

VERSION

const string SetaPDF_Stamper::VERSION = '2.26.0.1122'

Version


Properties

$_currentStampData

protected array SetaPDF_Stamper::$_currentStampData

The currently handled stamp data.

$_document

protected SetaPDF_Core_Document SetaPDF_Stamper::$_document

Document which shall be stamped.

$_stampsData

protected array SetaPDF_Stamper::$_stampsData = array()

Array of all stamps.


Methods

__construct()

The constructor.

Parameters
$document : SetaPDF_Core_Document

The document instance

addStamp()

public SetaPDF_Stamper::addStamp (
SetaPDF_Stamper_Stamp $stamp [, string|array $positionOrConfig = self::POSITION_LEFT_TOP [, int|string|array|callback $showOnPage = self::PAGES_ALL [, int $translateX = 0 [, int $translateY = 0 [, float $rotation = 0.0 [, bool $underlay = false [, null|callback $callback = null ]]]]]]]
): void

Adds a stamp object to the stamper instance.

Parameters
$stamp : SetaPDF_Stamper_Stamp

Stamp object which shall be stamped on the document

$positionOrConfig : string|array

Position or array of configuration variables

$showOnPage : int|string|array|callback

The configuration defining on which pages the stamp shall be shown. Possible values are:

  • PAGES_XXX constant
  • Integer with the valid page number
  • String with the valid page number or the valid range (e.g. '10-12')
  • Array with all valid page numbers
  • Callback with the arguments (int $pageNumber, int $pageCount)

$translateX : int

Move the stamp on x-axis by $translateX

$translateY : int

Move the stamp on y-axis by $translateX

$rotation : float

Rotate the stamp by $rotation degrees

$underlay : bool

Defines whether the stamp should be place before or after the existing content

$callback : null|callback

Callback which will be called every time before the document will be stamped by this stamp if it's not returning true the stamp will not stamped on this run.

checkPositionParameter()

public SetaPDF_Stamper::checkPositionParameter (
string $position
): bool

Checks whether the position parameter is valid.

This method allows you to check a string value against all predefined position constants: SetaPDF_Stamper::POSITION_XXX.

Parameters
$position : string

The string value to check for validity

Return Values

It will return true on success otherwise it will throw an InvalidArgumentException exception.

Exceptions

Throws InvalidArgumentException

checkShowOnPageParameter()

public SetaPDF_Stamper::checkShowOnPageParameter (
int|string|array|callback $showOnPage
): bool

Checks whether the $showOnPage parameter is valid.

Parameters
$showOnPage : int|string|array|callback

The value to check

Exceptions

Throws InvalidArgumentException

cleanUp()

public SetaPDF_Stamper::cleanUp (
void
): void

Release objects to free memory and cycled references.

After calling this method the instance of this object is unusable.

getDocument()

Get the document which shall be stamped.

stamp()

public SetaPDF_Stamper::stamp (
void
): void

This method will stamp the complete document with all added stamps.

See

stampPageNo()

public SetaPDF_Stamper::stampPageNo (
integer $pageNumber
): bool

This method will only stamp the page $pageNumber with all added stamps.

Parameters
$pageNumber : integer

The number of the page which will be stamped

Exceptions

Throws InvalidArgumentException

See