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

import pdf with mpdf shows imports only a layer of the pdf

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

I'm trying to import a pdf by using the import functionality of mpdf.

        $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();

I already tried a lot of different input PDF's but mpdf never outputs the same output pdf as the one i put in. Depending on which input pdf i use, the graphics are stripped, or large parts of the text are removed. In the best case I see only a part of the text. For some input PDF's i only get a grey background in the output pdf with no text at all.

I tried upgrading mpdf to the latest version, with no result. I have tried importPage() & ImportPage(), with addPage(), without addPage(). It seems like I'm stuck. I couldn't find a question on SO that resembles my question.

Does anyone have a clue about what could be the problem here?

Regards

Lieven

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

I found out that it's actually the minifier of my api (that minifies the output of my api) was the cause for this problem! Disabling this minifier before downloading a PDF solves it.

So it has nothing to do with mpdf