I am trying to change font of a specific word to Italic from word document using Spire.Doc. But code is not giving me the expected result.
Exaample - Albia A et al [l0] and Jain M et al [3] also observed predominance of non-neoplastic lesions with few cases of adenocarcinoma. Incidence of chronic cholecystitis was also comparable to Shah H et al [11], Terada T [12] and Zahrani IH et al [13] who encountered 82.25%, 94.1% and 96.08% cases respectively.
So, from above paragraph only 'et al' should be formatted to Italic, everything else should stay as it is.
Pasting down the code that I have tried below.
Body body = document.Body;
var paragraphs = body.Descendants<Paragraph>();
foreach (Paragraph para in paragraphs)
{
if (para.InnerText.Contains("et al"))
{
var runs = para.Descendants<Run>();
if (runs != null)
{
foreach (Run run in runs)
{
Index index = para.InnerText.IndexOf("et al");
para.Parent.ElementAt(index).AppendChild(new Italic());
}
}
}
}
I am new to using Spire.Doc. Kindly suggest.