Back to Devexpress

SubDocument.InsertHtmlText(DocumentPosition, String) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-subdocument-dot-inserthtmltext-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentposition-system-dot-string-x29.md

latest3.7 KB
Original Source

SubDocument.InsertHtmlText(DocumentPosition, String) Method

Inserts the specified HTML text into the specified position.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
DocumentRange InsertHtmlText(
    DocumentPosition pos,
    string htmlText
)
vb
Function InsertHtmlText(
    pos As DocumentPosition,
    htmlText As String
) As DocumentRange

Parameters

NameTypeDescription
posDocumentPosition

A DocumentPosition object specifying the position at which the text should be inserted.

| | htmlText | String |

A string in HTML format.

|

Returns

TypeDescription
DocumentRange

A DocumentRange object representing the DocumentRange.Start and DocumentRange.End positions of the inserted text.

|

Remarks

The InsertHtmlText method imports the specified string in HTML format into the internal document model.

Note

Do not include the meta charset attribute in HTML string that is supplied to this method. It will result in incorrect character encoding.

If the HTML string contains links to external content, such as pictures, the corresponding attributes should contain a valid URL from which the content can be downloaded.

After the string is successfully imported, the new document model is inserted at the specified position of the main document.

If the Paragraph.ContextualSpacing property of the last paragraph is false (default), RichEditControl inserts additional space between inserted HTML paragraphs. To remove extra space, set the Paragraph.ContextualSpacing option to true for paragraphs in the document and set the Paragraph.SpacingAfter property of the current paragraph and the Paragraph.SpacingBefore property of the next paragraph to zero (0).

Note

If you want more control over the text before it is inserted, create an instance of the RichEditDocumentServer and load the string into it. Then use the SubDocument.InsertDocumentContent method to insert the modified document.

See Also

SubDocument Interface

SubDocument Members

DevExpress.XtraRichEdit.API.Native Namespace