Reputation: 75
I'm trying to create an invoice in A4 format dynamically using airium in python. The creation of the HTML page works as expected.
the porblem comes with the conversion to a .pdf, I tried many tools but the best results I had where with weasyprint, but a part of the invoice is cut out, and with pdfkit and wkhtmltopdf, but the invoice number move on it's own. How can I fix the issue, knowing that the HTML and the PDF must be to the A4 format and render the same no matter the file type ?
from weasyprint import HTML
path = "C:\\Users\\Administrateur\\data\\Dev\\"
input_html = path + "invoice.html"
output_pdf = path + "invoice.pdf"
HTML(input_html).write_pdf(output_pdf)
import pdfkit
path = "C:\\Users\\Administrateur\\data\\Dev\\"
input_html = path+"invoice.html"
output_pdf = path+"invoice.pdf"
path_wkhtmltopdf = "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
pdfkit.from_file(input_html, output_pdf, configuration=config)
Upvotes: 0
Views: 53