Hello
About the library:
The error occurs with “Aspose-Word for Java”, version 16.3 or 17.3.
It works correctly though with the old version 13.9.0.0, which I used earlier.
Error Description:
When searching and replacing a text placeholder that is present in the document more than once, the placeholders are found and replaced in the wrong order: First, the text placeholders that are placed directly in the document (i.e. in a paragraph), and then the ones wrapped in the table.
I expect the placeholders to be found from top to bottom of the document (it used to work that way earlier).
Effect:
As soon as a customer changes within a report, data from customers is shown mixed.
Steps to reproduction:
I have prepared a simple example with the erroneous scenario: please see the archive file “FindAndReplaceBug.zip”. Comments can be found in the source code.
At startup, input.docx is read and the 5 placeholders found within it are being replaced. The result is saved to output.docx.
Currently I’m using the method “com.aspose.words.Range.replace(Pattern pattern, String replacement, FindReplaceOptions options)”.
Further information:
I used to work with the method “com.aspose.words.Range. replace(Pattern, IReplacingCallback, boolean)” which is deprecated in the current version. Regarding the order (of placeholder processing) it works correctly with the aforementioned method, but sadly another error occurs occasionally when it gets called (please see my older post “java.lang.IllegalStateException: Cannot perform further replacements since the document has been changed.” for more details).
I would be grateful for a swift solution to my problem.
Best regards,
Alexander Lyalin
Eudemonia-Solutions.AG