mPDF错误:找不到外部参照表

问题描述:

当我尝试上载pdf文件并将每页分隔为pdf时,其中有一些pdf文件正在运行,但是某些pdf文件显示此错误:

When I am trying to upload a pdf file and separating each page as pdf, with some pdf files it is working but some of pdf files show this error:

mPDF error: Unable to find xref table -" Maybe a Problem with auto_detect_line_endings"

我的代码:

ini_set('memory_limit', '512M');
$pagecount = Model::count_pages($documentPath.$journalDoc);
for ($i=1; $i<=$pagecount; $i++) {
    $pdf = new mPDF('','Letter',12,'helvetica, sans-serif',200,0,0,20,0,10,'P');
    $pdf->SetImportUse();
    $pdf->SetSourceFile($documentPath.$journalDoc);
    $import_page = $pdf->ImportPage($i);
    $pdf->UseTemplate($import_page);
    $pdf->Output($output_dir.$i.'.pdf', 'F');
}   

这可能是由与您正在运行的mPDF不兼容的PDF文件引起的.您通常可以通过退回原始PDF文件来解决此问题.

This can be caused by PDF files of a version incompatible with the mPDF you're running. You can often circumvent the problem by regressing the source PDF files.

例如,对于mPDF v6.0,请尝试使用Ghostscript之类将PDF最多压缩到v1.4. (其中old.pdf是您的源文件)

For instance, for mPDF v6.0 try brining your PDFs down to at most v1.4 using something like Ghostscript. (Where old.pdf is you're sourcefile)

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -o new.pdf old.pdf

Ghostscript不会将其写入正在读取的文件中,因此,如果您以内联方式进行此操作,则必须跳舞;

Ghostscript won't write to the file it's reading so if you're doing this inline you'll have to dance;

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -o new.pdf old.pdf; mv -f new.pdf old.pdf