简体   繁体   English

pdfkit-返回仅包含请求URL的空白pdf

[英]pdfkit - returns a blank pdf with only requested URL

I'm trying to render a webpage with pdfkit 我正在尝试使用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. 但这只会返回一个空白的pdf,顶部是请求的URL。

When in terminal I run wkhtmltopdf directly... 在终端中时,我直接运行wkhtmltopdf ...

wkhtmltopdf http://stackoverflow.com so2.pdf

It renders fine 效果很好

What am I doing wrong? 我究竟做错了什么?

This works fine with me: 这对我很好:

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

What is your pdfkit and wkhtmltopdf version? 您的pdfkitwkhtmltopdf版本是什么?

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')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM