PDF 不合并大于 PDF-1.5 版本使用 mPDF
PDF not merge greater than PDF-1.5 version using mPDF
我尝试使用最新版本的 mPDF 插件合并 pdf,但是
错误来了
PDF 合并在使用 pdf 版本 1.3 时有效,但在 1.5
中未完成
我试过下面的代码
<?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');
?>
我遇到了这个错误
mPDF error: Unable to find xref table - Maybe a Problem with auto_detect_line_endings
提前致谢
拉克斯:
您是否尝试过使用不同的 pdf 文档?这可能会帮助您:
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.
我已经使用 mpdf 和 shell 脚本合并了大于 1.5 版的 pdf。
$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);
$tmp_dir1='upload_files/tmp_ao_pdf';
if(!is_dir($tmp_dir1))
{
mkdir($tmp_dir1,0777);
}
$file_path=$tmp_dir1."/"."generate_html.pdf";
$mpdf->Output($file_path,'F');
$attachh_pdf_name="upload_files/order_form_instructions_energy_supply.pdf";
$fileArray= array($file_path,$attachh_pdf_name);
$datadir = "upload_files/";
$outputName = $datadir."orderform_".$order_id.".pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -dAutoRotatePages=1 -sPAPERSIZE=legal -sDEVICE=pdfwrite -sOutputFile=$outputName ";
foreach($fileArray as $file) {
$cmd .= $file." ";
}
$result = shell_exec($cmd);
您之前可以使用 Ghostscript 实用程序
降级输入的 PDF 文件版本
gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-o order_form_instructions_energy_supply_v1.4.pdf \
order_form_instructions_energy_supply.pdf
然后在 mPDF 库中使用降级文件
您的脚本:
<?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');
我尝试使用最新版本的 mPDF 插件合并 pdf,但是 错误来了 PDF 合并在使用 pdf 版本 1.3 时有效,但在 1.5
中未完成我试过下面的代码
<?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');
?>
我遇到了这个错误
mPDF error: Unable to find xref table - Maybe a Problem with auto_detect_line_endings
提前致谢
拉克斯: 您是否尝试过使用不同的 pdf 文档?这可能会帮助您: 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.
我已经使用 mpdf 和 shell 脚本合并了大于 1.5 版的 pdf。
$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);
$tmp_dir1='upload_files/tmp_ao_pdf';
if(!is_dir($tmp_dir1))
{
mkdir($tmp_dir1,0777);
}
$file_path=$tmp_dir1."/"."generate_html.pdf";
$mpdf->Output($file_path,'F');
$attachh_pdf_name="upload_files/order_form_instructions_energy_supply.pdf";
$fileArray= array($file_path,$attachh_pdf_name);
$datadir = "upload_files/";
$outputName = $datadir."orderform_".$order_id.".pdf";
$cmd = "gs -q -dNOPAUSE -dBATCH -dAutoRotatePages=1 -sPAPERSIZE=legal -sDEVICE=pdfwrite -sOutputFile=$outputName ";
foreach($fileArray as $file) {
$cmd .= $file." ";
}
$result = shell_exec($cmd);
您之前可以使用 Ghostscript 实用程序
降级输入的 PDF 文件版本gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-o order_form_instructions_energy_supply_v1.4.pdf \
order_form_instructions_energy_supply.pdf
然后在 mPDF 库中使用降级文件
您的脚本:
<?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');