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. Calling copy() on a subclass will return an instance of TextSearch, not the subclass.

  • 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.

    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.

    Declaration

    Objective-C

    - (void)cancelAllOperations;

    Swift

    func cancelAllOperations()
  • Cancels all operations. Blocks current thread until all operations are processed.

    Note

    Use cancelAllOperations if you don’t with to wait until all operations are processed.

    Declaration

    Objective-C

    - (void)cancelAllOperationsAndWait;

    Swift

    func cancelAllOperationsAndWait()
  • String comparison options for the search.

    Defaults to [.caseInsensitive, .diacriticInsensitive, .smart].

    Declaration

    Objective-C

    @property (nonatomic) PSPDFTextComparisonOptions comparisonOptions;

    Swift

    var comparisonOptions: TextSearch.ComparisonOptions { get set }
  • Deprecated

    Deprecated in PSPDFKit 13.3 for iOS. Use ‘comparisonOptions’ instead.

    String comparison options for the search. This property is deprecated in favor of comparisonOptions.

    Defaults to NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch|NSRegularExpressionSearch. I.e. a case- and diacritic-insensitive smart search.

    With NSDiacriticInsensitiveSearch, e.g. an ö character will be treated like an o. See NSString comparison documentation for details.

    NSRegularExpressionSearch maps to TextSearch.ComparisonOptions.smart, not TextSearch.ComparisonOptions.regularExpression. To perform a regular expression search, use comparisonOptions instead.

    Note

    PSPDF has extensions that will allow a combination of NSRegularExpressionSearch and NSDiacriticInsensitiveSearch. If NSRegularExpressionSearch 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 the Features.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 }