| java.lang.Object | |
| ↳ | com.pspdfkit.api.providers.FileDataProvider |
A DataProvider for a standard filesystem file .
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pspdfkit.api.providers.DataProvider
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
FileDataProvider(File file)
Creates an
DataProvider to allow PSPDFKit to be able to read from a File. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| boolean |
canWrite()
Indicates whether this data provider is writable.
| ||||||||||
| boolean |
finishWrite()
Called by PSPDFKit after all data has been written via
write(byte[]) method. | ||||||||||
| File |
getFile()
Get the File from the data provider.
| ||||||||||
| long |
getSize()
Return the actual file size of the data source which is provided by this data provider.
| ||||||||||
| String |
getTitle()
Displayable document title to be used if PDF document does not contain metadata.
| ||||||||||
| byte[] |
read(long size, long offset)
Called by PSPDFKit to read data from the document.
| ||||||||||
| void |
release()
Called when the provided document is being closed.
| ||||||||||
| boolean |
startWrite(WritableDataProvider.WriteMode writeMode)
Called before writing to the source begins so the provider can prepare data 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.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.pspdfkit.api.providers.DataProvider
| |||||||||||
From interface
com.pspdfkit.api.providers.WritableDataProvider
| |||||||||||
Creates an DataProvider to allow PSPDFKit to be able to read from a File.
| file | The file to read. |
|---|
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 access, the data
provider should here replace the original data with the written temporary data.
true if operation succeeded, false if it failed.
Get the File from the data provider. Allows for direct file IO access in PSPDFKit.
FileDataProvider is serving.
Return the actual file size of the data source which is provided by this data provider. If the data provider
can't determine the correct 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.
Called by PSPDFKit to read data from the document. The returned byte array can be reused in subsequent calls to prevent excessive allocations.
| size | Size of the data chunk to be read in bytes. |
|---|---|
| offset | Offset from start of document of the data chunk to be read in bytes. |
Called when the provided document is being closed. Implementations are expected to release all resources (like closing of all streams and freeing of allocations).
Called before writing to the source begins so the provider can prepare data output.
| writeMode | Determines how the data should be written to the output. For APPEND the data should be added to the end of existing file
data. For REWRITE PSPDFKit will write full data load and
the data should be written to a temporary location. The temporary location should replace then
original data in finishWrite() callback method. Original data 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 will be used and the data 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 data cannot be appended.
true if this provider supports APPEND 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.