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

    See psc_indexSet to convert NSNumber-NSArrays to an NSIndexSet.

    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()
  • Defaults to NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch|NSWidthInsensitiveSearch|NSRegularExpressionSearch. With NSDiacriticInsensitiveSearch, 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 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 }