Image Stamp

Introduction

The image stamp class  allows you to stamp PNG, JPEG and JPEG2000 images.

Create an Instance

An instance could be created by simply passing an image instance to its constructor: 

PHP
$image = SetaPDF_Core_Image::getByPath('files/pdfs/camtown/Logo.png');
$imageStamp = new SetaPDF_Stamper_Stamp_Image($image);

Configure Properties

Beside the general stamp properties the image stamp class offers following properties that allow you to define its dimensions: 

getDimensions()

Get the stamp dimension.

getHeight()

Get the height of the image stamp.

getWidth()

Get the width of the image stamp.

setDimensions()

Set the dimensions of this stamp.

setHeight()

Set the individual height if the image stamp.

setWidth()

Set the individual width of the image stamp.

Example

PHP
<?php
/**
 * Adds a users name and email into the bottom right corner
 */

require_once('library/SetaPDF/Autoload.php');

// create a writer
$writer = new SetaPDF_Core_Writer_Http('png.pdf', true);
// get a document instance
$document = SetaPDF_Core_Document::loadByFilename(
    'files/pdfs/Fact-Sheet-without-personalization.pdf', $writer
);

// create a stamper instance
$stamper = new SetaPDF_Stamper($document);

// get an image instance
$image = SetaPDF_Core_Image::getByPath('files/pdfs/camtown/Logo.png');
// initiate the stamp
$stamp = new SetaPDF_Stamper_Stamp_Image($image);
// set height (and width until no setWidth is set the ratio will retain)
$stamp->setHeight(23);

// add stamp to stamper on position left top for all pages with a specific translation
$stamper->addStamp($stamp, array(
    'translateX' => 43,
    'translateY' => -38
));

// stamp the document
$stamper->stamp();

// save and send it to the client
$document->save()->finish();