Generate PDF from HTML using Django and Reportlab
I'd recommend using wkhtmltopdf.
The short answer? On Ubuntu, install a binary:
apt-get install wkhtmltopdf
On CentOS / RedHat:
yum install wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm
Then pip install a Python package:
pip install pdfkit
Then the code:
import pdfkit
input_filename = 'README.html'
output_filename = 'README.pdf'
with open(input_filename, 'r') as f:
html_text = f.read()
pdfkit.from_string(html_text, output_filename)
For the long answer and details, I put together a blog post:
https://www.pyphilly.org/generating-pdf-markdown-or-html/
That should take care of the PDF creation; you'll have to decide how you want to handle the download. Good luck!