python html格式的pdf转换成pdf文件
2016-03-25 16:29
1036 查看
今天对接物流接口时,遇到返回来的面单是个网页版的pdf,经过一番波折后,借用python中的pdfkit解决了这个问题:
pdfkit.from_file('test.html', 'test.pdf')
但是还存在一个问题,pdf文件中面单占的大小不能控制,待解决。
后续:
options = {
'page-width': '120',
'page-height': '170',
'margin-top': '0.1',
'margin-right': '0.1',
'margin-left': '0.1',
'margin-bottom': '0.1',
}
config = pdfkit.configuration(wkhtmltopdf='/home/newpro/pro/wkhtmltopdf')
pdfkit.from_string('test.html', 'test.pdf', options=options, configuration=config)
通过传入options来截取对应纬度所需的信息。
pdfkit.from_file('test.html', 'test.pdf')
但是还存在一个问题,pdf文件中面单占的大小不能控制,待解决。
后续:
options = {
'page-width': '120',
'page-height': '170',
'margin-top': '0.1',
'margin-right': '0.1',
'margin-left': '0.1',
'margin-bottom': '0.1',
}
config = pdfkit.configuration(wkhtmltopdf='/home/newpro/pro/wkhtmltopdf')
pdfkit.from_string('test.html', 'test.pdf', options=options, configuration=config)
通过传入options来截取对应纬度所需的信息。
相关文章推荐
- Python爬虫:一些常用的爬虫技巧总结
- python的zeroMQ介绍
- Python3.x中的print()函数
- python笔记---常见异常
- 机器学习基础(二十)—— 数学语言与 Python 代码
- 将python程序打包成.exe文件
- python3的字符串格式化
- 动手写一个Python Web 框架学习笔记 - 搭建开发环境 (1)
- 《Python数据分析基础教程:Numpy学习指南》- 速记 - 第四章
- PYTHON实现把PPT文档中的内容导出到TXT文件中
- 使用python进行web抓取
- 《Python基础教程》(一)数字和表达式
- cx_freeze打包Python程序
- python3 Unicode 编码转换中文显示
- python开发web服务器《一》
- python 遍历文件夹及文件
- python Django框架实现自定义表单提交
- Python接收开源中国GITOSC WebHook的POST数据
- python3.5之输出HTML实体字符
- python web