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

Free Support Forum - aspose.com

Insert html in Run?


Is it possible to insert html in run (paragraph)??

Run run = new Run(doc, textToInsert);
run.Font.Style = doc.Styles[“PFS_DATA”];
run.Font.Color = Color.Black;


Actually, the variable “textToInsert” is a plain text, but our client wants to insert html text. Is it possible to do that?? Or do you have a workaround to be able to insert html??

Thank you


Hi Steeve,

Thanks for your inquiry. Yes, you can insert html at the place of Run node in a Paragraph of document. Please note that, content inserted by DocumentBuilder.InsertHtml method does not inherit formatting specified in DocumentBuilder options. Whole formatting is taken from HTML snippet. If you insert HTML with no formatting specified, then default formatting is used for inserted content.

Please use the following code snippet to insert html at Run node. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");

DocumentBuilder builder = new DocumentBuilder(doc);

Paragraph para = doc.FirstSection.Body.FirstParagraph;

Run run = new Run(doc, "");





Paragraph right

" +

"Implicit paragraph left" +


Div center
" +


Heading 1 left.


doc.Save(MyDir + "out.docx");