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

Free Support Forum - aspose.com

Save as Mhtml FormDropDowns are not replaced

Hello,


I use ExportTextInputFormFieldAsText=true from HtmlSaveOptions to get rid of Form Text Fields { FORMTEXT } when saving Word documents as Mhtml, but Form Dropdown Fields { FORMDROPDOWN } were not removed/replaced. I would expect that ExportTextInputFormFieldsAsText setting would cover DropDown Fields too, which it doesn’t.

best regards
Alex

Hi Alex,


Thanks for your inquiry. Yes, you’re right. The HtmlSaveOptions.ExportTextInputFormFieldAsText property only controls how text input form fields are saved to HTML or MHTML. It does not has any affect on DropDown Form Fields. May be, you can achieve what you need after reading the article suggested below:
http://www.aspose.com/docs/display/wordsnet/How+to++Replace+Fields+with+Static+Text

I hope, this helps.

Best regards,

Hi Awais,


Thanks for your answer. I tried the code snippet to replace fields with static text as described in the docs you have mentioned. I ran into the same problem as Will described in the comments, the nextParagraph is null in the while loop in the VisitParagraphEnd method. Adarn Skelton replied to the comment that the code should work as there should always be paragraph where the fields ends on. I tried to convert FieldType.FieldFormDropDown, FieldType.FieldFormTextInput and FieldType.FieldIf field types to static text.

best regards
Alex

Hi Alex,


Thanks for the additional information. I tested the scenario and have managed to reproduce the same problem on my side. We will improve the code mentioned in this article in future, I have logged this issue in our issue tracking system as WORDSNET-8656. We apologize for your inconvenience.

To workaround this problem, please try run the following code snippet:

Document doc = new
Document(@“C:\Temp\RenderingTest_OhneCustomXml.doc”);

foreach (FormField field in doc.Range.FormFields)

{

if (field.Type == FieldType.FieldFormDropDown)

{

Run run = new Run(doc, field.Result);

Node currentNode = field;

while (currentNode != null && currentNode.NodeType != NodeType.FieldStart)

currentNode = currentNode.PreviousSibling;

field.ParentParagraph.InsertBefore(run, currentNode);

field.Remove();

}

}


doc.Save(@"C:\Temp\out.mhtml");


I hope, this helps.

Best regards,