HtmlFixedSaveOptionsEncoding Property

Specifies the encoding to use when exporting to HTML. Default value is new UTF8Encoding(true) (UTF-8 with BOM).

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public Encoding Encoding { get; set; }

Property Value

Type: Encoding


Shows how to set encoding while exporting to HTML.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("Hello World!");

// The default encoding is UTF-8
// If we want to represent our document using a different encoding, we can set one explicitly using a SaveOptions object
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions
    Encoding = Encoding.GetEncoding("ASCII")

Assert.AreEqual("US-ASCII", htmlFixedSaveOptions.Encoding.EncodingName);

doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.UseEncoding.html", htmlFixedSaveOptions);

ExpandedSee Also