1

I use cefpython inside PySide on Python 2.7. To create advanced 3d transitions between div's I have to cut the div in e.g. 20 parts which I can animate separately. I found no way to do that "natively" so I have to simulate the split by taking a screenshot of a specific element in the dom (I could also take a screenshot of the whole dom and cut out the required element by coordinates.).

How can I take a screenshot of a specific div in my DOM or how could I take a screenshot of the whole visibile part of a Webpage in cefpython and PySide.

JavaScript functions often just render the html into a picture but I need a completely real picture since the user should not know that the animation is created from a picture instead of a real div.

Is there an easy way to capture an element (or the whole currently visible part) of a Webpage using cefpython and PySide (or JavaScript and HTML)?

( By the way: Cefpython embed a chromium browser into PySide.)

fameman
  • 3,451
  • 1
  • 19
  • 31
  • Have you looked at [this question](http://stackoverflow.com/questions/6887183/how-to-take-screenshot-of-a-div-with-javascript?rq=1)? – Pointy Jan 28 '17 at 16:14
  • Wow! I searched for hours on the web and did not see this solution?! (Maybe wrong Keywords). I will try it out. Thank you. – fameman Jan 28 '17 at 16:20
  • Sorry, but that doesn't fit to my problem. __I Need a completely similar representation of my Webpage in the Picture - I already said that Rendering are not always correct.__ – fameman Jan 28 '17 at 16:33

1 Answers1

1

You can render contents of the window that embeds a browser to a bitmap. In pyqt/pyside you can render QWidget to QImage. For an example google "qwidget to qimage": https://www.google.com/search?q=qwidget+to+qimage

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56