#2876·PHPWord

Mpdf export can exceed pcre.backtrack_limit

Author: mrinaldidfsCreated May 11, 2026Updated May 19, 2026
LabelsBug Report

Describe the bug and add attachments

Good morning, I'm having the same problem reported in the following phpSpreadsheet issue (https://github.com/PHPOffice/PhpSpreadsheet/issues/637) on phpWord, and analyzing the same part of the code on this package hasn't resolved it. the file is: PhpSpreadsheet\Writer\Pdf\Mpdf.php row: 72

foreach (\array_chunk(\explode(PHP_EOL, $html), 1000) as $lines) {
            $pdf->WriteHTML(\implode(PHP_EOL, $lines));
}

In the file PhpWord\Writer\Pdf\Mpdf.php row: 103

foreach (explode("\n", $html) as $line) {
            $pdf->WriteHTML("$line\n");
}

Can you perform the same fix in the PHPWord package?

Thank you very much.

Expected behavior

no errors

Steps to reproduce

The problem occurs when inserting an image of approximately 700 KB into a Word document, and this already triggers the error: The HTML code size is larger than pcre.backtrack_limit 1000000

PHPWord version(s) where the bug happened

1.4.0

PHP version(s) where the bug happened

8.4

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)