---
title: "selection(for:)"
framework: pdfkit
role: symbol
role_heading: Instance Method
path: "pdfkit/pdfpage/selection(for:)-20y9d"
---

# selection(for:)

Returns the text contained within the specified range.

## Declaration

```swift
func selection(for range: NSRange) -> PDFSelection?
```

## Discussion

Discussion This method raises an exception if the range length is 0 or if either end of the range is outside the range of characters on the page.

## See Also

### Working with Selections

- [selection(for:)](pdfkit/pdfpage/selection(for:)-2ckpi.md)
- [selectionForWord(at:)](pdfkit/pdfpage/selectionforword(at:).md)
- [selectionForLine(at:)](pdfkit/pdfpage/selectionforline(at:).md)
- [selection(from:to:)](pdfkit/pdfpage/selection(from:to:).md)
