I saw similar questions, but there was nothing like that - I believe this is a configuration problem, but I donβt know where in the chain.
I can successfully create pdf files using pdfkit and wkhtmltopdf for both my mac and my ubuntu env-ubuntu.
There are minor issues with the release of the ubuntu version that are not on the Mac.
The biggest / most important issue is the page break that I achieve with this css:
div.page{ page-break-after: always !important; page-break-inside: avoid !important; }
This is my python code (flask) for creating pdf:
@app.route('/report/<report_key>.pdf') def report_pdf(report_key): #replace with sso user_id = 1 config = pdfkit.configuration(wkhtmltopdf='/usr/local/bin/wkhtmltopdf') try: report = _generate_report(report_key) except Exception as e: logging.error("could not get report for {}: {}".format(report_key, e)) raise HTTPException else: template = render_template('report-pdf.html', report=report) pdf = pdfkit.from_string(template.encode('ascii', 'ignore').decode('ascii'), False, configuration=config) response = make_response(pdf) response.mimetype = 'application/pdf' response.headers["Content-Disposition"] = "attachment; filename={}_{}.pdf".format(strftime("%Y-%m-%d", gmtime()), report_key) return response
I can only assume that this is a problem with the user agent - however - it does not make sense, since webkit should recognize breaks (and I'm sure that WK in wkhtmltopdf means webkit).
On the ubuntu server, I use xvfb to connect pdfkit and wkhtmltopdf - using this command, I see everywhere:
echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2020
I tried this, but it fails, I cannot find a suitable way to send custom header (and distribution) parameters via pdfkit. However, I do not know if this is even a solution.
Any help would be great, Thansk
(By the way, this is a new question for me. I left FB and had to start a new one on SO - my old username had a 1k reputation - bummer.)