EditablePdfDocument


interface EditablePdfDocument : PdfDocument


Represents a PDF document that allows for editing.

Summary

Public functions

suspend Unit

Applies the changes specified by record to the form.

suspend List<String>
applyEdits(editsDraft: EditsDraft)

Applies a list of edits to the document sequentially.

PdfWriteHandle

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

Inherited functions

From java.lang.AutoCloseable
From androidx.pdf.PdfDocument
open Unit

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

Unit

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

suspend List<KeyedPdfAnnotation>

Retrieves a list of all annotations for the specified page.

suspend List<FormWidgetInfo>
getFormWidgetInfos(pageNum: Int, types: Long)

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

PdfDocument.BitmapSource
getPageBitmapSource(pageNumber: Int)

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

suspend PdfDocument.PdfPageContent?
getPageContent(pageNumber: Int)

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

suspend PdfDocument.PageInfo
getPageInfo(pageNumber: Int)

Asynchronously retrieves information about the specified page.

suspend PdfDocument.PageInfo
getPageInfo(pageNumber: Int, pageInfoFlags: Long)

Asynchronously retrieves information about the specified page.

suspend List<PdfDocument.PageInfo>
getPageInfos(pageRange: IntRange)

Asynchronously retrieves information about a range of pages.

suspend List<PdfDocument.PageInfo>
getPageInfos(pageRange: IntRange, pageInfoFlags: Long)

Asynchronously retrieves information about a range of pages.

suspend PdfDocument.PdfPageLinks
getPageLinks(pageNumber: Int)

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

suspend PageSelection?
getSelectionBounds(pageNumber: Int, start: PointF, stop: PointF)

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

open Unit

Remove a listener for applied edits.

Unit

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

suspend SparseArray<List<PageMatchBounds>>
searchDocument(query: String, pageRange: IntRange)

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

Inherited properties

From androidx.pdf.PdfDocument
Int

The type of form present in the document.

Int

Indicates the linearization status of the document.

Int

The total number of pages in the document.

RenderParams

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

Uri

The URI of the document represented by this object

Public functions

applyEdit

Added in 1.0.0-alpha19
suspend fun applyEdit(record: FormEditInfo): Unit

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
record: FormEditInfo

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

suspend fun applyEdits(editsDraft: EditsDraft): List<String>

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

Parameters
editsDraft: EditsDraft

: edits to be applied on pdf document.

Returns
List<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
fun createWriteHandle(): PdfWriteHandle

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