Warm tip: This article is reproduced from serverfault.com, please click

php-使用mpdf导入pdf显示仅导入pdf的一层

(php - import pdf with mpdf shows imports only a layer of the pdf)

发布于 2020-11-27 16:17:30

我正在尝试通过使用mpdf的导入功能来导入pdf。

        $this->mpdf = new \Mpdf\Mpdf();
        $this->mpdf->setSourceFile("paybackform/Attest-psychotherapie_tcm47-25501.pdf");
        $tplId = $this->mpdf->importPage(1);
        $this->mpdf->addPage();
        $this->mpdf->UseTemplate($tplId);

        $this->mpdf->output();

我已经尝试了很多不同的输入PDF,但是mpdf从来没有输出与我输入的输出pdf相同的输出pdf。根据我使用的输入pdf的不同,图形会被剥离,或者文本的大部分会被删除。在最好的情况下,我只会看到部分文本。对于某些输入PDF,我在输出pdf中仅获得灰色背景,而根本没有文本。

我尝试将mpdf升级到最新版本,但没有结果。我尝试了具有addPage()和没有addPage()的importPage()和ImportPage()。好像我被卡住了。我在SO上找不到与我的问题类似的问题。

有谁知道这里可能是什么问题的线索?

问候

利文

Questioner
Lvn W
Viewed
0
Lvn W 2021-01-09 16:01:09

我发现实际上是我的api的缩小器(最小化了我的api的输出)是导致此问题的原因!在下载PDF之前禁用此缩小器即可解决该问题。

所以它与mpdf无关