public static function add_template($pdf_name) { global $pdf; /* * Get the page sizes so we can load each page correctly * The only way to do this is to initilise and load the PDF, read the sizes and * then correctly initilise the class. */ $pdf_temp = new mPDF(); $pdf_temp->SetImportUse(); /* LOAD THE PDF FILE * Must be in Acrobat 4.0 (PDF v1.3) format. * See manual for more details * http://www.setasign.de/support/manuals/fpdi/fpdi/fpdi-setsourcefile/ */ $pagecount = $pdf_temp->SetSourceFile($pdf_name); /* CREATE A TEMPLATE FOR EACH PDF PAGE * See manual for more details * http://www.setasign.de/support/manuals/fpdi/fpdi/fpdi-importpage/ */ for ($i = 1; $i <= $pagecount; $i++) { $pdf_load[$i] = $pdf_temp->ImportPage($i); $pdf_template_size[$i] = $pdf_temp->useTemplate($pdf_load[$i]); } /* * Set the real object */ $pagecount = $pdf->SetSourceFile($pdf_name); for ($i = 1; $i <= $pagecount; $i++) { $pdf_load[$i] = $pdf->ImportPage($i); } return array('load' => $pdf_load, 'size' => $pdf_template_size); }