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.
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.
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.
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 firstname.lastname@example.org if you have any follow-up questions!