DocumentBuilderInsertHtml Method (String, Boolean)
Inserts an HTML string into the document.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
public void InsertHtml(
	string html,
	bool useBuilderFormatting


Type: SystemString
An HTML string to insert into the document.
Type: SystemBoolean
A value indicating whether formatting specified in DocumentBuilder is used as base formatting for text imported from HTML.

You can use InsertHtml to insert an HTML fragment or whole HTML document.


When useBuilderFormatting is false, DocumentBuilder formating is ignored and formatting of inserted text is based on default HTML formatting. As a result, the text looks as it is rendered in browsers.

When useBuilderFormatting is true, formatting of inserted text is based on DocumentBuilder formatting, and the text looks as if it were inserted with Write(String).

Inserts HTML into a document using. The current document formatting at the insertion position is applied to the inserted text.
Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
    "<P align='right'>Paragraph right</P>" + "<b>Implicit paragraph left</b>" +
    "<div align='center'>Div center</div>" + "<h1 align='left'>Heading 1 left.</h1>", true);

doc.Save(ArtifactsDir + "DocumentBuilder.InsertHtml.doc");
See Also