openDocument

open fun openDocument(@NonNull context: Context, @NonNull documentUri: Uri): PdfDocument

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 java.io.IOException.

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

Return

PdfDocument instance if the opening succeeded.

Parameters

context

Application context.

documentUri

Uri pointing to the PDF document.

Throws

If file was not opened correctly.

If opening the document failed due to password protection. To specify a password for opening the file, use the openDocument method instead.

If PSPDFKit was not initialized with initialize call.


open fun openDocument(@NonNull context: Context, @NonNull documentUri: Uri, @Nullable password: String): PdfDocument

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.

Return

PdfDocument instance if the opening succeeded.

Parameters

context

Application context.

documentUri

Uri pointing to the PDF document.

password

PDF document password, may be null.

Throws

If file was not opened correctly.

If no password or a wrong password was provided for opening the document.

If PSPDFKit was not initialized with initialize call.


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

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

Return

PdfDocument instance if opening succeeded.

Parameters

context

Application context.

source

DocumentSource describing the source and password of this document.

Throws

If file was not opened correctly.

If PSPDFKit was not initialized with initialize call.

If no password or a wrong password was provided for opening the document.

If the provided contentSignature does not match the opened document.


open fun openDocument(@NonNull context: Context, @NonNull source: DocumentSource, multithreadedRenderingEnabled: Boolean): PdfDocument

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

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

Return

PdfDocument instance if opening succeeded.

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.

Throws

If file was not opened correctly.

If PSPDFKit was not initialized with initialize call.

If no password or a wrong password was provided for opening the document.

If the provided contentSignature does not match the opened document.