http://www.fpdf.org/
http://fpdi.setasign.de/index.php?p=home
Extract both packages into the same folder.
Put the PDF you want to add text to in the same folder and call it test1.pdf
Create a new script in the same folder called demo.php and add the following code.
Code: Select all
define('FPDF_FONTPATH','font/');
require('fpdi.php');
class PDF extends fpdi
{
//Page header
function Header()
{
//Logo
//$this->Image('logo_pb.png',10,8,33);
//Arial bold 15
//$this->SetFont('Arial','B',15);
//Move to the right
//$this->Cell(80);
//Title
//$this->Cell(30,10,'Title',1,0,'C');
//Line break
//$this->Ln(20);
}
//Page footer
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
$this->Cell(0,10,'This document was downloaded at '.date("G:i T", time()).' on '.date("l F jS Y", time()).'. This document is only valid for 24 hours from this date.',0,0,'C');
}
}
$pdf= new PDF();
$pagecount = $pdf->setSourceFile("test1.pdf");
for ($i=1; $i <= $pagecount; $i++) {
$tplidx = $pdf->ImportPage(1);
$pdf->addPage();
$pdf->useTemplate($tplidx,0,0,0);
}
$pdf->Output("newpdf.pdf","I");
Uncomment the header function and change the image name to one that exists to add images!
Mark