One of our users has word templates with nested field codes with have no associated code and are completely redundant, e.g. {{ INCLUDETEXT “D:\Work\TemplateMerging\TestRunner\SignatureBlock.doc” }}.
We were previously replacing field codes with values using a DocumentVisitor.
We have moved to Field.unlink instead to help us with problems with INCLUDETEXT and other types being included multiple times.
This worked a treat, thank you, apart from the {{ … }} fields that aspose doesn’t see.
doc.getFirstSection().getBody().getRange().getFields() is empty as is mailMerge.getFieldNames().
The document visitor doesn’t fire visitField methods either.
As this is entirely consist I assume its intended behavior and our users will need to review all 1800 document templates.
Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:
Your input Word document.
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 simple Java 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.
You can attach the file size up to 10MB with your post. Please do not include the JAR file in the ZIP file. If the documents’ size is greater than 10MB, please ZIP and upload them on Dropbox or any other file hosting service and share the download link here for us to test this scenario.
In your document there is a filed of type FieldUnknown and INCLUDETEXT field is nested field in it. In this case, Field.Unlink method does not work. You need to remove the field of FieldUnknown type by iterating over field’s nodes and remove them.
Thanks for the prompt reply.
I can see a FieldType.FIELD_NONE.
What is FieldUnknown?
I use doc.getFirstSection().getBody().getRange().getFields() to get fields
Gives me fields of type 0, 68 and 2 as I’d expect.
But removing the 0 type with field.remove also removes the nested field and I’m no further forward.