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

Free Support Forum - aspose.com

Convert Text Form Field to HTML does not convert Font

When converting the attached word template to HTML, the text form field font (Arial Black) is not converted to HTML and it applies the default font instead

Salutation.zip (22.1 KB)

@vecin2

We have tested the scenario using the latest version of Aspose.Words for .NET 21.7 with following code example and have not found the shared issue. So, please use Aspose.Words for .NET 21.7.

Document doc = new Document(MyDir + "Salutation.dotx");
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html)
{
    ExportTextInputFormFieldAsText = true
};

doc.Save(MyDir + @"21.7.html", options); 

Thanks very much for your response.

I did test your code in the JAVA version, and it keeps the font as you said.

However, in our case we prefer to generate the FormFields as inputs (as opposed to text), is there anyway to keep font-family in this scenario?

Another reason to save the form fields as html inputs is that when saving the file back to ‘SalutationConvertedFromOptions.dotx’ the form field is lost and ‘Salutation’ and it shows as a regular text instead of the original form field. Is this expected when ExportTextInputFormFieldAsText is set true?:

String docname="Salutation.dotx";
Document doc = new Document(docname);
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
options.setExportTextInputFormFieldAsText(true);
doc.save("SalutationConvertedWithOptions.html",options);
Document doc2 = new Document("SalutationConvertedWithOptions.html");
doc2.save("SalutationConvertedFromOptions.dotx");

@vecin2

Could you please ZIP and attach your expected output HTML here for our reference? We will then provide you more information on it.

Please find attached two tests: the first one converts a form field to html “as input” and the second one converts it “as text”.
We are particularly interesting in the first case, as we want to show to users the HTML with inputs.

The first case shows how the font-family within the form field is lost when converting to HTML also when converting back to .dotx

The second case shows how the form field itself is lost when converting back to .dotx

For the first case we would expect that the font family to be converted to HTML and it is showing with the correct font when viewing the Web page. Then when converting it back to .dotx should restore to the original font-family.
asposeSupportTests.zip (179.0 KB)

@vecin2

We have logged a new feature request to keep the font formatting of form field after DOTX>HTML>DOTX conversion. The feature ID is WORDSNET-22555. We will inform you via this forum thread once there is an update available on it.