We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word Doc - Convert oll shading to highlight

Hi,

How can I process word document to convert all text shading to text highlight. I mean replacing text shading with text highlight in word document.

Thanks,
Hemant

@hemant_thote You can use code like the following code to convert shading background color to highlight color:

Document doc = new Document();
DocumentBuilder builer = new DocumentBuilder(doc);
builer.InsertHtml("<p><span style=\"font-family: Arial, Helvetica, sans-serif;\"><span style=\"font-size: 14pt;\">This is hemant test. Here is <span style=\"background-color: rgb(255, 255, 0);\">highlighted text</span></span></span></p>");

NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);
foreach (Run run in runs)
{
    if (!run.Font.Shading.BackgroundPatternColor.IsEmpty)
    {
        run.Font.HighlightColor = run.Font.Shading.BackgroundPatternColor;
        run.Font.Shading.BackgroundPatternColor = Color.Empty;
    }
}

doc.Save(@"C:\Temp\out.docx");