Appearance
Wkhtmltopdf is a command line tool to render HTML into PDF using a webkit rendering engine. A lot of libraries offering this feature are built upon it.
However, we warn you to use it at your own risk.
Wkhtmltopdf last stable version was released June 2020. It has been deprecated and even archived on Github since January 2023.
This means any security patch, Javascript feature, CSS feature supported by browsers after 2020 will never be supported by wkhtmltopdf. No fix will be released for newly discovered bugs or security issues. Your code can be displayed correctly on your browser and be broken when rendering to PDF.
Start by installing the command line tool on your machine.
You can find precompiled libraries here but those can be old and most likely incompatible with your current machine.
Another option is to build it from the source.
For mac users, you can install it with brew:
brew install wkhtmltopdf --cask
Wkhtmltopdf command line is pretty straight forward
wkhtmltopdf <source> <output>
The source
can either be an URL address or the relative path to an HTML file. The output
is the relative path to the rendered PDF file.
A lot of options are available. You can find the whole list here.
Wkhtmltopdf does not go well with Javascript. If you use a framework such as Vue, React or Angular to render the HTML, the rendered PDF will likely be an empty page however long you wait for Javascript to execute.
Using wkhtmltopdf in your application implies having another dependency and execute a binary inside your application. This can lead to a potential security breach.
The documentation warn to not use it with untrusted HTML as it could take over the server it is running on. It is your responsibility to check the HTML and sanitize it to avoid any issues.
It is not the most suitable approach if you are looking to automate PDF generation, for exemple for rendering invoices or reports. Other libraries wrap wkhtmltopdf for better use in Node, Python etc but it adds another layer of complexity and not all features could be available.
As we mentionned earlier, wkhtmltopdf is no being longer maintained. This means no update will be released in the future. If a security issue or a bug is discovered, it will not be fixed.
Doppio provides a simpler, more secured and scalable solution to rendering PDF.
All it takes to render the PDF is an API call.
It is easy to use and kept up-to-date with the latest rendering engines by our team.
It executes outside your application, saving precious ressources on your server and protecting it from any security issues.
You can easily use Doppio from your terminal with just curl
, without installing anything.
curl --location --request POST 'https://api.doppio.sh/v1/render/pdf/direct' \
--header 'Authorization: Bearer <YOUR API KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"page": {
"pdf": {
"printBackground": true
},
"goto": {
"url": "https://example.doppio.sh/information-booklet.html",
"options": {
"waitUntil": ["networkidle0"]
}
}
}
}' --output ./myfile.pdf
Wkhtmltopdf | Doppio | |
---|---|---|
Type of tool | Self managed library | Hosted and managed Saas API |
Maintenance | Deprecated | Kept up-to-date by our team |
Easy setup | ||
PDF rendering | ||
PNG, JPG & WebP rendering | ||
Languages supported | Not full javascript support | Any language |
Create asynchronous workflows | Good luck! | |
Upload delegation (S3 storage) | Good luck! | |
HDS ready | Depend on you | |
GDPR ready & full privacy | Depend on you | |
Fully secured | Depend on you | |
Pricing | Free (but need to be hosted and managed on your server) | Free plan (400 renders / month) Paying plan from €14,90 / month |