icps

notes

Html2pdf

apt-get install wkhtmltopdf https://wkhtmltopdf.org/downloads.html

https://github.com/twtrubiks/python-pdfkit-example

1
2
3
4
5
6
7
8
9
config = pdfkit.configuration(wkhtmltopdf='/opt/wkhtmltox/bin/wkhtmltopdf')
options = {
    'encoding': 'UTF-8',
}
pdfkit.from_url('/tmp/result.html', '/tmp/result.pdf', configuration=config, options=options)
#os.system("/opt/wkhtmltox/bin/wkhtmltoimage /tmp/result.html /tmp/result.jpg") 


#<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

ref https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3195

1
2
3
<style>
  tr { page-break-inside: avoid !important; }
</style>