添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
酷酷的紫菜  ·  Error : ...·  3 天前    · 
痴情的帽子  ·  博弈论(Game ...·  4 周前    · 
善良的牛腩  ·  ISRC申报平台 - ...·  10 月前    · 

We've been running into a problem recently, some pages don't seem to work when the --height option is omitted (or manually set to 0)

D:\Tools>wkhtmltoimage.exe -V
wkhtmltoimage 0.12.2.1 (with patched qt)

Without the --height option:

D:\Tools>wkhtmltoimage.exe http://www.reanmachine.com/this-is-a-test/ d:\out.png
Loading page (1/2)
Rendering (2/2)
Error: Will not output an empty image
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::translate: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setBrush: Painter not active
QPainter::pen: Painter not active
QPainter::setPen: Painter not active
QPainter::end: Painter not active, aborted
Error: Could not save image
Exit with code 1, due to unknown error.

With the --height option:

D:\Tools>wkhtmltoimage.exe --height 1000 http://www.reanmachine.com/this-is-a-test/ d:\out.png
Loading page (1/2)
Rendering (2/2)

This is problematic since we don't know the target height, it should be inferring it from the rendered content.

This occurs on Windows 8.1, Windows 2008 R2, and Windows 2012

Here's some further information to help narrow down the problem:

It seems this combination of CSS was causing the tool to get a 0-height (null image?)

html { overflow-x: hidden; }
body { overflow-x: hidden; }

You can demo it by trying to render this page:

http://jsbin.com/cagus/1

It seems this is a behavior being used in mobile-first design to prevent horizontal scrolling in all cases:

https://stackoverflow.com/questions/8635799/overflow-xhidden-still-can-scroll

It's prevelant in many modern site designs.

Here's some further information to help narrow down the problem:

It seems this combination of CSS was causing the tool to get a 0-height (null image?)

html { overflow-x: hidden; }
body { overflow-x: hidden; }

You can demo it by trying to render this page:

http://jsbin.com/cagus/1

It seems this is a behavior being used in mobile-first design to prevent horizontal scrolling in all cases:

https://stackoverflow.com/questions/8635799/overflow-xhidden-still-can-scroll

It's prevelant in many modern site designs.

this works
thanks bro