PDF Search Matching Options on iOS
PDFLibrary
offers advanced matching options. Pass these options in a Dictionary
when calling documentUIDs(matching:options:completionHandler:previewTextHandler:)
.
Name | Type | Description |
---|---|---|
.maximumSearchResultsTotal |
UInt |
The maximum amount of search results for the total of all documents. Defaults to 500. |
.maximumSearchResultsPerDocument |
UInt |
The maximum amount of search results per document. |
.maximumPreviewResultsTotal |
UInt |
The maximum amount of preview search results of all documents. Defaults to 500. |
.maximumPreviewResultsPerDocument |
UInt |
The maximum amount of preview search results per document. |
.matchExactWordsOnly |
Bool |
Only matches exact words. For example, “something” would not match “some.” |
.matchExactPhrasesOnly |
Bool |
Only matches exact phrases. For example, “this is a test” would not match “this is a quick test.” |
.excludeAnnotations |
Bool |
Excludes annotations from the search. By default, indexed annotations will be searched. |
.excludeDocumentText |
Bool |
Excludes document text from the search. By default, indexed document text will be searched. |
.previewRange |
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 |
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 |
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 |
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:)
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:)
will always return the same object.