Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Add A Watermark To A Multi-page PDF (a-la Pragmatic Programmers)

DZone's Guide to

Add A Watermark To A Multi-page PDF (a-la Pragmatic Programmers)

·
Free Resource
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;
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}