Export SVG with HTML foreignObject

HTML content inside an SVG file is not shown when saving to WebP or PNG using Aspose.Imaging

Example SVG file taken from SVG Embedded Content

<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
    <style>
        div {
            color: grey;
            font: 14px serif;
        }
    </style>
    <circle cx="65" cy="60" r="60" fill="red" fill-opacity="0.1" />
    <foreignObject x="20" y="20" width="200" height="180">
    <!--In the context of HTML embedded in the SVG document, the XHTML namespace is mandatory-->
        <div xmlns="http://www.w3.org/1999/xhtml">
            Convert SVG to PNG. Aspose.SVG for .NET can read and convert SVG files to PNG, PDF, XPS, and major image formats.
        </div>
    </foreignObject>
</svg>

To save as WebP:

var fileStream = new StreamReader($"input.svg").BaseStream;
using SvgImage image = (SvgImage)Image.Load(fileStream);
using FileStream fs = new FileStream("output.webp", FileMode.Create, FileAccess.ReadWrite);
image.Save(fs, new WebPOptions());

Thank you.

@markus.michel

Can you please try using the latest Aspose.Imaging for .NET 21.10 on your end. In case there is still an issue then please share the generated file reproducing the issue.

Thanks for your response.
Issue still exists using Aspose.Imaging version 21.10

Input SVG and generated output WebP files:

foreign-object.zip (3.6 KB)

@markus.michel

We need to investigate this further on our end and a ticket with ID IMAGINGNET-4863 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hello, @markus.michel
We apologize for the long silence on this issue.
Regarding your question, we can inform you of the following:

  1. Aspose.Imaging does not support embedded HTML in SVG and its support is not planned.
  2. If you need this functionality, then please pay attention to Aspose.SVG
    that implements the required functionality. Besides Aspose.SVG allows you to export SVG
    to various raster formats, for example, PNG.

Please familiarize yourself with the supported formats here