Manuals

 

SetaPDF_Stamper::setStamp()

Description

class SetaPDF_Stamper extends SetaPDF {
mixed setStamp ( &$stamp[, string $position='LT'[, mixed $showOnPage='all'[, float $translate_x=0[, float $translate_y=0[, float $rotation=0[, boolean $underlay=false[, mixed $callback=null]]]]]]] ) }

With this method you can add multiple stamp objects to the stamping process.

You can add one stamp object more than one time on different positions, pages and/or rotations.

Parameters

&$stamp

A reference to an instance of any stamp object.

$position

The position of a Stamp is defined by special tokens like LT, LM, and so on. The letters are defined as follows:

  • L: Left
  • C: Center
  • R: Right
  • T: Top
  • M: Middle
  • B: Bottom

These letters can be combined to tokens like LT = LeftTop, RB = RightBottom,...

$showOnPage

This parameter defines on which pages the stamp should appear.

Possible values are:

  • "all": on all pages
  • "odd": only on odd pages
  • "even": only on even pages
  • "first": only on the first page
  • "last": only on the last page
  • A one- or two-dimensional array which values represent the page numbers on which the stamp should appear.

Also it's possible to create your own functions/methods which will check if the current page should be stamped. The possible values are:

  • A callback functions name as a string
  • An array of 2 values: key 0: an object instance, key 1: the method to call
  • An array of 2 values: key 0: a class name (string), key 1: the static method to call (string)

The SetaPDF-Stamper API will call your given function/method with 2 parameter: "current page", "total number of pages in the document". The function/method should return true if the page should be stamped or false if it shouldn't.

So your function/method should look like this:

function shouldWeStamp($pageNo, $totalPageCount) {
    return true||false;
}

$translate_x

The $translate_x-parameter can be used to translate the position of the stamp on the x-axis. The input is done in points.

$translate_y

The $translate_y-parameter can be used to translate the position of the stamp on the y-axis. The input is done in points.

$rotation

The rotation in degrees.

Be informed that the API will do an automatic correction of the position if an area of a stamp will be translated outside the viewing area.

$underlay

This parameter let you define if the stamp should be layed above the existing content or under.

The default behaviour is to place them on top: false

$callback

A callback function or method which should be called before the stamp is written on a specific page.

The possible values are:

  • A callback functions name as a string
  • An array of 2 values: key 0: an object instance, key 1: the method to call
  • An array of 2 values: key 0: a class name (string), key 1: the static method to call (string)

The SetaPDF-Stamper API will call your given function/method with 3 parameter: "stamp properties" (a reference!), "current page", "total number of pages in the document". The function/method should return true if the stamp was changed.

So your function/method should look like this:

function adjustAlpha(&$stampProperties, $currentPageNo,
                            $pageCount) {
   // get the stamp object assigned in the first parameter of setStamp()
   $stamp =& $stampProperties['stamp'];
   // set the alpha/transparency in relation to the page count
   $stamp->alpha += 1/$pageCount;
   return true;
}

More examples will follow in the coming days.

Return value

True - if everything works as expected - an SetaPDF_Error object if an error occurs.