wkhtmltopdf has been one of the best-known tools for converting HTML and web pages to PDF. It is free, can be run from the command line and has been integrated into countless applications over the years.

However, developers building or modernising applications may now want an alternative that does not require installing and maintaining wkhtmltopdf and its rendering dependencies on their own servers.

The HTML2PDF API provides a managed alternative. Send HTML2PDF a URL or raw HTML and receive the generated PDF directly in the HTTP response.

This lets you move PDF rendering outside your application while continuing to use HTML and CSS to define your documents.


Why look for a wkhtmltopdf alternative?

wkhtmltopdf has been extremely useful because it made HTML-to-PDF conversion available through a simple command-line interface.

But there are several reasons why developers may look for an alternative today:

  • Modern websites increasingly depend on newer HTML, CSS and JavaScript features
  • You need to install wkhtmltopdf and its dependencies on every relevant server or container
  • Operating-system upgrades can affect existing installations
  • Fonts and rendering dependencies need to be maintained
  • Scaling conversions requires managing processes and server capacity
  • You may prefer PDF rendering to be independent from your application infrastructure

If wkhtmltopdf already produces exactly the PDFs you need and is running reliably, there may be no reason to replace it.

But if you are building a new application, modernising an existing system or having difficulty rendering newer web content, moving PDF generation to HTML2PDF can simplify your architecture.


HTML2PDF as a wkhtmltopdf alternative

With wkhtmltopdf, the PDF conversion happens inside infrastructure that you manage:

Your application
       |
       v
   wkhtmltopdf
       |
       v
 Rendering engine
       |
       v
      PDF

With HTML2PDF, your application sends the document to our API:

Your application
       |
       | URL or HTML
       v
  HTML2PDF API
       |
       | PDF
       v
Your application

Your application no longer needs to install, execute, monitor or update the PDF rendering software itself.


Migrating from wkhtmltopdf to HTML2PDF

A simple wkhtmltopdf conversion might currently look like this:

wkhtmltopdf https://example.com output.pdf

The equivalent HTML2PDF request is an HTTP call:

curl "https://api.html2pdf.co.uk/?license=YOUR_LICENSE_KEY&url=https%3A%2F%2Fexample.com" \
     --output output.pdf

Instead of executing a local binary, your application calls HTML2PDF and receives the PDF as the response.

This also means HTML2PDF can be used from virtually any programming language capable of making an HTTP request.


Convert raw HTML instead of a URL

Just like wkhtmltopdf can generate documents from application-generated content, HTML2PDF can convert HTML that does not exist at a public URL.

Send the generated HTML directly to the API:

curl -X POST "https://api.html2pdf.co.uk/" \
     -d "license=YOUR_LICENSE_KEY" \
     --data-urlencode "html=<html><body><h1>Invoice</h1><p>Document content...</p></body></html>" \
     --output document.pdf

This is useful for invoices, reports, statements and other documents generated dynamically by your application.


Replacing common wkhtmltopdf options

HTML2PDF provides API parameters for many of the layout settings commonly used when generating PDFs.

Requirement wkhtmltopdf HTML2PDF
A4 page size --page-size A4 page_size=A4
Landscape --orientation Landscape orientation=landscape
Margins --margin-* Margin parameters / account defaults
Headers / footers Header/footer options HTML2PDF header/footer options
Wait for dynamic content --javascript-delay wait_time

For all supported parameters, see the HTML2PDF API documentation.

Tip: Frequently used settings such as page size, margins and headers/footers can be configured as defaults in the HTML2PDF members area. Your application then only needs to send options that differ for a particular document.

wkhtmltopdf vs HTML2PDF

wkhtmltopdf HTML2PDF API
DeploymentLocal binaryHTTP API
Rendering infrastructureYou manage itManaged by HTML2PDF
InstallationRequiredNo local installation
UpdatesYou manage themManaged by HTML2PDF
URL to PDFYesYes
Raw HTML to PDFYesYes
Works offlineYesNo
HTTP integrationRequires your own wrapperNative
Infrastructure costYour serversIncluded in service
Service costOpen sourceSubscription

When should you keep using wkhtmltopdf?

HTML2PDF is not automatically the right replacement for every wkhtmltopdf installation.

You may be better off continuing to use wkhtmltopdf if:

  • Your current PDF output already renders correctly
  • Your application must operate completely offline
  • You cannot send document content to an external service
  • You generate very large volumes and already have efficient conversion infrastructure
  • You specifically depend on wkhtmltopdf behaviour in existing documents

HTML2PDF becomes particularly attractive when you want to remove PDF-rendering infrastructure from your application or need a managed solution for converting web content and dynamically generated HTML.


Try HTML2PDF as a wkhtmltopdf alternative

Moving from wkhtmltopdf to HTML2PDF changes PDF generation from a local process into a simple HTTP request:

  1. Send HTML2PDF a URL or raw HTML
  2. Specify your PDF layout and rendering options
  3. Receive the generated PDF in the HTTP response

You no longer need to install or maintain wkhtmltopdf on your application servers.

Explore the HTML2PDF API documentation or compare our plans and pricing to test HTML2PDF with your existing HTML and web pages.