PSPDFDocumentPickerController
Objective-C
@interface PSPDFDocumentPickerController
: PSPDFSearchableTableViewController <UISearchDisplayDelegate,
UISearchBarDelegate>
Swift
class PDFDocumentPickerController : SearchableTableViewController, UISearchDisplayDelegate, UISearchBarDelegate
Shows all documents available in the specified directory or the documents set directly.
By default this will enqueue all documents into the default PSPDFLibrary
for FTS.
Uses a UISearchController
internally. It displays results for both PDF text and annotations,
provided the library indexes both.
Note
This controller should be presented embedded in aUINavigationController
.
Failing to do so might lead to issues with the search UI.
-
Returns an array of
Document
’s found in thedirectoryName
directory.Declaration
Objective-C
+ (nonnull NSArray<PSPDFDocument *> *) documentsFromDirectory:(nullable NSString *)directoryName includeSubdirectories:(BOOL)includeSubdirectories;
Swift
class func documents(fromDirectory directoryName: String?, includeSubdirectories: Bool) -> [PSPDFDocument]
-
Initializes a document picker controller for the specified directory.
Warning
Specifying a directory and a library with a
dataSource
set may result in the library’s indexes being in an inconsistent state with the data source if the documents do not match those provided by thedataSource
. This is highly discouraged. IF you wish to use the picker controller for documents not already specified by the library’sdataSource
, create a new library at a separate path and pass that here.Declaration
Objective-C
- (nonnull instancetype)initWithDirectory:(nullable NSString *)directory includeSubdirectories:(BOOL)includeSubdirectories library:(nullable PSPDFLibrary *)library;
Swift
convenience init(directory: String?, includeSubdirectories: Bool, library: PSPDFLibrary?)
Parameters
directory
The directory from which documents are to be retrieved for selection.
library
The library in which the documents are to be indexed. This is optional but required if you want to use
fullTextSearchEnabled
.Return Value
An instance of
PSPDFDocumentPickerController
. -
Initializes a document picker controller for the specified documents.
Warning
Specifying documents and a library with a
dataSource
set may result in the library’s indexes being in an inconsistent state with the data source if the documents do not match those provided by thedataSource
. This is highly discouraged. IF you wish to use the picker controller for documents not already specified by the library’sdataSource
, create a new library at a separate path and pass that here.Declaration
Objective-C
- (nonnull instancetype)initWithDocuments: (nonnull NSArray<PSPDFDocument *> *)documents library:(nullable PSPDFLibrary *)library;
Swift
init(documents: [PSPDFDocument], library: PSPDFLibrary?)
Parameters
documents
The documents available to be selected.
library
The library in which the documents are to be indexed. This is optional but required if you want to use
fullTextSearchEnabled
.Return Value
An instance of
PSPDFDocumentPickerController
. -
Manually trigger library enqueueing. We automatically do that when the controller becomes visible.
-
Delegate for document selection and search callbacks.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFDocumentPickerControllerDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: PDFDocumentPickerControllerDelegate? { get set }
-
All
Document
objects.Declaration
Objective-C
@property (copy, readonly) NSArray<PSPDFDocument *> *_Nonnull documents;
Swift
var documents: [PSPDFDocument] { get }
-
Displayed path. Might be nil, if initialized with a number of documents.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *directory;
Swift
var directory: String? { get }
-
Show document titles in the list. If set to NO, the file name is used instead. Defaults to NO, since getting the PDF document title can be slow.
Declaration
Objective-C
@property (nonatomic) BOOL useDocumentTitles;
Swift
var useDocumentTitles: Bool { get set }
-
Enables section indexes. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL showSectionIndexes;
Swift
var showSectionIndexes: Bool { get set }
-
If disabled, documents will only be displayed once you start searching. Defaults to YES.
Declaration
Objective-C
@property (nonatomic) BOOL alwaysShowDocuments;
Swift
var alwaysShowDocuments: Bool { get set }
-
Enable to perform full-text search on all documents. Defaults to YES.
Note
To improve matching in large libraries, full text search is only performed after at least 4 characters are entered in the search field.Declaration
Objective-C
@property (nonatomic) BOOL fullTextSearchEnabled;
Swift
var fullTextSearchEnabled: Bool { get set }
-
If set to YES, will require an exact word match instead of an begin/end partial match. Defaults to NO.
Declaration
Objective-C
@property (nonatomic) BOOL fullTextSearchExactWordMatch;
Swift
var fullTextSearchExactWordMatch: Bool { get set }
-
Property is enabled if a FTS-Search is currently queued/running. KVO observable.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isSearchingIndex;
Swift
var isSearchingIndex: Bool { get }
-
Will show the actual pages and text preview instead of just the documents. Only valid if
fullTextSearchEnabled
is enabled. Defaults to YES.Declaration
Objective-C
@property (nonatomic) BOOL showSearchPageResults;
Swift
var showSearchPageResults: Bool { get set }
-
Will show a preview text that presents the search term within its context. Only valid if
fullTextSearchEnabled
is enabled. Defaults to YES.Declaration
Objective-C
@property (nonatomic) BOOL showSearchPreviewText;
Swift
var showSearchPreviewText: Bool { get set }
-
Defaults to 600. A too high number will be slow. Only valid if
fullTextSearchEnabled
is enabled.Declaration
Objective-C
@property (nonatomic) NSUInteger maximumNumberOfSearchResultsDisplayed;
Swift
var maximumNumberOfSearchResultsDisplayed: UInt { get set }
-
Number of results found per document. Defaults to 10. Only valid if
fullTextSearchEnabled
is enabled.Declaration
Objective-C
@property (nonatomic) NSUInteger maximumNumberOfSearchResultsPerDocument;
Swift
var maximumNumberOfSearchResultsPerDocument: UInt { get set }
-
Maximum number of lines for search preview text. Defaults to 2. The actual number of lines will be smaller if there’s not enough preview text available. Only valid if
fullTextSearchEnabled
is enabled.Declaration
Objective-C
@property (nonatomic) NSUInteger maximumNumberOfSearchPreviewLines;
Swift
var maximumNumberOfSearchPreviewLines: UInt { get set }
-
The attached library, if any.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFLibrary *library;
Swift
var library: PSPDFLibrary? { get }
-
Called when the document picker status cell will be updated. Override this method to customize the status cell.
Declaration
Objective-C
- (void)updateStatusCell:(nonnull PSPDFDocumentPickerIndexStatusCell *)cell;
Swift
func update(_ cell: PSPDFDocumentPickerIndexStatusCell)