public class

PdfDocumentLoader

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.PdfDocumentLoader

Class Overview

Provides methods to obtain PdfDocument instances.

Summary

Public Methods
static PdfDocument openDocument(Context context, Uri documentUri)
Opens a PDF document from a Uri.
static PdfDocument openDocument(Context context, DocumentSource source)
Opens a PDF document from a Uri.
static PdfDocument openDocument(Context context, DocumentSource source, boolean multithreadedRenderingEnabled)
Opens a PDF document from a Uri.
static PdfDocument openDocument(Context context, Uri documentUri, String password)
Opens a PDF document from a Uri.
static Single<PdfDocument> openDocumentAsync(Context context, DocumentSource source)
Opens a PDF document from a DocumentSource.
static Single<PdfDocument> openDocumentAsync(Context context, Uri documentUri)
Opens a PDF document from an Uri.
static Single<PdfDocument> openDocumentAsync(Context context, DocumentSource source, boolean multithreadedRenderingEnabled)
Opens a PDF document from an Uri.
static Single<PdfDocument> openDocumentAsync(Context context, Uri documentUri, String password)
Opens a PDF document from an Uri.
static PdfDocument openDocuments(Context context, List<DocumentSource> sources, boolean multithreadedRenderingEnabled)
Opens multiple PDF document from a list of sources.
static PdfDocument openDocuments(Context context, List<DocumentSource> sources)
Opens multiple PDF document from a list of sources.
static Single<PdfDocument> openDocumentsAsync(Context context, List<DocumentSource> sources, boolean multithreadedRenderingEnabled)
Opens multiple PDF document from a list Uris.
static Single<PdfDocument> openDocumentsAsync(Context context, List<DocumentSource> sources)
Opens multiple PDF document from a list Uris.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static PdfDocument openDocument (Context context, Uri documentUri)

Opens a PDF document from a Uri. Note that currently only local files are supported and passing remote or non-file Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
documentUri Uri pointing to the PDF document.
Returns
Throws
IOException If file was not opened correctly.
InvalidPasswordException If opening the document failed due to password protection. To specify a password for opening the file, use the openDocument(Context, Uri, String) method instead.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.

public static PdfDocument openDocument (Context context, DocumentSource source)

Opens a PDF document from a Uri. Note that currently only local files are supported and passing remote or Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
source DocumentSource describing the source and password of this document.
Returns
Throws
IOException If file was not opened correctly.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.
InvalidPasswordException If no password or a wrong password was provided for opening the document.
InvalidSignatureException If the provided contentSignature does not match the opened document.

public static PdfDocument openDocument (Context context, DocumentSource source, boolean multithreadedRenderingEnabled)

Opens a PDF document from a Uri. Note that currently only local files are supported and passing remote or Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
source DocumentSource describing the source and password of this document.
multithreadedRenderingEnabled Whether the multithreaded rendering should be enabled when rendering document pages.
Returns
Throws
IOException If file was not opened correctly.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.
InvalidPasswordException If no password or a wrong password was provided for opening the document.
InvalidSignatureException If the provided contentSignature does not match the opened document.

public static PdfDocument openDocument (Context context, Uri documentUri, String password)

Opens a PDF document from a Uri. Note that currently only local files are supported and passing remote or non-file Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
documentUri Uri pointing to the PDF document.
password PDF document password, may be null.
Returns
Throws
IOException If file was not opened correctly.
InvalidPasswordException If no password or a wrong password was provided for opening the document.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentAsync (Context context, DocumentSource source)

Opens a PDF document from a DocumentSource. The returned Single may fail with a InvalidPasswordException when trying to open a password protected document.

Parameters
context Application context
source DocumentSource of the document.
Returns
  • Observable which returns a single opened document when called successfully
Throws
PSPDFKitNotInitializedException if PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentAsync (Context context, Uri documentUri)

Opens a PDF document from an Uri. Note that currently only local files are supported and passing remote or non-file Uris will return a IOException. If the document being opened is password protected, the returned Single will fail with an InvalidPasswordException. To open password protected documents use openDocumentAsync(Context, Uri, String) instead.

Parameters
context Application context
documentUri Uri pointing to the PDF document.
Returns
  • Observable which returns a single opened document when called successfully
Throws
PSPDFKitNotInitializedException if PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentAsync (Context context, DocumentSource source, boolean multithreadedRenderingEnabled)

Opens a PDF document from an Uri. Note that currently only local files are supported and passing remote or non-file Uris will return a IOException.

Parameters
context Application context
source DocumentSource of the document.
multithreadedRenderingEnabled Whether the multithreaded rendering should be enabled when rendering document pages.
Returns
  • Observable which returns a single opened document when called successfully
Throws
PSPDFKitNotInitializedException if PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentAsync (Context context, Uri documentUri, String password)

Opens a PDF document from an Uri. Note that currently only local files are supported and passing remote or non-file Uris will return a IOException. The returned Single may fail with a InvalidPasswordException if no password or a wrong password was provided for opening the document.

Parameters
context Application context
documentUri Uri pointing to the PDF document.
password PDF document password, may be null.
Returns
  • Observable which returns a single opened document when called successfully
Throws
PSPDFKitNotInitializedException if PSPDFKit was not initialized with initialize(Context, String) call.

public static PdfDocument openDocuments (Context context, List<DocumentSource> sources, boolean multithreadedRenderingEnabled)

Opens multiple PDF document from a list of sources. The documents will be displayed as a single continuous document. Note that currently only local files are supported and passing remote or Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
sources List of DocumentSources describing the sources and passwords of the documents.
multithreadedRenderingEnabled Whether the multithreaded rendering should be enabled when rendering document pages.
Returns
Throws
IOException If file was not opened correctly.
InvalidPasswordException If no passwords or a wrong passwords were provided for opening the documents.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.

public static PdfDocument openDocuments (Context context, List<DocumentSource> sources)

Opens multiple PDF document from a list of sources. The documents will be displayed as a single continuous document. Note that currently only local files are supported and passing remote or Uris will throw an IOException.

Note that this method blocks until the document is loaded and should not be invoked on main thread.

Parameters
context Application context.
sources List of DocumentSources describing the sources and passwords of the documents.
Returns
Throws
IOException If file was not opened correctly.
InvalidPasswordException If no passwords or a wrong passwords were provided for opening the documents.
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentsAsync (Context context, List<DocumentSource> sources, boolean multithreadedRenderingEnabled)

Opens multiple PDF document from a list Uris. The documents will be displayed as a single continuous document. Note that currently only local files are supported and passing remote or non-file Uris will throw an IOException. The returned Single will fail with an InvalidPasswordException when trying to open a password protected document with no or a wrong password. To specify a password, create the DocumentSource instances using one of the constructors taking a password.

Parameters
context Application context.
sources List of DocumentSources for this document.
multithreadedRenderingEnabled Whether the multithreaded rendering should be enabled when rendering document pages.
Returns
  • Observable which returns a compound document when called successfully.
Throws
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.

public static Single<PdfDocument> openDocumentsAsync (Context context, List<DocumentSource> sources)

Opens multiple PDF document from a list Uris. The documents will be displayed as a single continuous document. Note that currently only local files are supported and passing remote or non-file Uris will throw an IOException. The returned Single will fail with an InvalidPasswordException when trying to open a password protected document with no or a wrong password. To specify a password, create the DocumentSource instances using one of the constructors taking a password.

Parameters
context Application context.
sources List of DocumentSources for this document.
Returns
  • Observable which returns a compound document when called successfully.
Throws
PSPDFKitNotInitializedException If PSPDFKit was not initialized with initialize(Context, String) call.