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

# selection(for:)

Returns the text enclosed within the specified rectangle, expressed in page (user) coordinates.

## Declaration

```swift
func selection(for rect: CGRect) -> PDFSelection?
```

```swift
func selection(for rect: NSRect) -> PDFSelection?
```

## See Also

### Working with Selections

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