public class

DocumentDescriptor

extends Object
implements Parcelable
java.lang.Object
   ↳ com.pspdfkit.ui.DocumentDescriptor

Class Overview

Describes a document and its UI state. The DocumentDescriptor is used by the PdfActivity's DocumentCoordinator to handle multiple loaded documents and to manage their state.

Document is represented by the list of parcelable DocumentSources. Descriptor also holds loaded PdfDocument after it's loaded by the DocumentCoordinator. Note that this PdfDocument instance won't be restored after reading from the parcel - it must be loaded again in this case.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<DocumentDescriptor> CREATOR
Protected Constructors
DocumentDescriptor(Parcel in)
Public Methods
int describeContents()
static DocumentDescriptor fromDataProvider(DataProvider dataProvider, String password, String contentSignature)
Creates descriptor for document loaded from data provider.
static DocumentDescriptor fromDataProvider(DataProvider dataProvider)
Creates descriptor for document loaded from data provider.
static DocumentDescriptor fromDataProvider(DataProvider dataProvider, String password)
Creates descriptor for document loaded from data provider.
static DocumentDescriptor fromDataProviders(List<DataProvider> dataProviders, List<String> passwords, List<String> contentSignatures)
Creates descriptor for compound document loaded from data providers.
static DocumentDescriptor fromDocument(PdfDocument document)
Creates descriptor for loaded document.
static DocumentDescriptor fromDocumentSource(DocumentSource documentSource)
Creates descriptor for document loaded from document source.
static DocumentDescriptor fromDocumentSources(List<DocumentSource> documentSources)
Creates descriptor for compound document loaded from document sources.
static DocumentDescriptor fromUri(Uri documentUri, String password)
Creates descriptor for document loaded from URI.
static DocumentDescriptor fromUri(Uri documentUri)
Creates descriptor for document loaded from URI.
static DocumentDescriptor fromUris(List<Uri> documentUris, List<String> passwords, List<String> contentSignatures)
Creates descriptor for compound document loaded from multiple URIs.
String getCustomTitle()
Returns custom document title that has been previously set via setTitle(String).
PdfDocument getDocument()
Returns document instance (if already loaded).
DocumentSource getDocumentSource()
Returns source from which the document should be loaded.
List<DocumentSource> getDocumentSources()
Returns list of DocumentSources from which the document should be loaded.
Bundle getState()
Returns UI state associated with the document.
String getTitle(Context context)
Returns displayable document title.
String getUid()
Returns unique document ID.
static DocumentDescriptor imageDocumentFromDataProvider(DataProvider dataProvider)
Creates descriptor for image document loaded from data provider.
static DocumentDescriptor imageDocumentFromDocumentSource(DocumentSource documentSource)
Creates descriptor for image document loaded from a document source.
static DocumentDescriptor imageDocumentFromUri(Uri uri)
Creates descriptor for image document loaded from URI.
boolean isImageDocument()
Checks whether descriptor describes an image document.
void setDocument(PdfDocument document)
Sets document instance associated with this descriptor.
void setState(Bundle state)
Sets UI state (activity or fragment) associated with the document.
void setTitle(String title)
Sets a custom displayable document title.
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<DocumentDescriptor> CREATOR

Protected Constructors

protected DocumentDescriptor (Parcel in)

Public Methods

public int describeContents ()

public static DocumentDescriptor fromDataProvider (DataProvider dataProvider, String password, String contentSignature)

Creates descriptor for document loaded from data provider.

Parameters
dataProvider Data provider for the document.
password Document password. May be null.
contentSignature Document content signature. May be null.

public static DocumentDescriptor fromDataProvider (DataProvider dataProvider)

Creates descriptor for document loaded from data provider.

Parameters
dataProvider Data provider for the document.

public static DocumentDescriptor fromDataProvider (DataProvider dataProvider, String password)

Creates descriptor for document loaded from data provider.

Parameters
dataProvider Data provider for the document.
password Document password. May be null.

public static DocumentDescriptor fromDataProviders (List<DataProvider> dataProviders, List<String> passwords, List<String> contentSignatures)

Creates descriptor for compound document loaded from data providers.

Parameters
dataProviders List of data providers for compound document.
passwords List of passwords for compound document, may be null.
contentSignatures List of content signatures for compound document, may be null.

public static DocumentDescriptor fromDocument (PdfDocument document)

Creates descriptor for loaded document.

Parameters
document Document instance.

public static DocumentDescriptor fromDocumentSource (DocumentSource documentSource)

Creates descriptor for document loaded from document source.

Parameters
documentSource Source of the document data.

public static DocumentDescriptor fromDocumentSources (List<DocumentSource> documentSources)

Creates descriptor for compound document loaded from document sources.

Parameters
documentSources List of sources for compound document.

public static DocumentDescriptor fromUri (Uri documentUri, String password)

Creates descriptor for document loaded from URI.

Parameters
documentUri Uri of the PDF file.
password Passwords of the document to open, may be null.

public static DocumentDescriptor fromUri (Uri documentUri)

Creates descriptor for document loaded from URI.

Parameters
documentUri Uri of the PDF file.

public static DocumentDescriptor fromUris (List<Uri> documentUris, List<String> passwords, List<String> contentSignatures)

Creates descriptor for compound document loaded from multiple URIs.

Parameters
documentUris List of document URIs for compound document.
passwords List of passwords for compound document, may be null.
contentSignatures List of content signatures for compound document, may be null.

public String getCustomTitle ()

Returns custom document title that has been previously set via setTitle(String).

Returns
  • Custom title set on the document descriptor.

public PdfDocument getDocument ()

Returns document instance (if already loaded).

Returns
  • Document instance if document has been loaded, null otherwise.

public DocumentSource getDocumentSource ()

Returns source from which the document should be loaded. A source can be either a file URI or a DataProvider.

Returns
  • The DocumentSource for this document. If the document is a compound one (i.e. it contains multiple files) this method returns the first entry of the array returned by getDocumentSources().

public List<DocumentSource> getDocumentSources ()

Returns list of DocumentSources from which the document should be loaded. A source can be either a file URI or a DataProvider. Only compound documents will have multiple sources.

Returns
  • A list of DocumentSources for this document. If the document is a compound one (i.e. is read from multiple sources) it will have several sources, otherwise it the list will contain a single entry.

public Bundle getState ()

Returns UI state associated with the document.

Returns
  • Bundle with the UI state or null if not available.

public String getTitle (Context context)

Returns displayable document title.

Parameters
context The context used to retrieve localized title.
Returns
  • Document title that can be displayed in the UI.

public String getUid ()

Returns unique document ID.

public static DocumentDescriptor imageDocumentFromDataProvider (DataProvider dataProvider)

Creates descriptor for image document loaded from data provider.

Parameters
dataProvider Data provider for the image document.

public static DocumentDescriptor imageDocumentFromDocumentSource (DocumentSource documentSource)

Creates descriptor for image document loaded from a document source.

Parameters
documentSource Source of the image document data.

public static DocumentDescriptor imageDocumentFromUri (Uri uri)

Creates descriptor for image document loaded from URI.

Parameters
uri URI for the image document.

public boolean isImageDocument ()

Checks whether descriptor describes an image document.

Returns
  • true if this is a descriptor for an image document.

public void setDocument (PdfDocument document)

Sets document instance associated with this descriptor.

Parameters
document Document instance, or null to clear existing document instance.

public void setState (Bundle state)

Sets UI state (activity or fragment) associated with the document.

Parameters
state Bundle with UI state.

public void setTitle (String title)

Sets a custom displayable document title. When null the default document title will be used.

Note: This method does not modify the PDF document, to persistently set the title in the PDF metadata see setTitle(String).

Parameters
title Custom document title to display.

public void writeToParcel (Parcel dest, int flags)