Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Add a watermark to a multi-page PDF (a-la Pragmatic Programmers) (See related posts)

This adds a text watermark to every page of a PDF document, as used by Pragmatic Programmers. Nothing secret here, more of a way to excercise "human" DRM. Used as:

   perl makepdf.pl "John Doe"


use PDF::Reuse;
use PDF::Reuse::Util;
use strict;

my ($name) = @ARGV;

prFile('book_for_someone.pdf');

my $sourcePdf = 'pdf_that_your_designer_made.pdf';
my $greeting = "This book is personalized for " . $name;

my $left = 1;
while ($left) {
   prFont('HO');
   prAdd("0 0 0 rg\n0 g\nf\n");
   prText( 38, 800, $greeting);
   $left = prSinglePage($sourcePdf);   
} 

prEnd;

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts