PSPDFTextSearch
Objective-C
@interface PSPDFTextSearch : NSObject <NSCopying, PSPDFOverridable>
Swift
class TextSearch : NSObject, NSCopying, Overridable
Manages search operations for a specific document. You can copy this class to be able to use it on your custom class. (and set a different delegate) Copying will preserve all settings except the delegate.
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_EMPTY_INIT_UNAVAILABLE
-
Initialize with the document.
Declaration
Objective-C
- (nonnull instancetype)initWithDocument:(nonnull PSPDFDocument *)document;
Swift
init(document: PSPDFDocument)
-
Searches for text occurrence. If document was not yet parsed, it will be now. Searches entire document. Will search the whole document and cancel any previous search requests.
Declaration
Objective-C
- (void)searchForString:(nonnull NSString *)searchTerm;
Swift
func search(for searchTerm: String)
-
Searches for text on the specified page ranges. If ranges is nil, will search entire document. If rangesOnly is set to NO, ranges will be searched first, then the rest of the document.
Note
Seepsc_indexSet
to convertNSNumber-NSArrays
to anNSIndexSet
.Declaration
Objective-C
- (void)searchForString:(nonnull NSString *)searchTerm inRanges:(nullable NSIndexSet *)ranges rangesOnly:(BOOL)rangesOnly cancelOperations:(BOOL)cancelOperations;
Swift
func search(for searchTerm: String, inRanges ranges: IndexSet?, rangesOnly: Bool, cancelOperations: Bool)
-
Cancels all operations. Returns immediately.
-
Cancels all operations. Blocks current thread until all operations are processed.
Note
UsecancelAllOperations
if you don’t with to wait until all operations are processed. -
Defaults to
NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch|NSWidthInsensitiveSearch|NSRegularExpressionSearch
. WithNSDiacriticInsensitiveSearch
, e.g. an ö character will be treated like an o. See NSString comparison documentation for details.Note
PSPDF has extensions that will allow a combination ofNSRegularExpressionSearch
andNSDiacriticInsensitiveSearch
. IfNSRegularExpressionSearch
is enabled, hyphenations and newlines between the body text will be ignored (which is good, better results)Declaration
Objective-C
@property (nonatomic) NSStringCompareOptions compareOptions;
Swift
var compareOptions: NSString.CompareOptions { get set }
-
Customizes the range of the preview string. Defaults to 20/160.
Declaration
Objective-C
@property (nonatomic) NSRange previewRange;
Swift
var previewRange: NSRange { get set }
-
Will include annotations that have a matching type into the search results. (contents will be searched).
Note
Requires theFeatures.annotationEditing
feature flag.Declaration
Objective-C
@property (nonatomic) PSPDFAnnotationType searchableAnnotationTypes;
Swift
var searchableAnnotationTypes: Annotation.Kind { get set }
-
We have to limit the number of search results to something reasonable. Defaults to 600.
Declaration
Objective-C
@property (nonatomic) NSUInteger maximumNumberOfSearchResults;
Swift
var maximumNumberOfSearchResults: UInt { get set }
-
The document that is searched.
Declaration
Objective-C
@property (nonatomic, weak, readonly) PSPDFDocument *_Nullable document;
Swift
weak var document: PSPDFDocument? { get }
-
The search delegate to be informed when search starts/updates/finishes.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFTextSearchDelegate> _Nullable delegate;
Swift
weak var delegate: TextSearchDelegate? { get set }
-
Exposed internal search queue.
Declaration
Objective-C
@property (nonatomic, readonly) NSOperationQueue *_Nonnull searchQueue;
Swift
var searchQueue: OperationQueue { get }