I try to merge pdf using mPDF plugin with latest version but the error coming PDF merging working when using pdf version 1.3 but not done for 1.5
I have try below code
<?php
$mihir='<html>
<body>
Generate PDFs with merge
</body>
</html>';
require_once("MPDF/mpdf.php");
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML($mihir);
$mpdf->AddPage();
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile("order_form_instructions_energy_supply.pdf");
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);
$mpdf->Output('test.pdf','D');
?>
I'm getting this error
mPDF error: Unable to find xref table - Maybe a Problem with auto_detect_line_endings
thanks in advance
Rax: Have you tried with different pdf documents? This may help you: http://www.vankouteren.eu/blog/2009/07/fpdf-error-unable-to-find-xref-table/
One of the PDFs which should be merged was originally created from Word by a PDF creator which placed its signature in the properties of the PDF document. After removing this signature (in this case opening the PDF with Adobe Illustrator and saving it again) the problem was solved.
You can previously downgrade input PDF file version with Ghostscript utility
gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-o order_form_instructions_energy_supply_v1.4.pdf \
order_form_instructions_energy_supply.pdf
and then use downgraded file in mPDF lib
Your script:
<?php
$mihir='<html>
<body>
Generate PDFs with merge
</body>
</html>';
require_once("MPDF/mpdf.php");
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML($mihir);
$mpdf->AddPage();
$mpdf->SetImportUse();
$cmd = 'gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -o order_form_instructions_energy_supply_v1.4.pdf order_form_instructions_energy_supply.pdf';
shell_exec($command);
$pagecount = $mpdf->SetSourceFile('order_form_instructions_energy_supply_v1.4.pdf');
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);
$mpdf->Output('test.pdf','D');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With