# EditablePdfDocument

Artifact: [androidx.pdf:pdf-core](https://developer.android.com/jetpack/androidx/releases/pdf) [View Source](https://cs.android.com/search?q=file:androidx/pdf/EditablePdfDocument.kt+class:androidx.pdf.EditablePdfDocument) Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

*** ** * ** ***


```
public interface EditablePdfDocument extends PdfDocument
```

<br />

*** ** * ** ***

Represents a PDF document that allows for editing.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdit(androidx.pdf.models.FormEditInfo)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/models/FormEditInfo record)` Applies the changes specified by `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdit(androidx.pdf.models.FormEditInfo)` to the form. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | `@https://developer.android.com/reference/androidx/pdf/ExperimentalPdfApi https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdits(androidx.pdf.EditsDraft)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/EditsDraft editsDraft)` Applies a list of edits to the document sequentially in the order they are provided in the `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdits(androidx.pdf.EditsDraft)`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfWriteHandle` | `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#createWriteHandle()()` Creates a `https://developer.android.com/reference/androidx/pdf/PdfWriteHandle` which can be used to save the document to a `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`. |

### Inherited methods

From [java.io.Closeable](https://developer.android.com/reference/java/io/Closeable.html) `abstract void` `https://developer.android.com/reference/java/io/Closeable.html#close()()` From [androidx.pdf.PdfDocument](https://developer.android.com/reference/androidx/pdf/PdfDocument) `default void` `@https://developer.android.com/reference/androidx/pdf/ExperimentalPdfApi
https://developer.android.com/reference/androidx/pdf/PdfDocument#addOnEditAppliedListener(java.util.concurrent.Executor,androidx.pdf.PdfDocument.OnEditAppliedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.OnEditAppliedListener listener
)`

Adds a listener to be notified when an edit is applied on the document.
`abstract void` `https://developer.android.com/reference/androidx/pdf/PdfDocument#addOnPdfContentInvalidatedListener(java.util.concurrent.Executor,androidx.pdf.PdfDocument.OnPdfContentInvalidatedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.OnPdfContentInvalidatedListener listener
)`

Adds a listener to receive notifications when some regions of the PDF content are invalidated.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/annotation/content/KeyedPdfAnnotation>` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getAnnotationsForPage(kotlin.Int)(int pageNum)`

Retrieves a list of all annotations for the specified page.
`abstract int` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getFormType()()`

The type of form present in the document.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/models/FormWidgetInfo>` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getFormWidgetInfos(kotlin.Int,kotlin.Long)(int pageNum, long types)`

Returns the list of `https://developer.android.com/reference/androidx/pdf/models/FormWidgetInfo` on `https://developer.android.com/reference/androidx/pdf/PdfDocument#getFormWidgetInfos(kotlin.Int,kotlin.Long)`, optionally filtered by widget type.
`abstract int` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getLinearizationStatus()()`

Indicates the linearization status of the document.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.BitmapSource` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageBitmapSource(kotlin.Int)(int pageNumber)`

Gets a `https://developer.android.com/reference/androidx/pdf/PdfDocument.BitmapSource` for retrieving bitmap representations of the specified page.
`abstract https://developer.android.com/reference/androidx/pdf/PdfDocument.PdfPageContent` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageContent(kotlin.Int)(int pageNumber)`

Asynchronously retrieves the content (text and images) of the specified page.
`abstract int` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageCount()()`

The total number of pages in the document.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.PageInfo` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageInfo(kotlin.Int)(int pageNumber)`

Asynchronously retrieves information about the specified page.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.PageInfo` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageInfo(kotlin.Int,kotlin.Long)(int pageNumber, long pageInfoFlags)`

Asynchronously retrieves information about the specified page.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.PageInfo>` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageInfos(kotlin.ranges.IntRange)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html pageRange)`

Asynchronously retrieves information about a range of pages.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.PageInfo>` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageInfos(kotlin.ranges.IntRange,kotlin.Long)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html pageRange, long pageInfoFlags)`

Asynchronously retrieves information about a range of pages.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.PdfPageLinks` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getPageLinks(kotlin.Int)(int pageNumber)`

Asynchronously retrieves the links (Go To and external) present on the specified page.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/RenderParams` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getRenderParams()()`

The render params used to determine the contents that will be rendered on the bitmap.
`abstract https://developer.android.com/reference/androidx/pdf/content/PageSelection` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getSelectionBounds(kotlin.Int,android.graphics.PointF,android.graphics.PointF)(
int pageNumber,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html start,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/PointF.html stop
)`

Asynchronously retrieves the selection bounds (in PDF coordinates) for the specified text selection.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html` `https://developer.android.com/reference/androidx/pdf/PdfDocument#getUri()()`

The URI of the document represented by this object
`default void` `@https://developer.android.com/reference/androidx/pdf/ExperimentalPdfApi
https://developer.android.com/reference/androidx/pdf/PdfDocument#removeOnEditAppliedListener(androidx.pdf.PdfDocument.OnEditAppliedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.OnEditAppliedListener listener
)`

Remove a listener for applied edits.
`abstract void` `https://developer.android.com/reference/androidx/pdf/PdfDocument#removeOnPdfContentInvalidatedListener(androidx.pdf.PdfDocument.OnPdfContentInvalidatedListener)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/PdfDocument.OnPdfContentInvalidatedListener listener
)`

Removes the listener from the list of listeners which are notified when some regions of the PDF content are invalidated.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/util/SparseArray.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/content/PageMatchBounds>>` `https://developer.android.com/reference/androidx/pdf/PdfDocument#searchDocument(kotlin.String,kotlin.ranges.IntRange)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html query, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-int-range/index.html pageRange)`

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

## Public methods

### applyEdit

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
abstract void applyEdit(@NonNull FormEditInfo record)
```

Applies the changes specified by `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdit(androidx.pdf.models.FormEditInfo)` to the form.

Any areas which are invalidated due to this operation are notified via `https://developer.android.com/reference/androidx/pdf/PdfDocument.OnPdfContentInvalidatedListener` callback.

It is recommended to maintain a list of `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/models/FormEditInfo record` | The `https://developer.android.com/reference/androidx/pdf/models/FormEditInfo` to apply to the form. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the provided `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdit(androidx.pdf.models.FormEditInfo)` cannot be applied to the widget indicated by the index, or if the index does not correspond to a widget on the page. |

### applyEdits

```
@ExperimentalPdfApi
abstract @NonNull List<@NonNull String> applyEdits(@NonNull EditsDraft editsDraft)
```

Applies a list of edits to the document sequentially in the order they are provided in the `https://developer.android.com/reference/androidx/pdf/EditablePdfDocument#applyEdits(androidx.pdf.EditsDraft)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/pdf/EditsDraft editsDraft` | : edits to be applied on pdf document. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | List of unique edit IDs (such as annotation IDs) corresponding to each operation in the order they were enqueued. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/pdf/PdfEditApplyException` | if any of the edit failed to be applied. |

### createWriteHandle

Added in [1.0.0-beta01](https://developer.android.com/jetpack/androidx/releases/pdf#1.0.0-beta01)

```
abstract @NonNull PdfWriteHandle createWriteHandle()
```

Creates a `https://developer.android.com/reference/androidx/pdf/PdfWriteHandle` which can be used to save the document to a `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`.