[cairo] SVG, links
mpsuzuki
mpsuzuki at hiroshima-u.ac.jp
Sun Mar 2 10:10:28 UTC 2025
https://www.cairographics.org/manual/cairo-SVG-Surfaces.html
has a note:
> Creates a SVG surface of the specified size in points to be written to filename .
>
> The SVG surface backend recognizes the following MIME types for the data attached to a surface (see cairo_surface_set_mime_data()) when it is used as a source pattern for drawing on this surface: CAIRO_MIME_TYPE_JPEG, CAIRO_MIME_TYPE_PNG, CAIRO_MIME_TYPE_URI. If any of them is specified, the SVG backend emits a href with the content of MIME data instead of a surface snapshot (PNG, Base64-encoded) in the corresponding image tag.
>
> The unofficial MIME type CAIRO_MIME_TYPE_URI is examined first. If present, the URI is emitted as is: assuring the correctness of URI is left to the client code.
>
> If CAIRO_MIME_TYPE_URI is not present, but CAIRO_MIME_TYPE_JPEG or CAIRO_MIME_TYPE_PNG is specified, the corresponding data is Base64-encoded and emitted.
>
> If CAIRO_MIME_TYPE_UNIQUE_ID is present, all surfaces with the same unique identifier will only be embedded once.
I hope if it can help you, although I've not tested by my hands.
Regards,
mpsuzuki
On 2025/03/02 6:18, Tomas By wrote:
> Hi all,
>
> I am using the C API to write both PNG and SVG from the same image
> (created using Cairo). The PNG looks fine, but the SVG is a very short
> file with a "href" data/image, apparently linking to some external
> resource.
>
> Is there no way to get a complete SVG file with no links to anything
> else? The Cairo SVG surface API does not seem to contain anything that
> looks useful for this purpose.
>
> (I do not have the code on this machine.)
>
> /Tomas
More information about the cairo
mailing list