wkhtmltopdf error

说明

html转个pdf 一堆bug , 有一个记录一个.. python27的, 很抱歉我只找到了原因,没找到解决方案。

bug

执行

>>> import pdfkit
>>> pdfkit.from_file('aa.html', 'out.pdf')

error

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python27/lib/python2.7/site-packages/pdfkit/api.py", line 49, in from_file
    return r.to_pdf(output_path)
  File "/usr/local/python27/lib/python2.7/site-packages/pdfkit/pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
IOError: wkhtmltopdf reported an error:
Loading pages (1/6)
Counting pages (2/6)
Warning: Received createRequest signal on a disposed ResourceObject's NetworkAccessManager. This might be an indication of an iframe taking too long to load.
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: ContentNotFoundError

此时此刻我想… 这里有个警告,貌似什么没加载到 ,如下

Warning: Received createRequest signal on a disposed ResourceObject’s NetworkAccessManager. This might be an indication of an iframe taking too long to load.

执行完命令之后,是生成了pdf的,但是也抛了异常,我想如果拦截异常不处理也是可以的,没发现影响功能。不过还是查了一下….

原因

是因为css文件引用了外部的资源,如:字体,图片,iframe加载等。

我这里是引用了外部的一套字体文件,然后就报了这个错。

你可能感兴趣的:(python,python)