Class Library

Represents a Library of indexed PDFs that can be searched. This class implements System.IDisposable. Don't forget to use using or class `System.IDisposable.Dispose() manually.

Inheritance
System.Object
Library
Implements
System.IDisposable
Namespace: PSPDFKit.Search
Assembly: PSPDFKit.dll
Syntax
public sealed class Library : IDisposable

Properties

LibraryName

The name of the library.

Declaration
public string LibraryName { get; }
Property Value
Type Description
System.String

SearchTimeout

The time span after which a search should time out. Any changes to this property only affect subsequent searches. Default is two minutes.

Declaration
public TimeSpan SearchTimeout { get; set; }
Property Value
Type Description
System.TimeSpan

Methods

CancelAllPreviewTextOperationsAsync()

Cancel all preview text search tasks.

Declaration
public IAsyncAction CancelAllPreviewTextOperationsAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

CancelAllTasksAsync()

Cancel all search tasks.

Declaration
public IAsyncAction CancelAllTasksAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

ClearAllIndexesAsync()

Clear all indices in this library.

Declaration
public IAsyncAction ClearAllIndexesAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

DeleteAllLibrariesAsync()

Deletes all current libraries. If libraries have not been disposed when this command is run a System.IO.FileLoadException will be thrown.

Declaration
public static IAsyncAction DeleteAllLibrariesAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

Dispose()

Implements System.IDisposable.Dispose().

Declaration
public void Dispose()

EnableOnPageIndexedEventsAsync(Boolean)

Sets if the event OnPageIndexed is raised. Default is false.

Declaration
public IAsyncAction EnableOnPageIndexedEventsAsync(bool enable)
Parameters
Type Name Description
System.Boolean enable
Returns
Type Description
Windows.Foundation.IAsyncAction

EnqueueDocumentsInFolderAsync(StorageFolder)

Queues a folder of documents for indexing. All files in the folder with the extension '.pdf' will be queued.

Declaration
public IAsyncAction EnqueueDocumentsInFolderAsync(StorageFolder folder)
Parameters
Type Name Description
Windows.Storage.StorageFolder folder

The folder to query for matching documents.

Returns
Type Description
Windows.Foundation.IAsyncAction

EnqueueDocumentsInFolderAsync(StorageFolder, QueryOptions)

Queues a folder of documents for indexing.

Declaration
public IAsyncAction EnqueueDocumentsInFolderAsync(StorageFolder folder, QueryOptions options)
Parameters
Type Name Description
Windows.Storage.StorageFolder folder

The folder to query for matching documents.

Windows.Storage.Search.QueryOptions options

The query identifying the PDF documents in the folder. Note that Windows.Storage.Search.FolderDepth.Deep is not yet supported.

Returns
Type Description
Windows.Foundation.IAsyncAction

GetIndexDocumentStatusAsync(String)

Returns indexing status for a document with passed Uid.

Declaration
public IAsyncOperation<LibraryIndexStatus> GetIndexDocumentStatusAsync(string uid)
Parameters
Type Name Description
System.String uid

Uid of document.

Returns
Type Description
Windows.Foundation.IAsyncOperation<LibraryIndexStatus>

Index status of document.

GetIndexedUidsAsync()

Returns a list of UIDs of documents currently indexed.

Declaration
public IAsyncOperation<IList<string>> GetIndexedUidsAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Collections.Generic.IList<System.String>>

The list of document UIDs.

IsIndexingAsync()

Indicates if the library is currently being indexed.

Declaration
public IAsyncOperation<bool> IsIndexingAsync()
Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

True if the library is currently being indexed.

OpenLibraryAsync(String)

Open a library with the provided name. If it doesn't yet exist it will be created.

Declaration
public static IAsyncOperation<Library> OpenLibraryAsync(string name)
Parameters
Type Name Description
System.String name

The name of the library. Only use names which are valid file names.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Library>

The opened or created Library. Note that this must be disposed.

OpenLibraryAsync(String, CreationCollisionOption)

Open a library with the provided name with the specified Windows.Storage.CreationCollisionOption.

Declaration
public static IAsyncOperation<Library> OpenLibraryAsync(string name, CreationCollisionOption option)
Parameters
Type Name Description
System.String name

The name of the library. Only use names which are valid file names.

Windows.Storage.CreationCollisionOption option

Determines how to handle the collision if a library with the specified name already exists.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Library>

The opened or created Library. Note that this must be disposed.

RemoveDocumentAsync(String)

Removes the specified document from the index if is in it.

Declaration
public IAsyncAction RemoveDocumentAsync(string documentUid)
Parameters
Type Name Description
System.String documentUid
Returns
Type Description
Windows.Foundation.IAsyncAction

RemoveDocumentsAsync(IList<String>)

Removes the specified documents from the index if they are in it.

Declaration
public IAsyncAction RemoveDocumentsAsync(IList<string> documentUids)
Parameters
Type Name Description
System.Collections.Generic.IList<System.String> documentUids
Returns
Type Description
Windows.Foundation.IAsyncAction

SearchAsync(LibraryQuery)

Searches the index with the supplied LibraryQuery for matches. Collect the results with the handler OnSearchComplete

Declaration
public IAsyncOperation<bool> SearchAsync(LibraryQuery query)
Parameters
Type Name Description
LibraryQuery query

The LibraryQuery defining the search criteria.

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>

True if it succeeded and False if it timed out.

WaitForAllIndexingTasksToFinishAsync()

Wait until all queued index tasks are complete.

Declaration
public IAsyncAction WaitForAllIndexingTasksToFinishAsync()
Returns
Type Description
Windows.Foundation.IAsyncAction

Events

OnFinishedIndexingDocument

Invoked when a document finished indexing. The owning library, the UID of the document and if indexing was successful is passed. This handler is not called on the UI thread.

Declaration
public event TypedEventHandler<Library, LibraryIndexingSuccess> OnFinishedIndexingDocument
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, LibraryIndexingSuccess>

OnPageIndexed

Invoked for each page indexed if EnableOnPageIndexedEvents() returns true. The owning library and the result is passed. This handler is not called on the UI thread.

Declaration
public event TypedEventHandler<Library, PageIndexed> OnPageIndexed
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, PageIndexed>

OnPasswordRequested

Invoked when a document requires a password to be indexed. The owning library and PasswordRequest of the document is passed. To unlock the document set Password

Declaration
public event TypedEventHandler<Library, PasswordRequest> OnPasswordRequested
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, PasswordRequest>

OnSearchComplete

Invoked once search completes with the map of search results. LibraryQueryResult

Declaration
public event TypedEventHandler<Library, IDictionary<string, LibraryQueryResult>> OnSearchComplete
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, System.Collections.Generic.IDictionary<System.String, LibraryQueryResult>>

OnSearchPreviewComplete

Invoked once search completes with the list of search preview results. LibraryPreviewResult

Declaration
public event TypedEventHandler<Library, IList<LibraryPreviewResult>> OnSearchPreviewComplete
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, System.Collections.Generic.IList<LibraryPreviewResult>>

OnSearchTimedOut

Invoked if a search timed out.

Declaration
public event TypedEventHandler<Library, LibraryQuery> OnSearchTimedOut
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, LibraryQuery>

OnStartIndexingDocument

Invoked when a document starts indexing. The owning library and UID of the document is passed. This handler is not called on the UI thread.

Declaration
public event TypedEventHandler<Library, string> OnStartIndexingDocument
Event Type
Type Description
Windows.Foundation.TypedEventHandler<Library, System.String>

Implements

System.IDisposable