PdfDocument


public interface PdfDocument extends Closeable


Represents a PDF document and provides methods to interact with its content.

Summary

Nested types

public interface PdfDocument.BitmapSource extends Closeable

A source for retrieving bitmap representations of PDF pages.

public final class PdfDocument.PageInfo

Represents information about a single page in the PDF document.

public final class PdfDocument.PdfPageContent

Represents the combined text and image content within a single page of a PDF document.

public final class PdfDocument.PdfPageLinks

Represents the links within a single page of a PDF document.

Public methods

abstract @NonNull PdfDocument.BitmapSource
getPageBitmapSource(int pageNumber)

Gets a BitmapSource for retrieving bitmap representations of the specified page.

abstract PdfDocument.PdfPageContent
getPageContent(int pageNumber)

Asynchronously retrieves the content (text and images) of the specified page.

abstract int

The total number of pages in the document.

abstract @NonNull PdfDocument.PageInfo
getPageInfo(int pageNumber)

Asynchronously retrieves information about the specified page.

abstract @NonNull List<@NonNull PdfDocument.PageInfo>

Asynchronously retrieves information about a range of pages.

abstract @NonNull PdfDocument.PdfPageLinks
getPageLinks(int pageNumber)

Asynchronously retrieves the links (Go To and external) present on the specified page.

abstract PageSelection
getSelectionBounds(
    int pageNumber,
    @NonNull PointF start,
    @NonNull PointF stop
)

Asynchronously retrieves the selection bounds (in PDF coordinates) for the specified text selection.

abstract @NonNull Uri

The URI of the document represented by this object

abstract boolean

Indicates whether the document is linearized (optimized for fast web viewing).

abstract @NonNull SparseArray<@NonNull List<@NonNull PageMatchBounds>>

Asynchronously searches the document for the specified query within a range of pages.

Inherited methods

From java.io.Closeable
abstract void

Public methods

getPageBitmapSource

Added in 1.0.0-alpha10
abstract @NonNull PdfDocument.BitmapSource getPageBitmapSource(int pageNumber)

Gets a BitmapSource for retrieving bitmap representations of the specified page.

Parameters
int pageNumber

The page number (0-based).

Returns
@NonNull PdfDocument.BitmapSource

A BitmapSource for the specified page, or null if the page number is invalid.

getPageContent

abstract PdfDocument.PdfPageContent getPageContent(int pageNumber)

Asynchronously retrieves the content (text and images) of the specified page.

Parameters
int pageNumber

The page number (0-based).

Returns
PdfDocument.PdfPageContent

A PdfPageContent object representing the page's content.

getPageCount

Added in 1.0.0-alpha10
abstract int getPageCount()

The total number of pages in the document.

getPageInfo

abstract @NonNull PdfDocument.PageInfo getPageInfo(int pageNumber)

Asynchronously retrieves information about the specified page.

Parameters
int pageNumber

The page number (0-based).

Returns
@NonNull PdfDocument.PageInfo

A PageInfo object containing information about the page.

getPageInfos

abstract @NonNull List<@NonNull PdfDocument.PageInfogetPageInfos(@NonNull IntRange pageRange)

Asynchronously retrieves information about a range of pages.

Parameters
@NonNull IntRange pageRange

The range of page numbers (0-based, inclusive).

Returns
@NonNull List<@NonNull PdfDocument.PageInfo>

A list of PageInfo objects, one for each page in the range.

getPageLinks

abstract @NonNull PdfDocument.PdfPageLinks getPageLinks(int pageNumber)

Asynchronously retrieves the links (Go To and external) present on the specified page.

Parameters
int pageNumber

The page number (0-based).

Returns
@NonNull PdfDocument.PdfPageLinks

A PdfPageLinks object representing the page's links.

getSelectionBounds

abstract PageSelection getSelectionBounds(
    int pageNumber,
    @NonNull PointF start,
    @NonNull PointF stop
)

Asynchronously retrieves the selection bounds (in PDF coordinates) for the specified text selection.

Parameters
int pageNumber

The page on which text to be selected.

@NonNull PointF start

The starting point of the text selection.

@NonNull PointF stop

The ending point of the text selection.

Returns
PageSelection

A PageSelection object representing the selection bounds on the page.

getUri

Added in 1.0.0-alpha10
abstract @NonNull Uri getUri()

The URI of the document represented by this object

isLinearized

Added in 1.0.0-alpha10
abstract boolean isLinearized()

Indicates whether the document is linearized (optimized for fast web viewing).

searchDocument

abstract @NonNull SparseArray<@NonNull List<@NonNull PageMatchBounds>> searchDocument(@NonNull String query, @NonNull IntRange pageRange)

Asynchronously searches the document for the specified query within a range of pages.

Parameters
@NonNull String query

The search query string.

@NonNull IntRange pageRange

The range of page numbers (0-based, inclusive) to search within.

Returns
@NonNull SparseArray<@NonNull List<@NonNull PageMatchBounds>>

A SparseArray mapping page numbers to lists of PageMatchBounds objects representing the search results on each page.