Edit this page

Text Position

TextPosition is a position in the text of a RadFixedDocument. They enable keeping track of a "current" position in the document (i.e. a caret) and lay the foundations of document selection.

Creation

One can create a TextPostion for a particular document, page and index using one of the constructors:

  • TextPosition(RadFixedDocument document)

  • TextPosition(RadFixedPage page)

  • TextPosition(RadFixedPage page, int index)

  • TextPosition(TextPosition position)

The constructors that accept a RadFixedPage as parameter create a TextPosition for the particular page. The offset you specify will be the offset in the current page in terms of number of characters. If you pass only the RadFixedDocument instance, a TextPosition for the first page will be created. In case you want to make a copy of a TextPosition, you can opt for the constructor listed last.

Members

The members that the TextPosition class exposes are:

  • Properties

    • Index: The integer offset of the text position into the page.

    • Page: The RadFixedPage that the position belongs to.

  • Methods: Provide the means for navigation in the document and have self-explanatory names and arguments:

    • MoveToNextPosition()

    • MoveToPreviousPosition()

    • MoveToPosition(TextPosition position)

    • MoveToNextWord()

    • MoveToPreviousWord()

    • MoveToCurrentWordStart()

    • MoveToCurrentWordEnd()

    • MoveToLineStart()

    • MoveToLineEnd()

    • MoveLineUp()

    • MoveLineDown()

    • MoveToStartOfDocument()

    • MoveToEndOfDocument()

  • Events:

    • PositionChanging- occurs just before the position is moved;

    • PositionChanged - occurs after the position has moved.

The caret position of RadFixedDocument is also a TextPosition object and all methods and properties listed above could be used with it as well. Here is an example:

CaretPosition


this.radPdfViewer1.PdfViewerElement.Document.CaretPosition.MoveToEndOfDocument();

Me.RadPdfViewer1.PdfViewerElement.Document.CaretPosition.MoveToEndOfDocument()

This will not only move the caret to the end of the document, but will also scroll the document to bring it into view, as the view port follows the caret.

See Also