[webkit-dev] [webkit/webkitgtk newbie] Headless rendering

Julien Sanchez julien.sanchez at limgeo.com
Mon May 5 06:28:05 PDT 2008


First I would like to thank webkit developers and testers for their
wonderful work.
I'm trying to understand the webkit code and more especially the
webkitgtk part. Bit by bit, I get the picture of the architecture but
it's not as easy as I would hope ;)

Currently, I wonder if there's already a way to use the webkitgtk API
"offscreen". For example, it would be useful in "headless" applications
to print or to render a web page into a Cairo surface from the command
line. I plan to do such an application later.
I have found the following thread:
but I don't know if it is possible to use a webkitwebframe without
initializing the GTK widget webkitwebview.

It's not the right elegant thing to do but for the moment, I had tried
something like that:

// web_view initialized with webkit_web_view_new()
WebCore::Frame* coreframe =
coreframe->view()->resize(800, 600);
int content_width = coreframe->view()->contentsWidth();
int content_height = coreframe->view()->contentsHeight();
cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
content_width, content_height);
cairo_t* cr_surf = cairo_create(surf);
WebCore::GraphicsContext ctx_surf(cr_surf); 
WebCore::IntRect rect(0, 0, content_width, content_height);
coreframe->paint(&ctx_surf, rect);
cairo_surface_write_to_png(surf, "webkitsurf.png");

but of course it didn't work (empty image). I'm stuck. Does someone give
me any clue where I should begin?



More information about the webkit-dev mailing list