PSPDFTextSearch


@interface PSPDFTextSearch : NSObject <NSCopying>

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.

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFTextSearch : NSObject <NSCopying>
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFTextSearch : NSObject <NSCopying>
  • 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 (assign, readwrite, 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 (assign, readwrite, 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 PSPDFFeatureMaskAnnotationEditing feature flag.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFAnnotationType searchableAnnotationTypes;

    Swift

    var searchableAnnotationTypes: PSPDFAnnotationType { get set }
  • We have to limit the number of search results to something reasonable. Defaults to 600.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger maximumNumberOfSearchResults;

    Swift

    var maximumNumberOfSearchResults: UInt { get set }
  • The document that is searched.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFDocument *_Nullable document;

    Swift

    weak var document: PSPDFDocument? { get }
  • The search delegate to be informed when search starts/updates/finishes.

    Declaration

    Objective-C

    @property (readwrite, nonatomic) id<PSPDFTextSearchDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFTextSearchDelegate? { get set }
  • Exposed internal search queue.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSOperationQueue *_Nonnull searchQueue;

    Swift

    var searchQueue: OperationQueue { get }