fix pdf creation for very large exports (#1533)
This commit is contained in:
@@ -34,7 +34,21 @@ class MPdfConverter implements HtmlToPdfConverter
|
||||
{
|
||||
$mpdf = new Mpdf(['tempDir' => $this->cacheDirectory]);
|
||||
$mpdf->creator = Constants::SOFTWARE;
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// some OS do not follow the PHP default settings
|
||||
if ((int) ini_get('pcre.backtrack_limit') < 1000000) {
|
||||
@ini_set('pcre.backtrack_limit', 1000000);
|
||||
}
|
||||
|
||||
// reduce the size of content parts that are passed to MPDF, to prevent
|
||||
// https://mpdf.github.io/troubleshooting/known-issues.html#blank-pages-or-some-sections-missing
|
||||
$parts = explode('<pagebreak>', $html);
|
||||
for ($i = 0; $i < count($parts); $i++) {
|
||||
$mpdf->WriteHTML($parts[$i]);
|
||||
if ($i < count($parts) - 1) {
|
||||
$mpdf->WriteHTML('<pagebreak>');
|
||||
}
|
||||
}
|
||||
|
||||
return $mpdf->Output('', Destination::STRING_RETURN);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user