• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Perl/PHP PDF Stamp Generation Questions

Turgrid

n00b
Joined
Oct 8, 2007
Messages
20
I am interested in creating a web based script that upon clicking a download button, an existing pdf is "stamped" with the user's name (as a copyright protection scheme) at the bottom of each page of the pdf. Any sort of watermark, add-text-to-buttom-of-each-page script should work.

I have found a script written in Perl that seems to fit the bill (http://search.cpan.org/dist/Text-PDF/), but as I am unfamiliar with Perl, I do not know how to implement it with the download button. I am thinking I could call the Perl script (pdfstamp.pl) somehow in php. How do I do this? The arguments of pdfstamp (part of linked Perl module) are
Code:
pdfstamp [-f font] [-l locx,locy] [-s size] infile string
Adds the given string to the infile .pdf file at the given location, font and
size.

    -f font     Font name from the standard fonts [Helvetica]
    -l locx,locy    Location in points from bottom left of page [0,0]
    -s size     Font size to print at             [11]
    -t ttfile   TrueType font file to use (instead of -f)
I believe I have installed the Perl module correctly using CPanel (address: /perl/usr/bin/pdfstamp.pl).

If this is a bad approach, is there a way to stamp pdfs easier in php? Thanks in advance for your assistance.
 
check out fpdi and fpdf
http://www.setasign.de/products/pdf-php-solutions/fpdi/
http://www.fpdf.org/

you can take an existing pdf document and just lay some text on top of it wherever you want.

i've pulled the following from a project of mine, though i haven't changed it in a while so i can't tell you exactly what everything does but it should be a start to at least give you the idea of how to use it.

Code:
$fpdi = new FPDI();

$fpdi->SetTitle('Your PDF Title');
$fpdi->SetAuthor('Author Name');

$fpdi->setMargins(0, 0, 0);
$fpdi->setSourceFile('/path/to/your.pdf');

// font and color
$fpdi->SetFont('Arial', '', 12);
$fpdi->SetTextColor(0, 0, 0);


for ($i = 1; $i <= NUM_PAGES; $i++) {
	$fpdi->AddPage();
	$tplIdx = $fpdi->importPage($i);
	$fpdi->useTemplate($tplIdx, 0, 0);

	$fpdi->Text($x, $y, 'Some text that will be overlaid');
}

echo $fpdi->fpdiOutput();
 
Thanks tim_m! I came across that and saw the PDF Stamper that they also offer on setasign and was turned away by the cost, not realizing you could do it manually using the free version as you suggest. Thanks.
 
Back
Top