I am using Spire to generate Word document using C# backend. I have several HTML fields stored as a string in a database, which I need to generate in a Word document as paragraphs. The following is the code that I am using to generate the particular fields from within a loop:
Spire.Doc.Documents.Paragraph solution = section.AddParagraph();
solution.AppendHTML(inv.solutionResponse);
inv.solutionResponse here is a string which is basically HTML and following is a sample:
<p><span style="font-size:11.0pt;font-family:"Calibri",sans-serif; mso-fareast-font-family:Calibri;mso-bidi-font-family:Calibri;background:yellow; mso-ansi-language:EN-AU;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA">ABCD</span><br></p><p>Some other text</p>
Some of these fields have custom styles as given in the example above. How can I override the custom formatting and apply a default formatting on these. I am mostly concerned about the font size and family. I tried creating a custom style as follows:
p1 = new ParagraphStyle(doc);
p1.Name = "StylePara1";
p1.CharacterFormat.TextColor = Color.Black;
p1.CharacterFormat.FontSize = 12;
p1.CharacterFormat.FontName = "Arial Narrow";
doc.Styles.Add(p1);
and then applied it to the paragraph mentioned above:
solution.ApplyStyle(p1.Name);
But the generated document still contains the style specified in the HTML tags.