|

楼主 |
发表于 2021-9-7 23:00:57
|
显示全部楼层
做到了html转pdf的,可以直接转本地的,图片也能出来现在就想mht转html
- import pdfkit
- """设置页面大小,上下左右的距离,编码方式,不允许一个本地文件加载其他的本地文件"""
- options = {
- 'page-size': 'Letter',
- 'margin-top': '0.1in',
- 'margin-right': '0.1in',
- 'margin-bottom': '0.1in',
- 'margin-left': '0.1in',
- 'enable-local-file-access':None,
- 'encoding': "UTF-8",
- 'no-outline': None
-
- # 'custom-header': [
- # ('Accept-Encoding', 'gzip')
- # ],
- # 'cookie': [
- # ('cookie-name1', 'cookie-value1'),
- # ('cookie-name2', 'cookie-value2'),
- # ],
- # 'outline-depth': 10,
- }
- """html文件转pdf,输出为out.pdf,位置为.py文件的路径"""
- pdfkit.from_file('C:/Users/Martin/Desktop/new/UP_J129.htm','out.pdf', options=options)
复制代码 |
|