EditablePdfDocument


public interface EditablePdfDocument extends PdfDocument


Represents a PDF document that allows for editing.

Summary

Public methods

abstract void

Applies the changes specified by record to the form.

abstract @NonNull List<@NonNull String>

Applies a list of edits to the document sequentially.

abstract @NonNull PdfWriteHandle

Creates a PdfWriteHandle which can be used to save the document to a ParcelFileDescriptor.

Inherited methods

From java.lang.AutoCloseable
abstract void
From androidx.pdf.PdfDocument
default void

Adds a listener to be notified when an edit is applied on the document.

abstract void

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

abstract @NonNull List<@NonNull KeyedPdfAnnotation>
getAnnotationsForPage(int pageNum)

Retrieves a list of all annotations for the specified page.

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 int

Indicates the linearization status of the document.

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

default void

Remove a listener for applied edits.

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.

Public methods

applyEdit

Added in 1.0.0-alpha19
abstract void applyEdit(@NonNull FormEditInfo record)

Applies the changes specified by record to the form.

Any areas which are invalidated due to this operation are notified via OnPdfContentInvalidatedListener callback.

It is recommended to maintain a list of androidx.pdf.models.FormEditInfo applied to the document so they can be saved and restored across destructive events like low memory kills or configuration changes.

Parameters
@NonNull FormEditInfo record

The androidx.pdf.models.FormEditInfo to apply to the form.

Throws
IllegalArgumentException

if the provided record cannot be applied to the widget indicated by the index, or if the index does not correspond to a widget on the page.

applyEdits

abstract @NonNull List<@NonNull StringapplyEdits(@NonNull EditsDraft editsDraft)

Applies a list of edits to the document sequentially. The edits are sorted by page number before applying using EditsDraft.getOperationsSortedByPage.

Parameters
@NonNull EditsDraft editsDraft

: edits to be applied on pdf document.

Returns
@NonNull List<@NonNull String>

List of annotationId for each operation in sequence of the order they were enqueued.

Throws
PdfEditApplyException

if any of the edit failed to be applied.

createWriteHandle

Added in 1.0.0-alpha19
abstract @NonNull PdfWriteHandle createWriteHandle()

Creates a PdfWriteHandle which can be used to save the document to a ParcelFileDescriptor.