Skip to main content

How to: Append Text to the Paragraph

The following code snippet appends text to the end of the last paragraph.

result

View Example

using DevExpress.XtraRichEdit.API.Native;
using System.Linq;

using (var wordProcessor = new RichEditDocumentServer())
{
  // Access a document.
  Document document = wordProcessor.Document;

  // Start to edit the document.
  document.BeginUpdate();

  // Append text
  document.AppendText("First Paragraph\nSecond Paragraph\nThird Paragraph");

  // Obtain the last paragraph's end position.
  DocumentPosition paragraphEnd = document.Paragraphs.Last().Range.End;

  // Insert text to the paragraph end.
  document.InsertText(paragraphEnd, "<<Appended to Paragraph End>>");

  // Finalize to edit the document.
  document.EndUpdate();
}