How to remove the Underline and Blue Color in specific word in whole string in Aspose word document?

Hi,

we are using aspose-word version 14.12.0.0. Our requirement is existing word document, we want to the Underline and Blue Color in specific word in whole string in Aspose word document. How can i achieve this and also we attached the sample project and screen shots for your review.

We are using following code for this requirements.

string File = “C:\UnderlineIssue.Docx”;
Aspose.Words.Document doc = new Aspose.Words.Document(File);

Run run = new Run(doc, “Test Enhanced Tiered Plan 5300/6300/0%/40%”);
run.Font.Underline = Underline.None;

System.IO.MemoryStream outStream = new System.IO.MemoryStream();
doc.Save(outStream, Aspose.Words.SaveFormat.Docx);

byte[] docBytes = null;

docBytes = outStream.ToArray();
FileStream output = new FileStream(“C:\UnderlineIssue1.Docx”, FileMode.Create,
FileAccess.Write);
// Write byte array contents in the output file stream
output.Write(docBytes, 0, docBytes.Length);
// Close output file
output.Close();

Note: Please include the dll aspose-word version 14.12.0.0.
I need Solution for aspose-word version 14.12.0.0, No need higher version.

UnderlineIssue.jpeg (24.0 KB)
UnderlineIssue.zip (824.5 KB)

@smani

Thanks for your inquiry. In your case, we suggest you following solution.

  1. Please implement IReplacingCallback interface to find the specific word.
  2. In IReplacingCallback.Replacing, get the matched node using ReplacingArgs.MatchNode property. Please use Run.Font property to set the text formatting.

The code example shared in following article highlights the text. You can use the same code example to get the matched Run nodes and set font formatting.
How to Find and Highlight Text

In the code example shared in above article, please replace following foreach loop

foreach (Run run in runs)
 run.Font.HighlightColor = Color.Yellow;

with:

foreach (Run run in runs)
{
    run.Font.Color = Color.Black;
    run.Font.Underline = Underline.None;
}

@ [tahir.manzoor]

we are using aspose-word version 14.12.0.0. But your solution is latest version. We need solution aspose-word version 14.12.0.0. Please share me the sample projects or update the our attached the projects.

Need solution asap,One of our customer is waiting for this solution.

@smani,

Thanks for your inquiry. Please note that we do not provide support for older released versions of Aspose.Words. Moreover, we do not provide any fixes or patches for old versions of Aspose products either. All fixes and new features are always added into new versions of our products.

You can use the obsolete Range.Replace method to achieve your requirement. However, we always encourage our customers to use the latest version of Aspose.Words as it contains newly introduced features, enhancements, and fixes to the issues that were reported earlier.