I'm trying to render a pdf of a html page. In the end of the HTML I have a very short jQuery script.
After wkhtmltopdf has been executed, it renders all the HTML fine however the Javascript has not been loaded for the PDF file. So it seems as if either wkhtmltopdf is ignoring my Javascript, or it is generating the .pdf before it is running the javascript.
I've tried both with $(document).ready and without, without results. I've tried --debug-javascript without any information retrieved.
Any ideas?
Another (I would say easiest) means of debugging javascript in WKHTMLTOPDF is to download QT Browser, the underlying browser used by WKHTMLTOPDF, and to inspect the javascript execution for your page from within the browser. You can basically debug your JavaScript in QT Browser just as you would in Chrome or Firefox.
What is it? wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service. There is also a C library, if you're into that kind of thing.
SOLVED: I solved this issue by using pure Javascript instead of using jQuery. I tried loading jquery.min.js, normal jquery.js and also making sure it was on the same host as I was running wkhtmltopdf from. Nothing worked.
When I instead used normal javascript it was running fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With