FindReplaceOptions findReplaceOptions = new FindReplaceOptions();

Hello,

I’m currently evaluating Aspose.Words (24.7.0) to create a ‘Word - Search and Replace Text’ function, I have also tried the latest version of the library. Unfortunately, the FindReplaceOptions() class is a bit temperamental depending on the document in which I use. When I replace text with existing font styling such as underline or italic and set the relevant save option to false it does not replace the text with no replacement save option set, but instead inherits the original formatting. So as an example, if the searched text is found which is underlined and I replace the text with the findReplaceOptions.ApplyFont.Underline = Underline.None set then the underline remains present even though the text has been updated correctly.

Please see my console app image, and two attached Word Documents.

When using TestSmallDoc.docx as input, it appears to output correctly, apart from ‘Shadow’ and ‘Outline’, all the other options work as intended.

When using TestLargeDoc.docx I’ve found that none of the highlighted text is replaced with text that has no styling (underline, italic etc.) when I set the save options to false.

Please advise how I can resolve this?

Kind regards,

djs

TestLargeDoc.docx (69.4 KB)

TestSmallDoc.docx (13.7 KB)

@djsomers1000 Regarding shadow, glow, outline and reflection DML effects of text. Unfortunately, currently there is no public API to work with them. This feature is logged as WORDSNET-20812.

Regarding the big document.

  1. DELIVERY text is formatted with AllCaps option. Most likely you are searching for DELIVERY text, but actual text in the document is delivery. So you should either disable FindReplaceOptions.MatchCase option or search for text in lowercase.

  2. All the words you have highlighted has revisions. FindReplaceOptions.ApplyFont is applied to the original text formatting, so revised formatting remains unchanged. So you should accept revisions before replacing to see the changes applied using FindReplaceOptions.ApplyFont. You can also see the changes by rejecting revision in the final document.