Class InputStreamDataProvider
-
- All Implemented Interfaces:
-
com.pspdfkit.document.providers.DataProvider
public abstract class InputStreamDataProvider extends ContextDataProvider
Abstract data provider that handles serving a PDF document from an InputStream. Since viewing the PDF document needs random access, this class wraps the logic for re-opening the stream for backwards-seek operations. Subclasses need to override the openInputStream method, which needs to return a new
InputStream
instance every time it is called.
-
-
Constructor Summary
Constructors Constructor Description InputStreamDataProvider()
-
Method Summary
-
-
Method Detail
-
read
@NonNull() Array<byte> read(long size, long offset)
Called by PSPDFKit to read data from the document. The returned byte array can be reused in subsequent calls to prevent excessive allocations.
- Parameters:
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.- Returns:
Byte array with document data of the exact same size or larger size than size parameter. Implementations may not return
null
or loading will fail. Instead, when experiencing a read error, implementations may return NO_DATA_AVAILABLE to safely stop reading.
-
release
void release()
Called when the provided document is being closed. Implementations are expected to release all resources (like closing of all streams and freeing of allocations).
-
-
-
-