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
Eric Leschinski
source share