开发者

webkit2png.py - Scrollbars always visible

开发者 https://www.devze.com 2023-03-06 09:42 出处:网络
I\'m using the webkit2png.py script to take some screenshots on a headless Linux server. I\'m running into a super annoying issue where the screenshots always have a vertical scrollbar included.

I'm using the webkit2png.py script to take some screenshots on a headless Linux server. I'm running into a super annoying issue where the screenshots always have a vertical scrollbar included.

I'm not too familiar with Python or Qt, but from what I can see in the code, scrollbars should always be disabled:

Starting at line 201:

self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
self._page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
self._page.settings().setUserStyleSheetUrl(QUrl("data:text/css,html,body{overflow-y:hidden !important;}"))

I'm finding it a bit hard to understand the relationship between the size of the X framebuffer created (via the -x option), the "geometry" of the virtual browser window (-g) and the -W (grab full window instead of frame) option. I've tried lots of combinations of these numbers with no success. I think this may have something to do with my problem, although the above code snippet would lead me to believe that scrollbars should NEVER be displayed.

Here's the string of options that I'm using to take a screenshot of say, Facebook's login page:

webkit2png.py -g 1200 900 -x 1200 900 --aspect-ratio=ignore --scale=200 150 -o test.png http://www.facebook.com/

The output of this command produces a screenshot with a vertical scrollbar开发者_StackOverflow, which I don't want.

Can anyone shed some light on this for me?


Turns out this was actually Facebook putting scrollbars in via CSS :/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号