I have a PHP loop that does the following:

  1. Log in to a web page via CURL
  2. Capture and internal page that requires a login
  3. Save the HTML of the page to a local file
  4. Using WKHTMLTOPDF, render the page as a PDF

The issue I'm having is that every once in a while (maybe ~30% of the time), the images won't render in the PDF. If I open up one of the saved HTML files, I'll find that I need to go in and manually refresh the page for the images to show up.

Any ideas on how to pragmatically ensure the images load? Things I've tried:

  1. sleep(n) between each and every line
  2. Adding --javascript-delay 30000 to my WKHTMLTOPDF call to ensure it has ample time to load any images.

#1 made it considerably worse, and #2 did nothing at all.

Thanks!

Edit
Report