Wkhtmltopdf waits for conditions before printing

We use wkhtmltopdf to convert dynamic html pages to pdf. We need to wait until all ajax requests are complete.

Is it possible to defer printing by condition?

+9
pdf-generation wkhtmltopdf html-to-pdf
source share
3 answers

You can use the --window-status option, see this message on the mailing list .

+17
source share

You can try using the -javascript-delay option.

0
source share

If you can change the javascript code on the web page, add this line of code to your javascript when you are sure that everything is ready to download:

 if (your_condition_is_met_here){ window.status = 'ready_to_print'; } 

Then pass the --window-status ready_to_print flag to wkhtmltopdf. For example:

 wkhtmltopdf --window-status ready_to_print map.html map.pdf 

See: wkhtmltopdf JavaScript delay for outputting Google maps

0
source share

All Articles