Convert HTML to PDF using Webkit (QtWebKit)
open sourceLGPL-3.0self-hostablefreearchived
wkhtmltopdf and wkhtmltoimage are command-line tools that render HTML to PDF and images with the Qt WebKit engine, headless and without a display. The project is unmaintained: its GitHub repository is archived, it depends on Qt 4 (unsupported since 2015) and an old QtWebKit with no upstream, and its own site warns never to use it with untrusted HTML because that can lead to complete takeover of the server. Its site recommends WeasyPrint or Prince for HTML you control and Puppeteer for JavaScript-heavy pages.
Problems it solves
- our old Rails app shells out to a WebKit-based binary for PDFs and I need to know what to replace it with
- CSS flexbox and grid don't render in our PDFs because the engine is ancient
- security scan flagged the HTML to PDF binary in our image as unmaintained
- PDF generation breaks on the new Debian base image because the binary needs old Qt libraries
- convert an HTML page to PDF with a single shell command on a server with no display
- migrating off a deprecated HTML to PDF command-line tool without rewriting all our templates
- users can put their own HTML into documents and I'm worried about server-side request forgery
- modern JavaScript in our report page doesn't run when it's converted to PDF
Features
- HTML to PDF and image from the command line
- headless, no display server needed
- wkhtmltoimage for image output
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what wkhtmltopdf does.
- ironpress HTML to PDF. In process. In pure Rust.
- DocRaptor The World's Most Advanced HTML to PDF API
- WeasyPrint Renders HTML and CSS to PDF, from Python or the command line
- Prince Convert HTML to PDF. Beautiful printing with simple CSS.
- Puppeteer JavaScript API for Chrome and Firefox
- Playwright Fast and reliable end-to-end testing for modern web apps