PdfLibrary

class PdfLibrary(path: String, tokenizer: PdfLibrary.TokenizerType? = null)

PdfLibrary implements a SQLite-based full-text-search engine. You can register documents to be indexed in the background and then search for keywords within that collection. There can be multiple libraries, although usually one is enough for the common use case.

Parameters

path

Writable path to library database file.

tokenizer

The tokenizer to use, one of TokenizerType.PORTER or TokenizerType.UNICODE. This controls how the PdfLibrary matches queries to the content in the index. If null is passed, TokenizerType.PORTER will be used as the default tokenizer.

See also

Constructors

Link copied to clipboard
constructor(path: String, tokenizer: PdfLibrary.TokenizerType? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Enum specifying the indexing tokenizer to use for the search library.

Properties

Link copied to clipboard

The library's data source. This object will be retained and used to provide documents for indexing. When set, the library can use updateIndexFromDataSource to automatically index documents provided by the data source.

Link copied to clipboard

Returns list of UIDs of documents currently indexed.

Link copied to clipboard

Indicates whether the indexing is in progress or not.

Link copied to clipboard

Returns list of UIDs of documents queued for indexing.

Functions

Link copied to clipboard

Adds a LibraryIndexingListener to monitor document indexing status. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.

Link copied to clipboard

Completely clears the index for this library.

Link copied to clipboard
fun enqueueDocuments(documents: List<PdfDocument>, indexingOptions: IndexingOptions = IndexingOptions())

Queues an array of documents for indexing. Any documents already queued or fully indexed will be ignored.

Link copied to clipboard
fun enqueueDocumentSources(documentSources: List<DocumentSource>, indexingOptions: IndexingOptions = IndexingOptions())

Queues an array of documents for indexing. Any documents already queued or fully indexed will be ignored. This call will avoid opening documents until they're indexed and it's thus significantly more memory friendly than enqueueDocuments.

Link copied to clipboard
fun enqueueDocumentSourcesWithMetadata(documentSources: List<Pair<DocumentSource, ByteArray?>>, indexingOptions: IndexingOptions = IndexingOptions())

Queues an array of documents for indexing together with passed free-form metadata. This call will avoid opening documents until they're indexed and it's thus significantly more memory friendly than enqueueDocumentsWithMetadata.

Link copied to clipboard
fun enqueueDocumentsWithMetadata(documents: List<Pair<PdfDocument, ByteArray>>, indexingOptions: IndexingOptions = IndexingOptions())

Queues an array of documents for indexing together with passed free-form metadata. Metadata can be retrieved after indexing with getMetadataForUID method call.

Link copied to clipboard

Returns indexing status for a document with passed UID.

Link copied to clipboard

Returns metadata appended to document with enqueueDocumentsWithMetadata call.

Link copied to clipboard
fun getNativeLibrary(): ERROR CLASS: Symbol not found for NativeDocumentLibrary
Link copied to clipboard

Indicates whether saving the reverse text is enabled.

Link copied to clipboard

Retrieves a document source with the specified UID from the data source, if any. Using this method is preferred to directly interacting with the data source's methods.

Link copied to clipboard
fun removeDocuments(documentUIDs: List<String>)

Invalidates index for documents.

Link copied to clipboard

Removes a registered LibraryIndexingListener added with addLibraryIndexingListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed, and will result in an exception.

Link copied to clipboard
fun search(searchString: String, options: QueryOptions? = null, resultListener: QueryResultListener)

Query the database for a match of searchString. Only direct matches, begins-with and ends-with matches are supported. Returns a map of document UIDs to set of pages matching inside that document.

Link copied to clipboard
fun setSaveReverseText(saveReverseText: Boolean)

Will save a reversed copy of the original page text. If enabled the index database will be about 2x bigger, but ends-with matches will be enabled.

Link copied to clipboard
fun size(): Int

Returns number of indexed documents in this library.

Link copied to clipboard

Stops search and all in-progress preview text generator tasks.

Link copied to clipboard
suspend fun updateIndexFromDataSource(indexingOptions: IndexingOptions = IndexingOptions())

Updates the index based on information provided by the data source. If there is no data source set, this method will throw an IllegalStateException. Any currently queued documents will be removed.