I try to use the FPDI lib with Drupal to concatenate pdf together. I created a class to add a new pdf to fpdi :
class PdfGenerator
{
public function importPDF(&$fpdi, $file)
{
$pageCount = $fpdi->setSourceFile($file);
for ($p = 1; $p <= $pageCount; $p++) {
$tplidx = $fpdi->importPage($p);
$size = $fpdi->getTemplatesize($tplidx);
if ($size['w'] > $size['h']) {
$format = 'L';
} else {
$format = 'P';
}
$fpdi->addPage($format, array($size['w'], $size['h']));
$fpdi->useTemplate($tplidx);
}
}
}
and I call the importPDF method like this:
$pdf = new FPDI();
$pdf_path = 'path/to/pdf.pdf';
$pdfGenerator->importPDF($pdf,$pdf_path);
$pdf->Output('test.pdf','I');
But unfortunately I have this error :
Fatal error: Call to undefined method FPDI::_getrawstream() in [..]sites/all/libraries/fpdi/fpdi.php on line 473
Do you know the reason for this error ?
thank you in advance :)
I found the solution: I actually use HTML2PDF before FPDI to generate a PDF.
So when I use FPDI, the type of the fpdi object instantiate is TCPDF and not FPDF. And FPDI called a function of TCPDF which appears on the v6 of TCPDF.
The solution : I Downgraded FPDI to the version 1.3.3 to match to html2pdf (v5.0.002) And I took fpdf_tpl version 1.2.2 to match to the fpdi lib v1.3.3
And this works !