ContentResolverDataProvider

Data provider for opening PDF documents directly from a ContentProvider using Android's content resolver framework. PSPDFKit internally uses this data provider when loading a document from an Uri that uses the content:// or file:// scheme.

Creates the data provider for loading a document from the given content provider uri.

Parameters

uri

A content provider URI with supported scheme (content:// or file://).

Constructors

Link copied to clipboard
constructor(uri: Uri)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun canWrite(): Boolean

Indicates whether this data provider is writable.

Link copied to clipboard
open override fun describeContents(): Int
Link copied to clipboard
open override fun finishWrite(): Boolean

Called by PSPDFKit after all data has been written via method. This allows the data provider to close all opened input streams. In case of WriteMode.REWRITE_FILE access, the data provider should here replace the original file with the written temporary file.

Link copied to clipboard
open override fun getSize(): Long

Return the actual file size of the PDF document which is provided by this data provider. If the data provider can't determine the correct file size (e.g. in case of an error) this method has to return FILE_SIZE_UNKNOWN.

Link copied to clipboard
open override fun getTitle(): String?

Displayable document title to be used if PDF document does not contain metadata. For example, for file-based providers this should return the filename. `.pdf` extensions will be stripped automatically.

Link copied to clipboard
open override fun getUid(): String

Unique document identifier used in all caching processes in PSPDFKit. Must be equal or shorter than 50 chars. This method must be implemented for caching to work properly.

Link copied to clipboard
open override fun getUri(): Uri

Returns the Uri from which this provided was created.

Link copied to clipboard
open override fun startWrite(writeMode: WritableDataProvider.WriteMode): Boolean

Called before writing to the file begins so the provider can prepare file output.

Link copied to clipboard
open override fun supportsAppending(): Boolean

Reports whether this provider supports appending to output file as opposed to always rewriting it. If this returns false, only WriteMode.REWRITE_FILE will be used and the PDF file will always be fully rewritten on save.

Link copied to clipboard
open override fun write(data: ByteArray): Boolean

Called by PSPDFKit to write data to the document. This callback will be called multiple times in a writing operation.

Link copied to clipboard
open override fun writeToParcel(dest: Parcel, flags: Int)