Im generating a PDF using FPDF which works fine, when certain conditions are met i want to be able to import an existing PDF (sometimes with multiple pages), what im finding though is the FPDI import is overwriting any existing FPDF page generation.
Here is some sample code
if($row['art'] <> '')
{
$datasubject = mysqli_query($link,"SELECT * from documents WHERE subject = 'Art'");
$rowsubject = mysqli_fetch_array($datasubject);
$pdf->AddPage("P","A4");
$pdf->SetY(30);
$pdf->cell(350,20,"Art Page",0,'C',false);
$pdf = new \setasign\Fpdi\Fpdi();
// set the source file
$pageCount = $pdf->setSourceFile("C:\\temp\\sourcedocuments\\Year 7\\art\\KS4 FINE ART KNOWLEDGE ORGANISER higher tier.pdf");
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$tplIdx = $pdf->importPage($pageNo);
// add a page
$pdf->AddPage();
$pdf->useTemplate($tplIdx, null, null, 210, 300, true);
// font and color selection
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(200, 0, 0);
}
}
Before it hits this "IF " statement FPDF creates a couple of static "Cover" pages but these are also overwritten by the imported document.