Can’t convert HTML to PDF using pdfkit (empty file)

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

I want to convert a HTML file to PDF

Example Input

The HTML file from Google Drive looks good, can see content in my browser.

Code

import pdfkit # convert html to pdf

pdfkit.from_file(‘income_contract_01.html’, ‘res.pdf’)

Issue

I expect to see data in res.pdf. But instead I see an empty file:

no text
but the same number of lines

Environment and versions used:

python 3.9
pdfkit versiion 1.0.0
wkhtmltopdf is the newest version (0.12.2.4-1)
OS Ubuntu 16.04

How can I fix the error? Don’t see any error messages.

Update: I was trying to specify library in configuration but it didn’t help

import pdfkit # convert html to pdf v1

path = “/usr/bin/wkhtmltopdf”
config = pdfkit.configuration(wkhtmltopdf=path)
pdfkit.from_file(‘income_contract_01.html’, ‘res123.pdf’, configuration=config)

‫أضف إجابة

تصفح
تصفح

مجهول يجيب