V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
cc21
V2EX  ›  Python

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

  •  
  •   cc21 · 2015-08-07 22:47:15 +08:00 · 4681 次点击
    这是一个创建于 3186 天前的主题,其中的信息可能已经有所发展或是发生改变。
    是这样,题主想把雪球上的文章按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友这是什么问题?
    2 条回复    2015-08-30 12:59:20 +08:00
    vjnjc
        1
    vjnjc  
       2015-08-08 23:07:45 +08:00
    osx 下面也遇到同样报错,不过pdf倒是生成出来了,同问
    mingyun
        2
    mingyun  
       2015-08-30 12:59:20 +08:00
    请问下我在 win7 下为什么装不上 wkhtmltopdf ?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3239 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:06 · PVG 20:06 · LAX 05:06 · JFK 08:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.