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
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
This doesn't make sense. Please share your input PDF and output which shows the wrong behavior.
I made an animated gif. First I demonstrate correct generation of pdf when write to file. Then I remove the arguments of the output function and you see a grey background instead of the template file. I made an animated gif. First I demonstrate correct generation of pdf when write to file. Then I remove the arguments of the output function and you see a grey background instead of the template file. [demo of problem][1] [1]: i.stack.imgur.com/cCGJF.gif
Still not enough information to analyze this. Can it be that you call
Output()
more than once? How is the final PDF send to the client at all? Please share both output PDFs (correct and faulty one).Hi, you were right @janSlabon. This wasn't the solution at all. I kept on getting the same problem when I wanted to download the pdf via my API. After debugging for a while I found out that the function that minifies the responses of my API was the cause for this problem. So it has nothing to do with mpdf