Interface IDataProvider

This interface is to be used by all possible data providers for Document access.

Namespace: PSPDFKitFoundation.Data
Assembly: PSPDFKitFoundation.dll
Syntax
public interface IDataProvider

Properties

Size

Returns the size of the data.

Declaration
ulong Size { get; }
Property Value
Type Description
System.UInt64

SupportsWriting

Specifies whether a write can be attempted using ReplaceWithDataSinkAsync(IDataSink).

Declaration
bool SupportsWriting { get; }
Property Value
Type Description
System.Boolean

Uid

Returns a Uid that enables you to uniquely identify this data provider.
The Uid for the same provider might change between application restarts.
For persisting it, you must either implement your own mechanism, or use the RandomAccessStreamDataProvider(IRandomAccessStream, String) constructor to pin the hashCode to a persistent id representing the document.

Declaration
string Uid { get; }
Property Value
Type Description
System.String

Methods

CreateDataSink(DataSinkOption)

This method creates a data sink for your data provider with the given DataSinkOption. PSPDFKit will write all the appropriate data into it and pass it to ReplaceWithDataSinkAsync(IDataSink) when appropriate.

Declaration
IDataSink CreateDataSink(DataSinkOption option)
Parameters
Type Name Description
DataSinkOption option

The desired options for the DataSink.

Returns
Type Description
IDataSink

ReadAsync(UInt32, UInt32)

Reads and returns data read from offset with size. You have to make sure not to read past the end of your data.

Declaration
IAsyncOperation<IBuffer> ReadAsync(uint size, uint offset)
Parameters
Type Name Description
System.UInt32 size

The requested amount of data to read.

System.UInt32 offset

The offset into the data source to start reading from.

Returns
Type Description
Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IBuffer>

ReplaceWithDataSinkAsync(IDataSink)

This method should replace your current data with the one written into the data sink. To create a data sink, see CreateDataSink(DataSinkOption).
Depending on the DataSinkOption used you either have to append or replace the data.

Declaration
IAsyncOperation<bool> ReplaceWithDataSinkAsync(IDataSink dataSink)
Parameters
Type Name Description
IDataSink dataSink

The object instantiated with CreateDataSink(DataSinkOption).

Returns
Type Description
Windows.Foundation.IAsyncOperation<System.Boolean>