We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Form Fields not exporting as HTML Inputs

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">&#xa0;</span></p>
         <p style="margin-top:0pt; margin-bottom:0pt; font-size:20pt"><span style="font-family:'Arial Narrow'; -aw-import:ignore">&#xa0;</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)

@RuanVM

The HtmlSaveOptions.ExportDropDownFormFieldAsText is used for FormField ( DropDown ) and you are using content controls (StructuredDocumentTag).

Unfortunately, Aspose.Words does not convert content control ( ComboBox and DropDownList ) to HTML Select tag. However, we logged this feature request as WORDSNET-11542 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-11542) have been fixed in this Aspose.Words for .NET 21.11 update also available on NuGet.