I am trying to Save a Word Document as HTML using HtmlSaveOptions. I have added Form Fields in the Word Document and have set the appropriate settings in order to export the Form Fields as HTML Inputs:
public string GetHtmlFromDoc(Stream docStream)
{
using (MemoryStream htmlStream = new MemoryStream())
{
Document document = _wordTools.SetDocumentMargins(new Document(docStream));
document.JoinRunsWithSameFormatting();
document.Save(htmlStream, new HtmlSaveOptions()
{
SaveFormat = SaveFormat.Html,
ExportImagesAsBase64 = true,
ExportFontsAsBase64 = true,
ExportHeadersFootersMode = ExportHeadersFootersMode.None,
ExportDropDownFormFieldAsText = false,
ExportTextInputFormFieldAsText = false,
HtmlVersion = HtmlVersion.Html5
});
return Encoding.UTF8.GetString(htmlStream.ToArray());
}
}
But for some reason the “DropDown” in word is exported as a “SPAN” tag instead of a “SELECT” tag:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="generator" content="Aspose.Words for .NET 19.4" />
<title></title>
</head>
<body>
<div>
<div style="-aw-sdt-tag:''">
<p style="margin-top:0pt; margin-bottom:0pt; font-size:20pt"><span style="font-family:'Arial Narrow'">This is the Word DropDown with 3 Options</span></p>
</div>
<p style="margin-top:0pt; margin-bottom:0pt; font-size:20pt"><span style="font-family:'Arial Narrow'; -aw-import:ignore"> </span></p>
<p style="margin-top:0pt; margin-bottom:0pt; font-size:20pt"><span style="font-family:'Arial Narrow'; -aw-import:ignore"> </span></p>
<p style="margin-top:0pt; margin-bottom:0pt; font-size:20pt"><span style="font-family:'Arial Narrow'">TEst</span></p>
</div>
</body>
</html>
Is this even possible, and if so, how can this be achieved?
Word Document Used to Export as HTML (14.4 KB)