Dear all,
I want to use QWebEngineView to create a screenshot of a complete web
page. This is mostly working for “shorter pages”, but it is not working
for longer pages.
The only solution to take a screenshot of a complete webpage is to
resize the QWebEngineView to the contentSize of QWebEnginePage. The
following code is working for shorter pages (self inherits QWebEngineView):
size = self.page().contentsSize().toSize()
self.resize(size)
QTimer.singleShot(2000, lambda: self.take_screenshot(size))
def take_screenshot(self, size):
img = QImage(size, QImage.Format_ARGB32)
self.render(img)
img.save(self.save_file)
The timer is only there to have enough time to resize the widget.
This code generates a full-web-page screenshot for most pages, such as
slashdort.org. But when visiting https://thetechportal.com/ and
scrolling down several times, so that additional content is loaded, the
code line
self.resize(size)
generates the following errors:
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete attachment.
QOpenGLFramebufferObject: Framebuffer incomplete, missing attachment.
[13092:9676:0908/151509.277:ERROR:gles2_cmd_decoder.cc(5678)]
GLES2DecoderImpl::ResizeOffscreenFramebuffer failed to allocate
storage due to excessive dimensions.
[13092:9676:0908/151509.278:ERROR:gles2_cmd_decoder.cc(5827)]
GLES2DecoderImpl: Context lost because ResizeOffscreenFramebuffer
failed.
[13092:9676:0908/151509.278:ERROR:gles2_cmd_decoder.cc(5963)] Error:
5 for Command kResizeCHROMIUM
This error can be reproduced with longer Facebook timelines as well.
The gles2 errors (the last three lines) are repeated indefinitely. I
have not found a way to fix this. I have checked that the page is not
bigger than the maximum size of the widget.
I am running Windows 10, Python 3.8.1, PySide2 5.14.2.3.
Is this a bug in PySide2 / Qt or how can I take a screenshot of a longer
page? I have tried this example with PyQt as well and ran into the same
errors…
Thanks for any help.
Best Regards
Dennis
_______________________________________________
PySide mailing list
PySide@qt-project.org
https://lists.qt-project.org/listinfo/pyside