I'm using the mPDF libary to turn HTML pages into PDFs.
This library works great on my local machine and development servers running PHP 5.6.
However on a newly provisioned Ubuntu 16 box from Amazon, with Apache 2.4.18 and PHP 7 I can't get it working.
The symptom is that the PDF is never generated - the browser just keeps spinning for ever, and eventually I have to quit the browser to escape from the process. I do not receive any error messages.
I've worked through my script to see where the process gets stuck, and it's on this method:
$mPDF->WriteHtml($html);
I have tried passing a very simple HTML string into the function, for example:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<b>Hello!</b>
</body>
</html>
And that does work.
So I wondered about the quality of my HTML. Running my HTML through the W3 Validator revealed a couple of errors which I've now fixed, but this has not resolved my issue.
So I'm now wondering about the size of my HTML - it's a large page that's being rendered, often in excess of 20 pages on the PDF.
My script allocates plenty of memory for the process:
ini_set('memory_limit', '1024M');
And the server has 8G of memory in total.
Is there anything I should check in the server config which might be affecting mPDF?
Thanks in anticipation.
Edit
After further debugging and stripping the HTML back to smaller and smaller pieces I have been able to get the PDF to generate - but it's extremely slow.
mPDF also seems to fail to find the image assets, so I get broken image symbols on the PDF. I wonder if this server setup has a strange webroot / basePath that means mPDF can't find the assets it's looking for?
Edit 2
Wondering if this issue is now a duplicate of mPDF not rendering images (mPDF error: IMAGE Error Could not find image file)
I'm seeing the same issues of slow load and missing images