As you're probably aware, wkhtmltopdf is unmaintained. Despite that, it's still widely used by developers for HTML to PDF generation—which is unfortunate because there are many excellent wkhtmltopdf alternatives available.
Before we dig into the alternatives, it's worth noting that wkhtmltopdf's largest weakness as PDF converter is a lack of support for CSS Paged Media specifications or the CSS Generated Content specifications. These specifications enable or ease advanced PDF styling such as named pages, headers, footnotes, watermarks, page floats, cross-references, content duplication, and much more.
Unfortunately, browser support for CSS Paged Media hasn't significantly improved over the years. Some of the alternatives listed here will have CSS Paged Media support, but others won't. Select carefully and evaluate the most challenging aspects of your PDF document first.
In addition to not supporting CSS Paged Media, wkhtmltopdf lacks full support for many newer, powerful HTML, CSS, and JavaScript features, including CSS Columns, CSS Flexbox, CSS Grid Layouts, ES6 JavaScript, and more.
Many of the below alternatives support most if not all of that functionality, but some do not. We've tried to call out specific features that are important to PDF generation. None of the alternatives are perfect in every way, you'll need to carefully examine the requirements of your project to make the best choice.
DocRaptor is an HTML to PDF API that uses the Prince PDF engine. It's easy to use and has a simple yet powerful API. Because of Prince's full support of CSS Paged Media, it's trivial to create complex PDFs that are difficult or impossible with many other PDF generators. Beyond paged media, DocRaptor also supports advanced functionality such as PDF forms, accessible PDFs, and TIFF image formats, which most PDF generators do not.
DocRaptor expands upon Prince's capabilities by offering an API that eliminates your infrastructure maintenance requirements while guaranteeing uptime and reliability. Our commitment to security and privacy is demonstrated by our SOC2, HIPAA, and GDPR compliance and third-party audits. Lastly, we have beautiful examples, free templates, extensive documentation, and a professional, experienced support team to help you craft perfect PDF documents.
WeasyPrint is a Python-based open-source HTML to PDF library. It is not based on a browser engine and thus has broader CSS Paged Media support than other open-source tools. Its primary downside is that it cannot parse JavaScript. It can convert HTML and CSS only. WeasyPrint also tends to struggle with really complex rendering and edge cases and lacks full support for advanced functionality such as PDF forms, accessible PDFs, or page floats. For more information, we've created a detailed WeasyPrint versus DocRaptor comparison.
We already mentioned feature-rich Prince as the PDF generation engine behind DocRaptor's API, but you can always just use Prince directly. It's the most powerful PDF conversion tool available, with many PDF-specific features like accessing the PDF file DOM. The limiting factor is that you have to build out and maintain your own PDF generation infrastructure (which is normally more resource-usage intensive than a web server), and Prince's licensing can be expensive. DocRaptor provides instant redundancy and scalability with an affordable price tag.
Google's Chromium is the most analogous alternative to wkhtmltopdf. Where wkhtmltopdf provided access to the ancient QT WebKit rendering engine, the current version of headless Chromium uses the very latest CSS and JavaScript.
The downside is the lack of CSS Paged Media and PDF-specific feature support, so headless Chrome is best for simpler PDF files. If you want the visual rendering engine to look exactly the same as the webpage in the browser, Chromium is an excellent choice. If your document contains multiple pages or complex features, you'll probably want to look elsewhere.
Below, you'll find many wrappers for headless Chrome in different programming languages.
As an API, DocRaptor is easily used in any programming language, but we maintain first-party clients in Ruby, .NET, Java, Python, and PHP. Prince also provides a wrapper for most major languages and headless Chrome libraries are available in almost every language as well. All three tools are available in your command line tools.
Here's a more complete list of popular libraries for every language:
When selecting a new PDF generator, consider the following:
This was a big list, but we hope it's been helpful. Feel free to contact our team at support@docraptor.com if you have any follow-up questions!