Field unlink Not working on some documents

Hi,

I am using Aspose.Words to Replace merge fields with Static Text using the code in

public static void ConvertFieldsToStaticText(CompositeNode compositeNode, FieldType targetFieldType)
{
	compositeNode.Range.Fields.Cast<Field>().Where(f => f.Type == targetFieldType).ToList().ForEach(f => f.Unlink());
}

however instead of getting the value of the field in the resulting document, I get the name of the merge field (example: «MERGEFIELD_name» instead of the value of the merge field).

I have attached a sample doument that has the issue. Any help will be greatly appreciated,

test.zip (16.5 KB)

thanks

looks like the issue was because I was calling asposeDocument.UpdateFields(); before calling ConvertFieldsToStaticText.

@zenlang

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.