Skip to content

Instantly share code, notes, and snippets.

@twinge
Created March 19, 2010 20:02
Show Gist options
  • Save twinge/338111 to your computer and use it in GitHub Desktop.
Save twinge/338111 to your computer and use it in GitHub Desktop.
<?php
error_reporting(E_NONE);
require_once("SetaPDF_Stamper.php");
define('SetaPDF_STAMPER_FONTPATH', 'font/');
// Create a new instance of SetaPDF_Stamper with output method "Inline"
$stamper =& SetaPDF_Stamper::factory('I');
$fileio = array(
"in" => "/Users/josh/Desktop/week6.pdf",
"out" => "/Users/josh/Desktop/week6-marked.pdf",
"compression" => true
);
$stamper->addFile($fileio);
// Let's create the text stamp
// require the SetaPDF_TextStamp-class
require_once("SetaPDF_Stamp/SetaPDF_TextStamp.php");
// Initiate a new instance of text_stamp
$textstamp =& new SetaPDF_TextStamp();
// Set the text
$textstamp->setText("Josh Starcher");
// Set font definitions
$textstamp->setFont("Arial", "B", 110);
// Set text color to red
$textstamp->SetFontColor(255,0,0);
$textstamp->SetOutlineColor(255,0,0);
// Set the charspacing
$textstamp->setCharSpacing(15);
// Set the rendering mode
$textstamp->setRenderingMode(2);
// Set the opacity
$textstamp->setAlpha(0.35);
/**
* Now we assign the text stamp to our stamper
* - we define the position on the center and middle of a page (CM)
* - the stamp should appear on "all" pages
* - no translation of the x-axis nor the y-axis will be done
* - we rotate the stamp about 60 degree
*/
$stamper->setStamp($textstamp,"CM", "all", 0, 0, 60);
// Let's stamp!
$stamper->stampit();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment