WritableDataProvider

WritableDataProvider is an interface which should be implemented by any DataProvider that should support saving PDF documents. Classes implementing this interface must implement all methods from this interface and from DataProvider interface for document loading and saving to work properly.

Classes implementing this interface need to implement all methods correctly to allow PSPDFKit loading documents. Furthermore, if classes with this interface are meant to be used with PdfActivity, they must also implement android.os.Parcelable. If you plan to use the DataProvider only for PdfFragment parcelation code is not necessary.

All callbacks will be called on a background thread.

Inheritors

Types

Link copied to clipboard

Describes possible write modes for the output.

Functions

Link copied to clipboard
abstract fun canWrite(): Boolean

Indicates whether this data provider is writable.

Link copied to clipboard
abstract 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

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

Link copied to clipboard
abstract 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
abstract 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.