public class

AssetDataProvider

extends InputStreamDataProvider
implements Parcelable UriDataProvider
java.lang.Object
   ↳ com.pspdfkit.document.providers.ContextDataProvider
     ↳ com.pspdfkit.document.providers.InputStreamDataProvider
       ↳ com.pspdfkit.document.providers.AssetDataProvider

Class Overview

Data provider for opening PDF documents directly from the app's assets. Use it in combination with openDocumentAsync(Context, com.pspdfkit.document.DocumentSource) or PdfActivityIntentBuilder#fromDataProvider(Context, DataProvider...).

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
From interface com.pspdfkit.document.providers.DataProvider
Fields
public static final Creator<AssetDataProvider> 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
AssetDataProvider(String assetName)
Default constructor taking the assetName of a document.
Protected Constructors
AssetDataProvider(Parcel in)
Public Methods
int describeContents()
long getSize()
String getTitle()
String getUid()
Uri getUri()
Returns the Uri from which this provided was created.
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

Fields

public static final Creator<AssetDataProvider> CREATOR

A field that generates the instances of this class from the provided Parcel.

Public Constructors

public AssetDataProvider (String assetName)

Default constructor taking the assetName of a document. The filename/path needs to be relative to the asset directory.

Parameters
assetName Filename of the asset in the application assets folder.

Protected Constructors

protected AssetDataProvider (Parcel in)

Public Methods

public int describeContents ()

public long getSize ()

public String getTitle ()

public String getUid ()

public Uri getUri ()

Returns the Uri from which this provided was created.

Returns
  • The Uri this data provider was created from.

public void writeToParcel (Parcel dest, int flags)

Protected Methods

protected InputStream openInputStream ()

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.

Returns
  • A new instance of the InputStream that servers the PDF document.
Throws
Exception