Class AssetDataProvider
-
- All Implemented Interfaces:
-
android.os.Parcelable
,com.pspdfkit.document.providers.DataProvider
,com.pspdfkit.document.providers.UriDataProvider
public class AssetDataProvider extends InputStreamDataProvider implements Parcelable, UriDataProvider
Data provider for opening PDF documents directly from the app's assets.
Default constructor taking the
assetName
of a document. The filename/path needs to be relative to the asset directory.
-
-
Field Summary
Fields Modifier and Type Field Description public final static Parcelable.Creator<AssetDataProvider>
CREATOR
private final String
assetName
-
Constructor Summary
Constructors Constructor Description AssetDataProvider(String assetName)
-
Method Summary
Modifier and Type Method Description final String
getAssetName()
Long
getSize()
Return the actual file size of the PDF document which is provided by this data provider. String
getUid()
Unique document identifier used in all caching processes in PSPDFKit. String
getTitle()
Displayable document title to be used if PDF document does not contain metadata. Integer
describeContents()
Unit
writeToParcel(Parcel dest, Integer flags)
Uri
getUri()
Returns the Uri from which this provided was created. -
-
Constructor Detail
-
AssetDataProvider
AssetDataProvider(String assetName)
- Parameters:
assetName
- Filename of the asset in the application assets folder.
-
-
Method Detail
-
getAssetName
final String getAssetName()
-
getSize
Long getSize()
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.
- Returns:
Returns size of PDF document data in bytes, or FILE_SIZE_UNKNOWN in case of an error.
-
getUid
String getUid()
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.
- Returns:
Unique identifier of the provided document. Implementations may not return
null
or an exception will be thrown.
-
getTitle
String getTitle()
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.
- Returns:
Fallback document title if PDF document does not contain the required metadata. May be null.
-
describeContents
Integer describeContents()
-
writeToParcel
Unit writeToParcel(Parcel dest, Integer flags)
-
-
-
-