On 20/08/2020 12:24, Ivan Klimek wrote: > Dear webkit-gtk developers, > > I am trying to render a webpage to SVG, I am successful in doing so > using Qt webkit - but as you all know Qt webkit has been discontinued > thus I am trying to migrate my code to webkit GTK > > the problem I am facing is that the generated SVG is only a wrapped PNG > image of the rendered webpage, on Qt the webpage is rendered "all > vector" texts etc all is "vectorized" an example of using this approach > are apps like: http://cutycapt.sourceforge.net/ or https://wkhtmltopdf.org/ > > my code is as follows (parts omitted for brevity): > > g_signal_connect(main_window, "damage-event", G_CALLBACK(capture), > main_window); > > static gboolean capture(GtkWidget *widget, GdkEvent *event, gpointer > user_data) > { > > fprintf(stderr, "damage event callback called..\n"); > > cairo_surface_t *surface = > gtk_offscreen_window_get_surface(GTK_OFFSCREEN_WINDOW(user_data)); >
Instead of getting the cairo surface from GTK, you can use the WebKitGTK API directly with the functions webkit_web_view_get_snapshot* Years ago I wrote a simple program that generates a png image from a webpage with that. Check it here: https://github.com/clopez/wksnap I tried now to use your example code to generate a svg image instead of a png one [1], but I'm getting the same issue you comment of it generating a svg image that is embedding a png one. I'm unsure how to fix that. My limited understanding is that once you get the cairo surface from webkit, that surface is already a bitmap surface.. so I'm unsure if is possible to convert that back to a vector surface. I wonder how QtWebKit did this?? Hope this helps. Regards [1] test patch to apply over wksnap: http://ix.io/2uLb
signature.asc
Description: OpenPGP digital signature
_______________________________________________ webkit-gtk mailing list webkit-gtk@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-gtk