请教一个关于 wkhtmltopdf 实现 html 转 pdf 的小问题( win32)

2015-08-07 22:47:15 +08:00
 cc21
是这样,题主想把雪球上的文章按html格式转成pdf,看到了有个很方便的pdfkit
结果是这样,pdf是转出来了,但有点格式上的错误

>>> import pdfkit
>>> pdfkit.from_url('http://xueqiu.com/9320604669/53827976', 'out.pdf')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\pdfkit\api.py", line 24, in from_url
return r.to_pdf(output_path)
File "C:\Python34\lib\site-packages\pdfkit\pdfkit.py", line 109, in to_pdf
if 'cannot connect to X server' in stderr.decode('utf-8'):
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 2362: inval
id start byte


直接用wkhtmltopdf试试

D:\>wkhtmltopdf http://xueqiu.com/9320604669/53827976 out.pdf
Loading pages (1/6)
QWin32PrintEngine::initialize: OpenPrinter failed (RPC ????????á?)%
QWin32PrintEngine::initialize: OpenPrinter failed (RPC ????????á?)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: UnknownContentError


求问广大V友这是什么问题?
4704 次点击
所在节点    Python
2 条回复
vjnjc
2015-08-08 23:07:45 +08:00
osx 下面也遇到同样报错,不过pdf倒是生成出来了,同问
mingyun
2015-08-30 12:59:20 +08:00
请问下我在 win7 下为什么装不上 wkhtmltopdf ?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/211628

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX