Best wkhtmltopdf Alternatives

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.

wkhtmltopdf Logo

CSS Paged Media

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.

Modern CSS and JavaScript Support

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.

Top Pick #1: DocRaptor

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.

Top Pick #2: WeasyPrint

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.

Top Pick #3: Prince

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.

Top Pick #4: Headless Chromium

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.

Alternatives by Programming Language

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:

Top Ruby Alternatives

  • Grover and puppeteer-ruby are both wrappers for Headless Chromium, with the same strengths and limitations.
  • Prawn is a DSL-like PDF generator, not an HTML page converter. It's fast at generating PDFs, but slow for actual development. It's also missing many important features, such as support for SVGs or accessible PDF tagging.
  • HexaPDF is a powerful PDF library, with support for creation and editing, but requires a commercial license. Similar to Prawn, it is more like a DSL than a conversion engine and is often much slower to work with.

Top PHP Alternatives

  • Chrome PHP is another wrapper for Headless Chrome. It will struggle with complex PDFs but work fine for simpler documents.
  • DomPDF is a PHP HTML to PDF library. It does not support JavaScript, SVGs, or advanced CSS, so it's best used with simple documents.
  • TCPDF is a pure PHP library for creating PDFs. It does not render HTML; you have to create your PDF element by element. It has a lot of power, but will require a lot of time and effort.

Top Python Alternatives

  • ReportLab is a powerful commercial PDF generation library with a limited open-source version, but it's more of an engine and DSL than an HTML converter. It has excellent support for building charts and graphs programmatically.
  • PyPDF2 is a pure Python library for creating PDFs, but you need to create your PDF element by element.
  • FPDF is a PHP library translated to Python. It's fast and has decent documentation for creating complex layouts programmatically.

Top Java Alternatives

  • Open HTML to PDF offers support for some advanced PDF features, such as accessibility and footnotes, but lacks other features such as OpenType fonts. Like most non-browser-based, open-source libraries, it lacks support for CSS flex and grid layouts. It also does not support JavaScript.
  • Flying Saucer is a Java library for parsing and rendering XHTML/XML+CSS 2.1 content to PDF, with support for Paged Media. It does not have JavaScript or advanced CSS support.
  • Aspose lacks support for CSS Paged Media specifications but offers minimal support for custom CSS extensions. For more complex PDF-specific functionality, custom coding with Aspose.PDF is required (although extended functionality is at least an option with Aspose).

Top Node.js / JavaScript Alternatives

  • Puppeteer is a Google-supported Headless Chrome library. As mentioned above, it's the most similar project to wkhtmltopdf and the most popular open-source HTML to PDF tool.
  • jsPDF is a lightweight PDF generator. We strongly prefer HTML to PDF converters over DSL-like generators and would consider jsPDF only for simple PDFs.
  • PDFKit is another DSL-esque PDF generator. It is a bit more featureful than jsPDF, but for context, neither library provides table support.

How to Pick

When selecting a new PDF generator, consider the following:

  • Installation & Maintenance: An API, like DocRaptor, requires no setup or ongoing maintenance, whereas installing the wkhtmltopdf executable is a known hassle. Various libraries on this list have different installation methods and maintenance requirements.
  • Performance & Infrastructure: Similarly, some libraries can rapidly generate hundreds of PDFs. Others may struggle to do so or consume a lot of server resources, requiring additional management to meet your throughput requirements.
  • Functionality: We've covered a lot of different features in this article. Obviously, some alternatives will meet your needs and others won't, whereas some may get the job done if you put in enough effort. We strongly suggest that you evaluate the required functionality of your document in order from hardest to easiest.
  • Total Cost: How much development and maintenance time can you afford to invest? Some libraries will be much faster to implement (often the commercial options), but others will take more development time and upkeep.

This was a big list, but we hope it's been helpful. Feel free to contact our team at if you have any follow-up questions!