I want to convert existing complex HTML with CSS and images to PDF.

  • I tried PhantomJS and CasperJS and they are great but no longer being developed.

  • I tried wkhtmltopdf which is great but didn't have a new release in over a year.

I know about headless Firefox and Chrome but I need to run it on a Debian server and call from PHP. Both Firefox and Chrome need GUI, need X windows.

I use Debian 8 on a server.

  • 1
    The last release of wkhtmltopdf was a while ago, but it seems to be still maintained. In the GitHub repo there's been 9 commits since the last release. Some projects eventually reach a point where no new features, just bug fixes.
    – LHLaurini
    Jan 24, 2020 at 14:04
  • @LHLaurini wkhtmltopdf is buggy as hell. Version 0.12.4 does not support OpenSSL 1.1. Version 0.12.5 renders pdfs in a different scale, with different margins and lots of empty space. There are problems with transparent images and so on.
    – Tom
    Jan 24, 2020 at 16:48
  • Did you have a python version 3.5+ installed?
    – GAD3R
    Jan 24, 2020 at 18:19
  • @GAD3R Why? I can install Python if it is needed
    – Tom
    Jan 24, 2020 at 18:31
  • Are you open to NodeJS/NPM for the solution? I assume you could trigger the nodejs request/work from PHP. Or host the nodejs on a separate debian instance perhaps.
    – Ryan
    Jan 24, 2020 at 23:27

2 Answers 2


I know about headless Firefox and Chrome but I need to run it on a Debian server and call from PHP.

If it works without problems then sure, NodeJS is fine

Since you want to convert complex HTML to PDF, then you really need a HTML rendering engine, such as Chrome Headless.

The following AGPL-3.0 project from the company I work for can accomplish what you want.

https://www.pdftron.com/blog/react/react-to-pdf (note React is not required).


This uses Chrome headless, so follow these steps if you need to, to get Chrome on Debian8.

  • Could you take a look at ugly-math-in-preview-of-wikipedia-pdfs/ on apple.stack please -- am I on the right track at all ? Can you point me to an overview of rendering / scaling .svgs to printer.pdf ? Thanks
    – denis
    Sep 4, 2020 at 9:45

weasyprint is an alternative, packaged on debian bullseye/sid , it can be installed on a prior debian release through pip. python 3.5+ is required:

pip install weasyprint

weasyprint on github.


  • 2
    "It is based on various libraries but not on a full rendering engine like WebKit or Gecko. The CSS layout engine is written in Python" Since your objective is "complex HTML" you would definitely want to review the output of this option before committing. Even Microsoft abandoned writing a new HTML rendering engine!
    – Ryan
    Jan 26, 2020 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .