[webkit-help] Rendering HTML page to bitmap

Nick Guenther Nick.Guenther at dossierview.com
Wed Jul 13 14:27:34 PDT 2011

As I understand it, rendering *only* happens within a View. Webkit is meant for speed, it's not like it's going to render things that aren't going to be seen. On Windows the only place the bitmap of the webpage gets created is during a WM_PAINT or WM_PRINT (I know, I had to hook in that code before an svn revision added what I'd added), except for then the bitmap doesn't exist, so the only way to render all the contents, not just those within the viewport, is to render everything within the viewport. You'll have to create your view with a fixed width and an excessively long height, tell it to render, and hope for the best.

I've written the same thing on Windows and we ended up discovering (in a moment of duh) that pages will react badly to being resized after the fact so there are two reasons to pick your rendering size at the outset. I originally wanted to load a page and then ask webkit what its size should be, but there is no reasonable way to snag that because some pages are designed for fixed layouts and others are designed for fluidity and there really isn't much you can do except pick a size and run with it.

QtWebKit allows asking for the natural size of a webpage but WebKit2 doesn't yet unfortunately. Does CEF? If it does then you can just that information to clip the bitmap once it's done rendering.

-Nick Guenther

From: webkit-help-bounces at lists.webkit.org [mailto:webkit-help-bounces at lists.webkit.org] On Behalf Of Matthew Johnson
Sent: Wednesday, July 13, 2011 5:17 PM
To: webkit-help at lists.webkit.org
Subject: [webkit-help] Rendering HTML page to bitmap

I'd like to be able to render the full contents of a page to a bitmap, not just the contents within the viewport.  Is this possible?

I have been using chromiumembedded framework (CEF) to deal with WebKit and get the bitmap (CefBrowser::GetImage), but I can either get an bitmap of the viewport area only or resize the WebView and then get a bitmap of the full page contents.  The latter results in changes to the web page layout on many pages due to a different viewport size after the resize.

Using the WebKit APIs is there a way to get a bitmap of the full contents of a web page - at a given point in time - without resorting to resizing the WebView?

Ideally, I could capture the full WebView in a single bitmap.  But I could resort to scrolling around the page and tiling the respective bitmaps together if I can prevent it from performing any layout on the page while doing so.

Anybody have any good ways to tackle this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20110713/b73c93cd/attachment.html>

More information about the webkit-help mailing list