How to set Headless Chrome wait until the page is fully loaded before printing?

Viewed 2853

The command to use headless Chrome to print webpage as PDF is chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/. The wkhtmltopdf has a feature --window-status ready_to_print to do so.

I ask this question because when I print this webpage contains MathJax.js, it has an error as follows:

enter image description here

The page source of that webpage has the following lines related to mathjax

<script src="../scripts.js"></script>
<script src="../../MathJax/MathJax.js?config=TeX-AMS_SVG"></script>

I would like to ask if there is an option so that Headless Chrome will wait until the page is fully loaded before printing?

1 Answers

We can use two options to achieve this goal: --run-all-compositor-stages-before-draw and --virtual-time-budget=10000.

Related