Make Chrome Headless to Wait for Ajax Before Printing to PDF

Gil Shamgar picture Gil Shamgar · Apr 2, 2018 · Viewed 11.6k times · Source

I'm trying to use chrome headless to print my webpage to a PDF file. The PDf file is with no data, because the headless chrome is printing it before the ajax commands finish.

Any idea on how I can get it to wait?

Here's the command I currently use:

chrome --headless http://localhost:8080/banana/key --run-all-compositor-stages-before-draw --print-to-pdf=C:\\tmp\\tmp.pdf

Answer

Izayoi Sakuya picture Izayoi Sakuya · Apr 12, 2018

chrome --headless http://localhost:8080/banana/key --run-all-compositor-stages-before-draw --print-to-pdf=C:\tmp\tmp.pdf --virtual-time-budget=10000

Try this, virtual-time-budget is the parameter which can delay it.