Uncaught Mpdf\MpdfException: The HTML code size is larger than pcre.backtrack_limit 1000000

Satya Mahesh picture Satya Mahesh · Mar 5, 2018 · Viewed 12.9k times · Source

I am developing code to generate PDF from HTML code using library MPDF. For HTML Code I am reading from external HTML file. But its not working for larger HTML code size. Is there any way to fix it or do we have any other library which supports my functionality.

For larger html file giving error:

Fatal error: Uncaught Mpdf\MpdfException: The HTML code size is larger than pcre.backtrack_limit 1000000. You should use WriteHTML() with smaller string lengths.

Answer

Finwe picture Finwe · Mar 6, 2018

The error message tells you what to do. Pass your HTML to WriteHTML() method in smaller chunks.

Or you can try to increase your backtrack limit even more:

ini_set("pcre.backtrack_limit", "5000000");

https://mpdf.github.io/troubleshooting/known-issues.html#blank-pages-or-some-sections-missing