I have the following code which downloads a PDF and I am trying to add some more pages from another PDF, after the current one:
$html = 'THIS IS A ONE PAGE PDF';
include ("PDF/mpdf60/mpdf.php");
$mpdf = new mPDF('c', 'A4-L','','' , 0, 0, 0, 0, 0, 0);
$mpdf->WriteHTML(utf8_encode($html));
$mpdf->AddPage();
$mpdf->SetImportUse();
$file = './best.pdf'; // HERE IS THE SECOND PDF WHICH I WANT TO MERGE WITH THE CURRENT ONE
$pagecount = $mpdf->SetSourceFile($file);
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);
ob_end_clean();
$mpdf->Output("title" . date('d-m-Y') . ".pdf",'D');
exit;
I can t get it to a solution. It creates a PDF where the last page from the best.pdf gets over my current first page pdf.
EDIT:
I added $mpdf->AddPage();
before $mpdf->SetImportUse();
and now I get the last page from the second pdf into the second page in first PDF. All I have to do now is to get all pages from the best.pdf.