Adds image watermarks to PDF files
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
pdfwatermarker Changed version to reconcile with https://github.com/mul14/pdf-waterm… Jun 4, 2016
tests Various fixes May 23, 2016
.gitignore Merge branch 'master' of git://github.com/mul14/pdf-watermarker into … Jun 4, 2016
.travis.yml bootstrap.php for phpunit was created May 21, 2016
README.md Various fixes May 23, 2016
build.sh -Updated Travis configuration Apr 18, 2015
composer.json Merge branch 'master' of git://github.com/mul14/pdf-watermarker into … Jun 4, 2016
createphpdocs.bat -Added ability to specify a page range for watermarking Feb 28, 2015
createphpdocsmarkdown.bat -Added ability to specify a page range for watermarking Feb 28, 2015
phpunit.xml

README.md

Build Status

PDF Watermarker

PDFWatermarker enables you to add an image as a watermark to existing PDF files. It uses FPDF that allows you to write PDF files and FPDI that allows you to import existing PDF documents into FPDF.

Using it, you can:

  • Use jpg and png ( with alpha channels ) files with a 96 DPI resolution
  • Easily position the watermark on the pages of the PDF file

Installation

  1. Place composer.phar in the folder you extracted the files to.

  2. Run php composer.phar install

  3. Include the files in your project.

<?php
require_once('pdfwatermarker/pdfwatermarker.php');
require_once('pdfwatermarker/pdfwatermark.php');

Usage

<?php

//Specify path to image. The image must have a 96 DPI resolution.
$watermark = new PDFWatermark('C:\myimage.png'); 

//Set the position
$watermark->setPosition('bottomleft');

//Place watermark behind original PDF content. Default behavior places it over the content.
$watermark->setAsBackground();

//Specify the path to the existing pdf, the path to the new pdf file, and the watermark object
$watermarker = new PDFWatermarker('C:\test.pdf','C:\output.pdf',$watermark); 

//Set page range. Use 1-based index.
$watermarker->setPageRange(1,5);
 
//Save the new PDF to its specified location
$watermarker->savePdf(); 
?>

Five positions can be used. 'center' is the default.

  • center
  • topleft
  • topright
  • bottomright
  • bottomleft

See the API Documentation for more details.

Support

Report bugs at https://github.com/binarystash/pdf-watermarker/issues.