com.aspose.words
Class HtmlMetafileFormat

java.lang.Object
    extended by com.aspose.words.HtmlMetafileFormat

public class HtmlMetafileFormat 
extends java.lang.Object

Utility class containing constants. Indicates the format in which metafiles are saved to HTML documents.

Example:

Shows how to convert SVG objects to a different format when saving HTML documents.
String html =
        "<html>\r\n                    <svg xmlns='http://www.w3.org/2000/svg' width='500' height='40' viewBox='0 0 500 40'>\r\n                        <text x='0' y='35' font-family='Verdana' font-size='35'>Hello world!</text>\r\n                    </svg>\r\n                </html>";

Document doc = new Document(new ByteArrayInputStream(html.getBytes()));

// This document contains a <svg> element in the form of text.
// When we save the document to HTML, we can pass a SaveOptions object
// to determine how the saving operation handles this object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Png" to convert it to a PNG image.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.Svg" preserve it as a SVG object.
// Setting the "MetafileFormat" property to "HtmlMetafileFormat.EmfOrWmf" to convert it to a metafile.
HtmlSaveOptions options = new HtmlSaveOptions();
{
    options.setMetafileFormat(htmlMetafileFormat);
}

doc.save(getArtifactsDir() + "HtmlSaveOptions.MetafileFormat.html", options);

String outDocContents = FileUtils.readFileToString(new File(getArtifactsDir() + "HtmlSaveOptions.MetafileFormat.html"), StandardCharsets.UTF_8);

switch (htmlMetafileFormat) {
    case HtmlMetafileFormat.PNG:
        Assert.assertTrue(outDocContents.contains(
                "<p style=\"margin-top:0pt; margin-bottom:0pt\">" +
                        "<img src=\"HtmlSaveOptions.MetafileFormat.001.png\" width=\"501\" height=\"41\" alt=\"\" " +
                        "style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" +
                        "</p>"));
        break;
    case HtmlMetafileFormat.SVG:
        Assert.assertTrue(outDocContents.contains(
                "<span style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\">" +
                        "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" width=\"499\" height=\"40\">"));
        break;
    case HtmlMetafileFormat.EMF_OR_WMF:
        Assert.assertTrue(outDocContents.contains(
                "<p style=\"margin-top:0pt; margin-bottom:0pt\">" +
                        "<img src=\"HtmlSaveOptions.MetafileFormat.001.emf\" width=\"500\" height=\"40\" alt=\"\" " +
                        "style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />" +
                        "</p>"));
        break;
}

Field Summary
static final intPNG = 0
           Metafiles are rendered to raster PNG images.
static final intSVG = 1
           Metafiles are converted to vector SVG images.
static final intEMF_OR_WMF = 2
           Metafiles are saved as is, without conversion.
 

Field Detail

PNG = 0

public static final int PNG
Metafiles are rendered to raster PNG images.

SVG = 1

public static final int SVG
Metafiles are converted to vector SVG images.

EMF_OR_WMF = 2

public static final int EMF_OR_WMF
Metafiles are saved as is, without conversion.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.