PDF Search Matching Options on iOS
PDFLibrary
offers advanced matching options. Pass these options in a Dictionary
when calling documentUIDs(matching:options:completionHandler:previewTextHandler:)
(opens in a new tab).
Name | Type | Description |
---|---|---|
.maximumSearchResultsTotal (opens in a new tab) | UInt | The maximum amount of search results for the total of all documents. Defaults to 500. |
.maximumSearchResultsPerDocument (opens in a new tab) | UInt | The maximum amount of search results per document. |
.maximumPreviewResultsTotal (opens in a new tab) | UInt | The maximum amount of preview search results of all documents. Defaults to 500. |
.maximumPreviewResultsPerDocument (opens in a new tab) | UInt | The maximum amount of preview search results per document. |
.matchExactWordsOnly (opens in a new tab) | Bool | Only matches exact words. For example, “something” would not match “some.” |
.matchExactPhrasesOnly (opens in a new tab) | Bool | Only matches exact phrases. For example, “this is a test” would not match “this is a quick test.” |
.excludeAnnotations (opens in a new tab) | Bool | Excludes annotations from the search. By default, indexed annotations will be searched. |
.excludeDocumentText (opens in a new tab) | Bool | Excludes document text from the search. By default, indexed document text will be searched. |
.previewRange (opens in a new tab) | NSRange | The range of the preview string. Defaults to 20/160. |
Advanced Configuration
You can configure PDFLibrary
to match your needs. The following properties on PDFLibrary
are available.
Property | Type | Default | Description |
---|---|---|---|
tokenizer (opens in a new tab) | String? | nil | The tokenizer used by the library. nil means PSPDFKit’s Porter tokenizer is used. You can learn more about this advanced topic by reading the custom tokenizers guide. |
saveReversedPageText (opens in a new tab) | Bool | true | This indicates whether or not the reversed text of a PDF document should be saved. This increases the size of the cache by about two, but it allows for “ends with” searches. |
shouldIndexAnnotations (opens in a new tab) | Bool | true | This specifies whether contents of annotations in documents should be indexed as well. |
You can also create your own instance of PDFLibrary
. Use PDFLibrary(path:)
(opens in a new tab) to create a new instance. path
must be the path to an empty directory. If path
doesn’t yet exist, the library will create it for you. The SQLite database cache will be stored there. Subsequent calls to PDFLibrary(path:)
(opens in a new tab) will always return the same object.