aspose-words / Aspose.Words-for-Java

Aspose.Words for Java examples, plugins and showcases
https://products.aspose.com/words/java
MIT License
404 stars 206 forks source link

Cannot find FindReplaceOptions class #37

Closed Golenko closed 7 years ago

Golenko commented 7 years ago

Hello guys, I'm trying to execute this example

The problem is that classes FindReplaceOptions and FindReplaceDirection are absent from com.aspose.words package.

The version of the jar I use is aspose-words-16.6.0-jdk16.jar

Is that something that expected and example should be updated?

Thanks.

sohail-aspose commented 7 years ago

Hi Golenko, Please use the latest version of Aspose.Words for Java 16.11.0.

I have tested ReplaceWithString example and it is running perfectly fine. I used this file as input and it produces this file as output.

Golenko commented 7 years ago

Thanks for your answer! 16.6.0 is the newest version supported by the license I have. Is there any examples for older versions?

sohail-aspose commented 7 years ago

Yes, three APIs are available in v16.6.0 for “Find and Replace” feature.

replace(Pattern pattern, String replacement) replace(String oldValue, String newValue, boolean isMatchCase, boolean isMatchWholeWord) replace(Pattern pattern, IReplacingCallback handler, boolean isForward)

Example 1:

Document doc = new Document(dataDir + "ReplaceWithString.doc");
doc.getRange().replace(Pattern.compile("[s|m]ad"), "bad");
doc.save(dataDir + "ReplaceWithString_out.doc");

Example 2:

Document doc = new Document(dataDir + "ReplaceWithString.doc");
doc.getRange().replace("sad", "bad", false, true);
doc.save(dataDir + "ReplaceWithString_out.doc");
Golenko commented 7 years ago

Thanks a lot!