Sry, hier das ganze als PHP-Code
Mein Code:
require_once ('include/fpdf/fpdf.php');
require_once ('include/fpdi/fpdi.php');
require_once ('include/fpdi/FPDI_Protection.php');
require_once ('include/personalizedPDF.php');
$pdf = new personalizedPDF ( );
if ($pdf->setPDFSource ( $path )) {
if (! $pdf->SetProtection ( array ('print' ), "passwort" )) {
$message .= "Es ist ein unbekannter Fehler ausgetreten!";
} else {
if (! $pdf->setPersonalize ( $personalizeText )) {
$message .= "Es ist ein unbekannter Fehler ausgetreten!";
$pdf->createPDF ();
$pdf->Output ( $req_file, 'D' );
}
}
}
##################################################################
personalizedPDF.php:
##################################################################
<?php
/**
* requires fpdf.php & fpdi.php
* creates PDF with a personalized text
*/
class personalizedPDF extends FPDI_Protection {
private $sourcefile;
private $personalize;
/**
* loads the Sourcefile
* @param $sourcefile
*/
function setPDFSource($sourcefile) {
if(!is_file($sourcefile)) return false;
else {
if(!file_exists($sourcefile)) return false;
}
$this->sourcefile = $sourcefile;
return true;
}
/**
* sets the Personalizable text for the PDF
* !!!funktioniert noch nicht!!!
* @param $personalize
*/
function setPersonalize($text) {
if(!is_null($text) && is_string($text)) {
$this->personalize = $text;
return true;
}
else return false;
}
/**
* creates a footer with the personalized text
* @param $personalize
*/
function Footer()
{
if(isset($this->personalize)) {
// Über dem unteren Seitenrand positionieren
$this->SetY(-10);
// Schriftart festlegen
$this->SetFont('Arial','I',8);
// Graue Schrift
$this->SetTextColor(200, 200, 200);
// Zentrierte Ausgabe der Seitenzahl
$this->Cell(0,10,$this->personalize);
}
}
/**
* creates the PDF
* if $this->personalize is set, it uses it
* now only portrait, change AddPage('P',..) for landscape
*/
function createPDF() {
$pagecount = $this->setSourceFile($this->sourcefile);
for ($i = 1; $i <= $pagecount; $i++) {
$tplidx = $this->ImportPage($i);
$s = $this->getTemplatesize($tplidx);
$this->AddPage('P', array($s['w'], $s['h']));
$this->useTemplate($tplidx);
}
}
}
?>
danke!
Robert