views:

40

answers:

2

Hey guys, the solutions for my schools' assignments all have waterstamps on the pdfs with our username on it. I was wondering if you guys know how to do something like that using php? Do they run a script prior to the download process?

Thanks

A: 

There is an excellent opensource php library http://www.tcpdf.org/ , I use it for all pdf generating tasks.

galymzhan
A: 

Although there are several very good PDF libs for PHP, if I were writing such a program I'd just shell out to run pdftk but you' still need to generate your watermark.

$tempfile=tempnam();
system("pdftk input_file.pdf background watermark.pdf output $tempfile dont_ask", $errcode);
if (!$errcode && $ih=fopen($tempfile, 'r')) {
    header('Content-Type: application/pdf');
    fpassthru($ih);
    fclose($ih);
} else {
    print "Whoops";
}
unlink($tempfile);
symcbean