---
title: "findString(_:withOptions:)"
framework: pdfkit
role: symbol
role_heading: Instance Method
path: "pdfkit/pdfdocument/findstring(_:withoptions:)"
---

# findString(_:withOptions:)

Synchronously finds all instances of the specified string in the document.

## Declaration

```swift
func findString(_ string: String, withOptions options: NSString.CompareOptions = []) -> [PDFSelection]
```

## Discussion

Discussion Each hit gets added to an NSArray object as a PDFSelection object. If there are no hits, this method returns an empty array. Use this method when the complete search process will be brief and when you don’t need the flexibility or control offered by beginFindString(_:withOptions:). For options, refer to Searching, Comparing, and Sorting Strings.

## See Also

### Searching Documents

- [beginFindString(_:withOptions:)](pdfkit/pdfdocument/beginfindstring(_:withoptions:).md)
- [beginFindStrings(_:withOptions:)](pdfkit/pdfdocument/beginfindstrings(_:withoptions:).md)
- [findString(_:fromSelection:withOptions:)](pdfkit/pdfdocument/findstring(_:fromselection:withoptions:).md)
- [isFinding](pdfkit/pdfdocument/isfinding.md)
- [cancelFindString()](pdfkit/pdfdocument/cancelfindstring().md)
