pdfkit - returns a blank pdf with only requested URL

喜你入骨 提交于 2019-12-13 04:33:32

问题


I'm trying to render a webpage with pdfkit

My code:

import pdfkit
config = pdfkit.configuration(wkhtmltopdf='/Library/Python/2.7/site-packages/wkhtmltopdf/wkhtmltopdf')
pdfkit.from_string('http://stackoverflow.com', 'so.pdf', configuration=config)

But this just returns a blank pdf with the requested URL at the top.

When in terminal I run wkhtmltopdf directly...

wkhtmltopdf http://stackoverflow.com so2.pdf

It renders fine

What am I doing wrong?


回答1:


This works fine with me:

>>> import pdfkit
>>> pdfkit.from_url('http://stackoverflow.com', 'out.pdf')

What is your pdfkit and wkhtmltopdf version?

If your job is only calling one simple page, you can also do something like directly:

>>> import os
>>> os.system('wkhtmltopdf http://stackoverflow.com out.pdf')


来源:https://stackoverflow.com/questions/31235759/pdfkit-returns-a-blank-pdf-with-only-requested-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!