WriteAsEmf

SvgImage.WriteAsEmf method

Saves the SVG image as an EMF file.

public void WriteAsEmf(Stream stream)
ParameterTypeDescription
streamStreamTarget stream

Exceptions

exceptioncondition
ArgumentNullExceptionTarget stream is null

Examples

The following example shows how to save the SVG image to the metafile.

[C#]
// Creates the new SVG image
ISvgImage svgImage = new SvgImage(System.IO.File.ReadAllText("content.svg"));

// Saves the SVG image as a metafille
using (var fileStream = System.IO.File.OpenWrite("SvgAsEmf.emf"))
    svgImage.WriteAsEmf(fileStream);

This sample demonstrates how to add the SVG image as a metafile to the presentation image collection.

[C#]
using (Presentation pres = new Presentation())
{
    // Creates the new SVG image
    ISvgImage svgImage = new SvgImage(System.IO.File.ReadAllText("content.svg"));
    using (var memStream = new MemoryStream())
    {
        // Saves the SVG image as a metafille
        svgImage.WriteAsEmf(memStream);
        // Adds metafile to the image collection
        pres.Images.AddImage(memStream.ToArray());
    }
}

See Also