The SVG backend is starting to look good. It would be neat if it also supported
the SVGPrint standard (http://www.w3.org/TR/SVGPrint/). It maps cleanly onto
cairo's show_page API and for single-page outputs, tools like librsvg can still
load the documents.
Patch on the way.
Created attachment 4068 [details] [review]
patch to implement a svg-print backend
FYI - this patch also corrects a small buglet - s/cairo_format_t/cairo_content_t
Created attachment 4289 [details] [review]
Reassign to Emmanuel
I would be happy to add multi-page capability to SVG backend, but unfortunately,
it seems inkscape currently doesn't support SVG-Print, and I really want to be
able to open SVG files produced by cairo with it.
An idea would be to stick to current output, and switch to SVG-Print as soon as
document has more than one page.
That sounds reasonable. I'll modify my patch to do this.
Created attachment 4501 [details] [review]
Only emits <pageSet> if there is more than one page
This should hopefully be more to your liking.
Your patch breaks compositing of svg surfaces.
+ surface->xml_node = xmlNewChild (surface->document->xml_node_main,
+ NULL, CC2XML ("g"), NULL);
When you had before:
- surface->xml_node = xmlNewChild (surface->id == 0 ?
- document->xml_node_main :
- NULL, CC2XML ("g"), NULL);
And in one page svg, there's a useless <g> </g> around main surface.
Otherwise, it's ok to commit.
Created attachment 4504 [details] [review]
New patch - should fix compositing
The extra "g" around the content is a harmless artifact. I needed a node to put
the whole page's content into before adding it to the <page> or <svg>, as
This patch should fix compositing of SVG surfaces. The new ID scheme for
surfaces is "surface" + surface->id + "-" + number_of_pages. This way, we keep
the surface0 == primary surface distinction, plus generate unique ids for each
If you change naming convention here:
+ snprintf (buffer, sizeof buffer, "surface%d-%d", surface->id,
+ _cairo_array_num_elements (&surface->document->pages));
You also need to adapt this code:
child = xmlNewChild (node, NULL, CC2XML("use"), NULL);
snprintf (buffer, sizeof buffer, "#surface%d", surface->id);
xmlSetProp (child, CC2XML ("xlink:href"), C2XML (buffer));
Not that creating a similar svg surface with cairo_surface_create_similar during
drawing of one page, and painting it on an another page may happen, so you need
to store the second id.
Created attachment 7761 [details] [review]
An new patch
Pushed to master.
on Jun 29, 2016 at 16:17:17.
(provided by the Example extension).