11/28/2021

print pdf from html, python code

#pip install weasyprint
from weasyprint import HTML
#read html
HTML_path = './sample.html'
#convert html2pdf with coordinate
pdf = HTML(HTML_path).write_pdf()
#save pdf
open('sample_weasyprint.pdf', 'wb').write(pdf)

 

Thank you.

www.marearts.com


No comments:

Post a Comment