We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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 https://docs.aspose.com/svg/net/drawing-basics/embedded-content/#html-inside-svg

<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg">
        div {
            color: grey;
            font: 14px serif;
    <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.

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.


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)


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.