[webkit-gtk] Taking full webpage screenshots

Chandra Siva chandra at zappli.com
Thu Aug 11 02:28:27 PDT 2011


Hi:

I am attempting to take a full webpage screenshot of a browser (uzbl) that uses WebKitGTK+ similar to the way CutyCapt (http://cutycapt.sourceforge.net/) does it with WebKitQT

This is the code I have so far and with this I am only able to get the visible parts of the browser in the screenshot. What is the best way to get a snapshot of the entire webpage ?

Thanks a LOT in advance.
void
screenshot(WebKitWebView *page, GArray *argv, GString *result) {
(void) result;

if(argv->len < 1)
return;

if (uzbl.state.verbose) {
printf("about to take a screenshot and save to file: %s\n",argv_idx(argv,0));
}

GdkWindow * window;
GdkColormap * colormap;
gint width;
gint height;
GdkPixbuf * pixbuf;

g_object_get(G_OBJECT(page), "window", &window, NULL);
gdk_window_get_size(GDK_WINDOW(window), &width, &height);
colormap = gdk_window_get_colormap(GDK_WINDOW(window));

/* gdk-pixbuf api: http://library.gnome.org/devel/gdk-pixbuf/stable/ */
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
gdk_pixbuf_get_from_drawable(pixbuf, GDK_DRAWABLE(window), colormap,
0, 0, 0, 0, width , height);
gdk_pixbuf_save(pixbuf, argv_idx(argv,0), "png", NULL, NULL);
g_object_unref(G_OBJECT(pixbuf));

if (uzbl.state.verbose) {
printf("saved PNG into %s\n", argv_idx(argv,0));
}
}



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20110811/1ec157f7/attachment.html>


More information about the webkit-gtk mailing list