You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling Output() on a mpdf which has images for 2 or more times the subsequent calls to Output() are missing the images.
Background: Maybe you want to show a Mpdf in browser and save it in filesystem, so one would call $mpdf->Output() and $mpdf->Output('some_filename', 'F');
The second, third, ... calls to Output() are generating pdf data / files which have images missing.
The reason is in mpdf/mpdf/src/Writer/ImageWriter.php line 96:
unset($this->mpdf->images[$file]['data']);
The image file data are cleaned after the first Output()call.
Even clone of the $mpdf object will not help since the ImageWriter class has its own reference to the original mpdf object.
mPDF version
8.2.3 / current
PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)
PHP 8.1 / 8.2 / 8.3
Reproducible PHP+CSS+HTML snippet suffering by the error
Generate new mpdf
Add images
Call $mpdf->Output() for the first time
Call $mpdf->Output() for the second time
The problem is also seen in php error / warning log strlen(): Passing null to parameter #1 ($string) of type string is deprecated
which occurs in the second call.
The text was updated successfully, but these errors were encountered:
Guidelines
Description of the bug
When calling
Output()
on a mpdf which has images for 2 or more times the subsequent calls toOutput()
are missing the images.Background: Maybe you want to show a Mpdf in browser and save it in filesystem, so one would call
$mpdf->Output()
and$mpdf->Output('some_filename', 'F');
The second, third, ... calls to
Output()
are generating pdf data / files which have images missing.The reason is in
mpdf/mpdf/src/Writer/ImageWriter.php
line 96:unset($this->mpdf->images[$file]['data']);
The image file data are cleaned after the first
Output()
call.Even
clone
of the$mpdf
object will not help since theImageWriter
class has its own reference to the original mpdf object.mPDF version
8.2.3 / current
PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)
PHP 8.1 / 8.2 / 8.3
Reproducible PHP+CSS+HTML snippet suffering by the error
The problem is also seen in php error / warning log
strlen(): Passing null to parameter #1 ($string) of type string is deprecated
which occurs in the second call.
The text was updated successfully, but these errors were encountered: