I am trying to generate PDF document from HTML using wkhtmltopdf
. But I am not able to figure out how to integrate wkhtmltopdf
into my webapplication as there are no jar
files in the tar
file provided by the author. Can someone help me to set up this?
The wkhtmltopdf program is provided in a form of a stand-alone executable. It uses Qt Webkit module from Qt library for rendering the HTML and producing the PDF output. It is written in C/C++ thus you will be unable to find any JAR files.
You can save the HTML to a temporary file, use Runtime.exec() or ProcessBuilder to fork a new process from Java and when the process finishes, read the PDF file.
Qt Jambi might help you as well with its QWebView class might help you as well. Alternatively, you can implement your own wrapper over Qt Webkit in C and create Java bindings using JNI for calling it from Java in-process.
Depending on the target environment, you have to assess if you can afford forking processes from Java or implementing native calls as it might be a possible security risk.
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