I have fpdi and fpdf working in harmony to grab a user’s name and member id which get printed on a PDF when they download it. However, the next user that comes along gets the same PDF with their username printed on top of the first user’s info.
Is there a way to remove the template once a file has been downloaded? How do you ‘undo’ something that fpdi added to a pdf and restore it to its original state?
require_once('pdfing/fpdf.php');
require_once('pdfing/fpdi.php');
$theirname = $_SESSION["first_name"] ." ".$_SESSION["last_name"];
$theirmemberid = $_SESSION["member_id"];
$todaysdate = date("D M j G:i:s T Y");
$line1 = "Name: " .$theirname . " | Member ID:" . $theirmemberid . " | Date Downloaded: " . $todaysdate . "";
$galleyFile = "$file_dest";
$pdf =& new FPDI();
$pagecount = $pdf->setSourceFile($galleyFile);
//$pdf->SetAutoPageBreak(true, 0);
$pdf->addPage();
for ($n = 1; $n <= $pagecount; $n++) {
//Add the header
$pdf->SetFont('Arial', '', 8);
$w=$pdf->GetStringWidth($line1)+6;
$pdf->SetX((210-$w)/2);
$pdf->SetXY(10, 5);
$pdf->SetDrawColor(0,80,180);
$pdf->SetFillColor(200,220,255);
$pdf->SetTextColor(220,50,50);
$pdf->SetLineWidth(1);
$pdf->Cell($w,9,$line1,1,1,'C',true);
//$pdf->MultiCell(0, '', $line1 , 0 , '' , false);
//Import 1 page and set as a template
$tplidx = $pdf->ImportPage($n);
$size = $pdf->useTemplate($tplidx);
//Repeat for all pages in the pdf.
if ($n != $pagecount) {
$pdf->AddPage();
}
}
//$pdf->Output($galleyFile, 'F');
$pdf->Output($file_dest, 'D');