For a while now, I have used wkhtmltopdf for on-the-fly generation of pdf documents, and generally it is far ahead of the pack (pared with other tools available in php).
However, it is a HUGE PAIN to do even the most basic debugging of this process.
With your regular browser, one might alert(var);
or console.log(var);
and discover that "var" is undefined
. Again, you can easily see a 404
or 500
http error somewhere in the browser console.
Take for instance this:
wkhtmltopdf.exe http://localhost/mypage.html C:/temp/myfile.pdf
The pdf file does get created but is imperfect because certain aspects dependent on javscript or AJAX are missing.
With wkhtmltopdf, how best can I investigate these kinds of errors, if they exist in mypage.html
?
For a while now, I have used wkhtmltopdf for on-the-fly generation of pdf documents, and generally it is far ahead of the pack (pared with other tools available in php).
However, it is a HUGE PAIN to do even the most basic debugging of this process.
With your regular browser, one might alert(var);
or console.log(var);
and discover that "var" is undefined
. Again, you can easily see a 404
or 500
http error somewhere in the browser console.
Take for instance this:
wkhtmltopdf.exe http://localhost/mypage.html C:/temp/myfile.pdf
The pdf file does get created but is imperfect because certain aspects dependent on javscript or AJAX are missing.
With wkhtmltopdf, how best can I investigate these kinds of errors, if they exist in mypage.html
?
2 Answers
Reset to default 7You need to use the --debug-javascript
mand-line option. I tested it in Linux, but it's probably the same on Windows:
$ echo '<script>console.log("YAY!");</script>' > test.html
$ wkhtmltopdf --debug-javascript test.html test.pdf
Loading pages (1/6)
Warning: file:///tmp/test.html:1 YAY!
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
For 404 and 500 error, wkhtmltopdf
should prints some stuff on the mand line too, if I remember well.
Seems to me you should just open the source page in your browser first. Your browser's debugger can trace the issues. Once you know the page is perfect, you can run it through wkhtmltopdf.