How to use the Rsvg.Handle.has_sub function?

148 Views Asked by At

I want use the librsvg to render part of some svg files. When I use those code:

        try {
            handle = new Rsvg.Handle.from_file(inputtext);
        } catch (GLib.Error e) {error ("%s", e.message);}

    if(handle.has_sub("##sub0") && handle.has_sub("##sub1"))
    {sub=0; stdout.printf("found sub0 and sub1.\n");}

nothing happend. of course id="sub0" and id="sub1" is in the svg file, and handle also work (can render whole svg correctlly).

id (str or None) – An element's id within the SVG, or None to render the whole SVG. For example, if you have a layer called “layer1” that you wish to render, pass “##layer1” as the id.

according to https://lazka.github.io/pgi-docs/Rsvg-2.0/classes/Handle.html, search the id in svg need to prefix with "##".

If i use handle.has_sub("sub0"), the code still no work.

0

There are 0 best solutions below