---
title: "selection(from:atCharacterIndex:to:atCharacterIndex:)"
framework: pdfkit
role: symbol
role_heading: Instance Method
path: "pdfkit/pdfdocument/selection(from:atcharacterindex:to:atcharacterindex:)"
---

# selection(from:atCharacterIndex:to:atCharacterIndex:)

Returns the specified selection based on starting and ending character indexes.

## Declaration

```swift
func selection(from startPage: PDFPage, atCharacterIndex startCharacter: Int, to endPage: PDFPage, atCharacterIndex endCharacter: Int) -> PDFSelection?
```

## Discussion

Discussion The selection begins at startChar on startPage and ends at endChar on endPage. The starting and ending index values must be in the range of the number of characters (as returned by numberOfCharacters) within the respective PDFPage objects.

## See Also

### Working with Selections and Searches

- [selection(from:at:to:at:)](pdfkit/pdfdocument/selection(from:at:to:at:).md)
- [selectionForEntireDocument](pdfkit/pdfdocument/selectionforentiredocument.md)
- [Search Operations](pdfkit/search-operations.md)
