Find Keyword in Template Word Document & Replace with Text with Word “country” | Java

Hi,
I have a WORD document which I am using as template and using Aspose WORD Java jdk,
I am trying to find/replace some text in the document, the new text has word “country”,
after replacing when I save the document as DOCX, they “country” is changed to “-ry”,
looks like it is trying replacing the “count” with some value, and final document ends up like “-ry” instead of “country”.

Asponse Java SKD version aspose-words-18.6-jdk16.jar
Method using to save document document.save(outputStream, SaveFormat.DOCX);
Method using to replace text range. .replace(“type_name”, typeNames, new FindReplaceOptions())

Please advise,
Thanks.

@saifidrees,

Please upgrade to the latest (21.5) version of Aspose.Words for Java and see how it goes on your end? In case the problem still remains, then please compress the following resources into ZIP format and attach the .zip file here for testing:

  • Your simplified template Word document
  • Aspose.Words for Java 21.5 generated output DOCX file showing the undesired behavior
  • Your expected DOCX file showing the desired output. You can create this expected document manually by using MS Word.
  • Please also create a standalone simplified Java Application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the ZIP file size.

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