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

Free Support Forum - aspose.com

Unable to find Range FormFields in html WORD document

Please advise why Apose.Words can't find the JURIS_a_343_C_1 text form field in the .html file in attached zip. Apose.Words does find the form field if I use MS WORD to save the html file to docx format, as in the .docx file in attached zip. Aspose.Words still can't find the form field if I save it from html file to docx file using Aspose.Words.

Here's snippet of .Net code I am using:

Aspose.Words.Document docFile = new Aspose.Words.DocumentBuilder(sourceFilePath);
Aspose.Words.Fields.FormFieldCollection docFields = docFile.Range.FormFields;

Hi Janet,


Thanks for your inquiry. Please note that Aspose.Words tries to mimic the same behavior as MS Word do. Apose.Words converts the MS Word documents to html (“Web Page, Filtered”). Please convert your document to HTML (“Web Page, Filtered”) by using MS Word and check the HTML output. Please find the list of Field Features supported upon HTML exporting/importing from here:
http://www.aspose.com/docs/display/wordsnet/Field+Features+Supported+on+HTML+Import
http://www.aspose.com/docs/display/wordsnet/Field+Features+Supported+on+HTML+Export

In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.3.0) from here:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/entry455473.aspx

I suggest you please read the memebers of HtmlSaveOptions class from here:
http://www.aspose.com/docs/display/wordsnet/HtmlSaveOptions+Members

Please check the following code snippet for your kind reference.

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> doc = new Document(MyDir

  • “myform.docx”);<o:p></o:p>

HtmlSaveOptions option = new HtmlSaveOptions();

//Controls how text input form fields are saved to HTML or MHTML. Default value is false.

option.ExportTextInputFormFieldAsText = false;

doc.Save(MyDir + "out.html", option);

Document docHtml = new Document(MyDir + "out.html");

foreach (FormField field in docHtml.Range.FormFields)

{

if (field.TextInputType == TextFormFieldType.Regular)

{

Console.Write(field.Name);

}

}

Thanks for the information, but it doesn’t solve my original problem. I upgraded to the latest Aspose.Words version (v13.3.0) and retried test with original attached html file. myform.html is a MS WORD web page file (not-filtered) containing the JURIS_a_343_C_1 form field. I need to be able to load this file via Aspose.Words and find the form field(s) to replace content. Using the original snippet of code I included before, the Range.FormFields is empty, so Aspose.Words is not finding the form field in this html document. I had previously read the documentation you pointed me to, and it seems to imply that form fields should work in this type of html file. Please advise how I can get this done or fixed.

Hi Janet,


Thanks for your inquiry. Please note that there is an option to export form fields as dynamic fields in HTML as and tags or to export them as plain text.

HtmlSaveOptions option = new HtmlSaveOptions();
option.ExportTextInputFormFieldAsText = false;
-------------------------
Result:


Only and tags are imported back as fields. The input types that have direct Microsoft Word analogs are imported as working form fields.

Radio and image input elements are imported as image shapes and are non-clickable. Input elements attributed with hidden or disabled are not imported. I suggest you please read the memebers of HtmlSaveOptions class from here:
http://www.aspose.com/docs/display/wordsnet/HtmlSaveOptions+Members