How can I set the cursor position programatically?

I would like to be able to programatically set the cursor position to the end of a document in the document editor so that I can add a new page to the end of the document and insert text there, using methods in the API reference such as InsertPageBreakAsync and InsertTextAsync. Is this possible?


1 Reply

SK Selvaprakash Karuppusamy Syncfusion Team March 16, 2023 09:58 AM UTC

Hi Alex,


Yes, please refer to the code below for your reference.

The following code illustrates how to move the cursor to the end of the document.

container.DocumentEditor.Selection.MoveToDocumentEndAsync();

 

The following code illustrates how to insert a page break.

container.DocumentEditor.Editor.InsertPageBreakAsync();

 

The following code illustrates how to insert text.

container.DocumentEditor.Editor.InsertTextAsync("hello");


Regards,

Selvaprakash K


Loader.
Up arrow icon