HtmlSaveOptionsMetafileFormat Property |
Namespace: Aspose.Words.Saving
Metafiles are not natively displayed by HTML browsers. By default, Aspose.Words converts WMF and EMF images into PNG files when exporting to HTML. Other options are to convert metafiles to SVG images or to export them as is without conversion.
Some image transforms, in particular image cropping, will not be applied to metafile images if they are exported to HTML without conversion.
// Create a document from an html string string html = @"<html> <svg xmlns='http://www.w3.org/2000/svg' width='500' height='40' viewBox='0 0 500 40'> <text x='0' y='35' font-family='Verdana' font-size='35'>Hello world!</text> </svg> </html>"; Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html))); // This document contains a <svg> element in the form of text, // which by default will be saved as a linked external .png when we save the document as html // We can save with a HtmlSaveOptions object with this flag set to preserve the <svg> tag HtmlSaveOptions options = new HtmlSaveOptions(); options.MetafileFormat = HtmlMetafileFormat.Svg; doc.Save(ArtifactsDir + "HtmlSaveOptions.MetafileFormat.html", options);