| java.lang.Object | |||
| ↳ | com.pspdfkit.document.providers.ContextDataProvider | ||
| ↳ | com.pspdfkit.document.providers.InputStreamDataProvider | ||
| ↳ | com.pspdfkit.document.providers.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.
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
| |||||||||||
From interface
com.pspdfkit.document.providers.DataProvider
| |||||||||||
| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| public static final Creator<ContentResolverDataProvider> | CREATOR | A field that generates the instances of this class from the provided Parcel. |
|||||||||
|
[Expand]
Inherited Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pspdfkit.document.providers.DataProvider
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
ContentResolverDataProvider(Uri uri)
Creates the data provider for loading a document from the given content provider
uri. | |||||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ContentResolverDataProvider(Parcel in) | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean |
canWrite()
Indicates whether this data provider is writable.
| ||||||||||
| int | describeContents() | ||||||||||
| boolean |
finishWrite()
Called by PSPDFKit after all data has been written via
write(byte[]) method. | ||||||||||
| long |
getSize()
Return the actual file size of the PDF document which is provided by this data provider.
| ||||||||||
| String |
getTitle()
Displayable document title to be used if PDF document does not contain metadata.
| ||||||||||
| String |
getUid()
Unique document identifier used in all caching processes in PSPDFKit.
| ||||||||||
| Uri |
getUri()
Returns the
Uri from which this provided was created. | ||||||||||
| boolean |
startWrite(WritableDataProvider.WriteMode writeMode)
Called before writing to the file begins so the provider can prepare file output.
| ||||||||||
| boolean |
supportsAppending()
Reports whether this provider supports appending to output file as opposed to always rewriting it.
| ||||||||||
| boolean |
write(byte[] data)
Called by PSPDFKit to write data to the document.
| ||||||||||
| void | writeToParcel(Parcel dest, int flags) | ||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| InputStream |
openInputStream()
Subclasses need to override this method and return a readable input stream which servers the PDF document.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.pspdfkit.document.providers.InputStreamDataProvider
| |||||||||||
From class
com.pspdfkit.document.providers.ContextDataProvider
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
| |||||||||||
From interface
com.pspdfkit.document.providers.DataProvider
| |||||||||||
From interface
com.pspdfkit.document.providers.UriDataProvider
| |||||||||||
From interface
com.pspdfkit.document.providers.WritableDataProvider
| |||||||||||
A field that generates the instances of this class from the provided Parcel.
Creates the data provider for loading a document from the given content provider uri.
| uri | A content provider URI with supported scheme (content:// or file://).
|
|---|
Indicates whether this data provider is writable.
true if the data provider can be written to, false if not.
Called by PSPDFKit after all data has been written via write(byte[]) method. This
allows the data provider to close all opened input streams. In case of REWRITE_FILE access, the
data provider should here replace the original file with the written temporary file.
true if operation succeeded, false if it failed.
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.
FILE_SIZE_UNKNOWN in case of an error.
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.
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.
null or an exception will be thrown.
Called before writing to the file begins so the provider can prepare file output.
| writeMode | Determines how file data should be written to the output. For WriteMode#APPEND_TO_FILE
the data should be added to the end of existing file data. For WriteMode#REWRITE_FILE
PSPDFKit will write full PDF document and the data should be written to a temporary file. The
temporary file should replace then original file in finishWrite() callback method.
Original file must not be written to when rewriting is in progress - PSPDFKit will issue
read(long, long) calls while writing and attempting to write output to the same input
will result in a corrupted file. |
|---|
true if operation succeeded, false if writing should be aborted.
Reports whether this provider supports appending to output file as opposed to always rewriting it. If this
returns false, only REWRITE_FILE will be used and the PDF file will always be fully rewritten
on save.
Note that if true is returned here, both WritableDataProvider.WriteMode options must be supported by this
DataProvider since some documents cannot be saved incrementally.
true if this provider supports APPEND_TO_FILE save mode.
Called by PSPDFKit to write data to the document. This callback will be called multiple times in a writing operation.
| data | Data to be written to the file. |
|---|
true if writing succeeded, false if the write operation should be aborted.
Subclasses need to override this method and return a readable input stream which servers the PDF document. This
method must return a new InputStream instance every time it is called. This is
necessary so InputStreamDataProvider can actually "simulate" random data access on the underlying stream.
| IOException |
|---|