PdfDocument


public interface PdfDocument extends Closeable

Known direct subclasses
EditablePdfDocument

Represents a PDF document that allows for editing.


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.

Listener interface for receiving notifications when some regions of the PDF content are invalidated.

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.

Constants

default static final long

Flag to include all types of form widgets in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_CHECKBOX in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_COMBOBOX in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_LISTBOX in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_PUSHBUTTON in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_RADIOBUTTON in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_SIGNATURE in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_TEXTFIELD in getFormWidgetInfos

default static final long

Flag to include FormWidgetInfo.WIDGET_TYPE_UNKNOWN in getFormWidgetInfos

default static final long

Flag used with getPageInfo to exclude any additional information in the returned PageInfo

default static final long

Flag used with getPageInfo to include form widget metadata in the PageInfo

default static final int

Represents a PDF with form fields specified using the AcroForm spec

default static final int

Represents a PDF with no form fields

default static final int

Represents a PDF with form fields specified using the XFAF subset of the XFA spec

default static final int

Represents a PDF with form fields specified using the entire XFA spec

Public methods

abstract void

Adds a listener to receive notifications when some regions of the PDF content are invalidated.

abstract int

The type of form present in the document.

abstract @NonNull List<@NonNull FormWidgetInfo>
getFormWidgetInfos(int pageNum, long types)

Returns the list of FormWidgetInfo on pageNum, optionally filtered by widget type.

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 PdfDocument.PageInfo
getPageInfo(int pageNumber, long pageInfoFlags)

Asynchronously retrieves information about the specified page.

abstract @NonNull List<@NonNull PdfDocument.PageInfo>

Asynchronously retrieves information about a range of pages.

abstract @NonNull List<@NonNull PdfDocument.PageInfo>
getPageInfos(@NonNull IntRange pageRange, long pageInfoFlags)

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 @NonNull RenderParams

The render params used to determine the contents that will be rendered on the bitmap.

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 void

Removes the listener from the list of listeners which are notified when some regions of the PDF content are invalidated.

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

Constants

FORM_WIDGET_INCLUDE_ALL_TYPES

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_ALL_TYPES

Flag to include all types of form widgets in getFormWidgetInfos

FORM_WIDGET_INCLUDE_CHECKBOX_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_CHECKBOX_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_CHECKBOX in getFormWidgetInfos

FORM_WIDGET_INCLUDE_COMBOBOX_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_COMBOBOX_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_COMBOBOX in getFormWidgetInfos

FORM_WIDGET_INCLUDE_LISTBOX_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_LISTBOX_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_LISTBOX in getFormWidgetInfos

FORM_WIDGET_INCLUDE_PUSHBUTTON_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_PUSHBUTTON_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_PUSHBUTTON in getFormWidgetInfos

FORM_WIDGET_INCLUDE_RADIOBUTTON_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_RADIOBUTTON_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_RADIOBUTTON in getFormWidgetInfos

FORM_WIDGET_INCLUDE_SIGNATURE_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_SIGNATURE_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_SIGNATURE in getFormWidgetInfos

FORM_WIDGET_INCLUDE_TEXTFIELD_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_TEXTFIELD_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_TEXTFIELD in getFormWidgetInfos

FORM_WIDGET_INCLUDE_UNKNOWN_TYPE

Added in 1.0.0-alpha13
default static final long FORM_WIDGET_INCLUDE_UNKNOWN_TYPE

Flag to include FormWidgetInfo.WIDGET_TYPE_UNKNOWN in getFormWidgetInfos

PAGE_INFO_EXCLUDE_FORM_WIDGETS

Added in 1.0.0-alpha13
default static final long PAGE_INFO_EXCLUDE_FORM_WIDGETS = 0

Flag used with getPageInfo to exclude any additional information in the returned PageInfo

PAGE_INFO_INCLUDE_FORM_WIDGET

Added in 1.0.0-alpha13
default static final long PAGE_INFO_INCLUDE_FORM_WIDGET

Flag used with getPageInfo to include form widget metadata in the PageInfo

PDF_FORM_TYPE_ACRO_FORM

Added in 1.0.0-alpha13
default static final int PDF_FORM_TYPE_ACRO_FORM = 1

Represents a PDF with form fields specified using the AcroForm spec

PDF_FORM_TYPE_NONE

Added in 1.0.0-alpha13
default static final int PDF_FORM_TYPE_NONE = 0

Represents a PDF with no form fields

PDF_FORM_TYPE_XFA_FOREGROUND

Added in 1.0.0-alpha13
default static final int PDF_FORM_TYPE_XFA_FOREGROUND = 3

Represents a PDF with form fields specified using the XFAF subset of the XFA spec

PDF_FORM_TYPE_XFA_FULL

Added in 1.0.0-alpha13
default static final int PDF_FORM_TYPE_XFA_FULL = 2

Represents a PDF with form fields specified using the entire XFA spec

Public methods

addOnPdfContentInvalidatedListener

Added in 1.0.0-alpha13
abstract void addOnPdfContentInvalidatedListener(
    @NonNull Executor executor,
    @NonNull PdfDocument.OnPdfContentInvalidatedListener listener
)

Adds a listener to receive notifications when some regions of the PDF content are invalidated.

Parameters
@NonNull Executor executor

The executor on which the listener's methods will be called.

@NonNull PdfDocument.OnPdfContentInvalidatedListener listener

The listener to add.

getFormType

Added in 1.0.0-alpha13
abstract int getFormType()

The type of form present in the document.

See also
PdfDocument.FormType

for the supported types.

getFormWidgetInfos

abstract @NonNull List<@NonNull FormWidgetInfogetFormWidgetInfos(int pageNum, long types)

Returns the list of FormWidgetInfo on pageNum, optionally filtered by widget type.

Parameters
int pageNum

The page number (0-based).

long types

Bitmask to determine the types of form widgets to include in the result. Includes all types of form widgets by default.

Returns
@NonNull List<@NonNull FormWidgetInfo>

A list of FormWidgetInfo objects representing the form widgets of the specified types on the specified page.

getPageBitmapSource

Added in 1.0.0-alpha13
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-alpha13
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.

getPageInfo

abstract @NonNull PdfDocument.PageInfo getPageInfo(int pageNumber, long pageInfoFlags)

Asynchronously retrieves information about the specified page.

Parameters
int pageNumber

The page number (0-based).

long pageInfoFlags

A bitmask for retrieving additional page information. Does not include any additional information by default.

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.

getPageInfos

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

Asynchronously retrieves information about a range of pages.

Parameters
@NonNull IntRange pageRange

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

long pageInfoFlags

A bitmask for retrieving additional page information. Does not include any additional information by default.

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.

getRenderParams

Added in 1.0.0-alpha13
abstract @NonNull RenderParams getRenderParams()

The render params used to determine the contents that will be rendered on the bitmap.

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-alpha13
abstract @NonNull Uri getUri()

The URI of the document represented by this object

isLinearized

Added in 1.0.0-alpha13
abstract boolean isLinearized()

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

removeOnPdfContentInvalidatedListener

Added in 1.0.0-alpha13
abstract void removeOnPdfContentInvalidatedListener(
    @NonNull PdfDocument.OnPdfContentInvalidatedListener listener
)

Removes the listener from the list of listeners which are notified when some regions of the PDF content are invalidated.

Parameters
@NonNull PdfDocument.OnPdfContentInvalidatedListener listener

The listener to remove.

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.