wkhtmltopdf
is a neat command line utility that will convert HTML to PDF or image using WebKit.
To convert an HTML file to PDF, run:
wkhtmltopdf sample.html sample.pdf
To batch convert a bunch of HTML files to PDF files with corresponding names, run:
for htmlfile in *.html; do
wkhtmltopdf "$htmlfile" "$(basename "$htmlfile" .html).pdf"
done
This will produce example.pdf
as a PDF version of example.html
.
In Debian GNU/Linux, wkhtmltopdf is available from the official mirrors and can thus be installed by running
sudo apt install wkhtmltopdf