我正在 python 中尝试 pdfkit。我有两件事遇到麻烦。
下面是我的代码
import pdfkit
path_wkhtmltopdf = r'C:/Program Files/path/to/wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_wkhtmltopdf)
options = {'page-size': 'LETTER',
'margin-top': '24px',
'margin-right': '2px',
'margin-bottom': '24px',
'margin-left': '2px'}
url = 'https://www.cal_info.ca.gov/mypath'
path_file = c:/myfile/save/path/webpage.pdf'
pdfkit.from_url(url, path_file, configuration=config, options=options)
我没有尝试过更新到最新的 wkhtmltopdf.exe 文件。
--no-outline
标志应删除书签。--margin-bottom 5mm --margin-left 5mm --margin-right 5mm --margin-top 5mm
。