Class PdfDocumentLoader

    • Constructor Detail

    • Method Detail

      • openDocument

        @NonNull() static PdfDocument openDocument(@NonNull() Context context, @NonNull() Uri documentUri)

        Opens a PDF document from a Uri. Remote Uri's are supported and automatically downloaded.

        Note that this method blocks until the document is loaded and should not be invoked on main thread. If you're passing a remote Uri and run this method on the main thread, it will throw an DownloadException.DownloadOnMainThreadException.

        Parameters:
        context - Application context.
        documentUri - Uri pointing to the PDF document.
        Returns:

        PdfDocument instance if the opening succeeded.

      • openDocument

        @NonNull() static PdfDocument openDocument(@NonNull() Context context, @NonNull() Uri documentUri, @Nullable() String password)

        Opens a PDF document from a Uri. Remote Uri's are supported and automatically downloaded.

        Note that this method blocks until the document is loaded and should not be invoked on main thread. If you're passing a remote Uri and run this method on the main thread, it will throw an DownloadException.DownloadOnMainThreadException.

        Parameters:
        context - Application context.
        documentUri - Uri pointing to the PDF document.
        password - PDF document password, may be null.
        Returns:

        PdfDocument instance if the opening succeeded.

      • openDocument

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

        Opens a PDF document from a Uri. Remote Uri's are supported and automatically downloaded.

        Note that this method blocks until the document is loaded and should not be invoked on main thread. If you're passing a remote Uri and run this method on the main thread, it will throw an DownloadException.DownloadOnMainThreadException.

        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:

        PdfDocument instance if opening succeeded.

      • openDocuments

        @NonNull() static PdfDocument openDocuments(@NonNull() Context context, @NonNull() @Size(min = 1) List<DocumentSource> sources)

        Opens multiple PDF document from a list of sources. The documents will be displayed as a single continuous document. Remote Uri's are supported and automatically downloaded.

        Note that this method blocks until the document is loaded and should not be invoked on main thread. If you're passing a remote Uri and run this method on the main thread, it will throw an DownloadException.DownloadOnMainThreadException.

        Parameters:
        context - Application context.
        sources - List of DocumentSources describing the sources and passwords of the documents.
        Returns:

        PdfDocument instance if the opening succeeded.

      • openDocuments

        @NonNull() static PdfDocument openDocuments(@NonNull() Context context, @NonNull() @Size(min = 1) List<DocumentSource> sources, boolean multithreadedRenderingEnabled)

        Opens multiple PDF document from a list of sources. The documents will be displayed as a single continuous document. Remote Uri's are supported and automatically downloaded.

        Note that this method blocks until the document is loaded and should not be invoked on main thread. If you're passing a remote Uri and run this method on the main thread, it will throw an DownloadException.DownloadOnMainThreadException.

        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:

        PdfDocument instance if the opening succeeded.

      • openDocumentAsync

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

        Opens a PDF document from an Uri. Remote Uri's are supported and automatically downloaded. If the document being opened is password protected, the returned Single will fail with an InvalidPasswordException. To open password protected documents use openDocumentAsync instead. The returned Single may also fail with a DownloadException if anything happened during the download of a remote Uri.

        Parameters:
        context - Application context
        documentUri - Uri pointing to the PDF document.
        Returns:

        Observable which returns a single opened document when called successfully

      • openDocumentAsync

        @NonNull() static Single<PdfDocument> openDocumentAsync(@NonNull() Context context, @NonNull() Uri documentUri, @Nullable() String password)

        Opens a PDF document from an Uri. Remote Uri's are supported and automatically downloaded. The returnedSingle may fail with a InvalidPasswordException if no password or a wrong password was provided for opening the document. The returned Single may also fail with a DownloadException if anything happened during the download of a remote Uri.

        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

      • openDocumentAsync

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

        Opens a PDF document from an Uri. Remote Uri's are supported and automatically downloaded. The returned Single may fail with a InvalidPasswordException when trying to open a password protected document. The returned Single may also fail with a DownloadException if anything happened during the download of a remote Uri.

        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

      • openDocumentsAsync

        @NonNull() static Single<PdfDocument> openDocumentsAsync(@NonNull() Context context, @NonNull() @Size(min = 1) List<DocumentSource> sources)

        Opens multiple PDF document from a list Uris. The documents will be displayed as a single continuous document. Remote Uri's are supported and automatically downloaded. 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 instances using one of the constructors taking a password. The returned Single may also fail with a DownloadException if anything happened during the download of a remote Uri.

        Parameters:
        context - Application context.
        sources - List of DocumentSources for this document.
        Returns:

        Observable which returns a compound document when called successfully.

      • openDocumentsAsync

        @NonNull() static Single<PdfDocument> openDocumentsAsync(@NonNull() Context context, @NonNull() @Size(min = 1) List<DocumentSource> sources, boolean multithreadedRenderingEnabled)

        Opens multiple PDF document from a list Uris. The documents will be displayed as a single continuous document. Remote Uri's are supported and automatically downloaded. 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 instances using one of the constructors taking a password. The returned Single may also fail with a DownloadException if anything happened during the download of a remote Uri.

        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.