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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AssetDataProvider

        AssetDataProvider(String assetName)
        Parameters:
        assetName - Filename of the asset in the application assets folder.
    • Method Detail

      • 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.

      • getUri

         Uri getUri()

        Returns the Uri from which this provided was created.

        Returns:

        The Uri this data provider was created from.