wkhtmltox

wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line
tools to render HTML into PDF and various image formats using the Qt
WebKit rendering engine. These run entirely "headless" and do not
require a display or display service.

There is also a C library, if you're into that kind of thing.

NOTE for SlackBuilds.org:

This is a repackage of the official prebuilt binaries and provides the
same commands as wkhtmltopdf at SlackBuilds.org (which builds from
source). Only one of them should be installed.

The official prebuilt binaries are made with a specially patched,
statically linked Qt, so the provided utilities have extra
functionality, such as better margin control and multiple file
convertion. This is primarily needed for Publican to work correctly.
