Skip to main content

SubDocument.InsertRtfText(DocumentPosition, String) Method

Inserts the specified formatted text into the specified position.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

DocumentRange InsertRtfText(
    DocumentPosition pos,
    string rtfText
)

Parameters

Name Type Description
pos DocumentPosition

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

rtfText String

A string in RTF format specifying the text to insert.

Returns

Type Description
DocumentRange

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

Remarks

The InsertRtfText method imports the specified string in RTF format into the internal document model.

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

The inserted text starts with a new paragraph and preserves formatting. It is inserted into an existing section and gets all section details (header, footer, page and print layout).

If the text being inserted contains document styles which are not present in the current document, the styles are copied to the resulting document.

If the document whose content is being inserted contains floating objects, such as pictures or text boxes, they are inserted into the corresponding positions in a newly created range.

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertRtfText(DocumentPosition, String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also