wkhtmltopdf

How to trim (crop) bottom whitespace of a PDF document, in memory

How to trim (crop) bottom whitespace of a PDF document, in memory Question: I am using wkhtmltopdf to render a (Django-templated) HTML document to a single-page PDF file. I would like to either render it immediately with the correct height (which I’ve failed to do so far) or render it incorrectly and trim it. I’m …

Total answers: 1

Convert html to pdf using Python/Flask

Convert html to pdf using Python/Flask Question: I want to generate pdf file from html using Python + Flask. To do this, I use xhtml2pdf. Here is my code: def main(): pdf = StringIO() pdf = create_pdf(render_template(‘cvTemplate.html’, user=user)) pdf_out = pdf.getvalue() response = make_response(pdf_out) return response def create_pdf(pdf_data): pdf = StringIO() pisa.CreatePDF(StringIO(pdf_data.encode(‘utf-8’)), pdf) return pdf …

Total answers: 3