---
title: "How to delete pages from a PDF document"
canonical_url: "https://www.nutrient.io/guides/android/knowledge-base/deleting-pages-from-a-pdf/"
md_url: "https://www.nutrient.io/guides/android/knowledge-base/deleting-pages-from-a-pdf.md"
last_updated: "2026-06-09T10:32:17.001Z"
description: "You can delete pages of a PDF document using the PdfProcessor in three steps: for Nutrient Android SDK."
---

You can delete pages of a PDF document using the `PdfProcessor` in three steps:

1. Load the `PdfDocument` you want to modify.

2. Create a `PdfProcessorTask` that removes the desired pages.

3. Process the document, saving it to a new location.

Here’s how to do this in your `PdfActivity`:

### KOTLIN

```kotlin

override fun onDocumentLoaded(document: PdfDocument) {
    // Remove the pages with index 0 and 4.
    val task = PdfProcessorTask.fromDocument(document).removePages(setOf(0, 4))

    // The output file must be different than the original document file.
    val outputFile = filesDir.resolve("${document.uid}-processed.pdf")

    // Process the document on a background thread. The newly created
    // document will have the pages removed.
    PdfProcessor.processDocumentAsync(task, outputFile).ignoreElements().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe { Log.i(TAG, "Document successfully saved.") }
}

```

### JAVA

```java

@Override
public void onDocumentLoaded(@NonNull PdfDocument document) {
    // Remove the pages with index 0 and 4.
    final PdfProcessorTask task = PdfProcessorTask.fromDocument(document).removePages(new HashSet<>(Arrays.asList(0, 4)));

    // The output file must be different than the original document file.
    final File outputFile =
        new File(getFilesDir(), document.getUid() + "-processed.pdf");

    // Process the document on a background thread. The newly created
    // document will have the pages removed.
    PdfProcessor.processDocumentAsync(task, outputFile).ignoreElements().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(() -> Log.i("TAG", "Document successfully saved."));
}

```

When saving the processed document to an `outputFile`, the output file must be different than the input file. Writing back directly to the original document isn’t supported.

---

## Related pages

- [Allow Clear Text Traffic](/guides/android/knowledge-base/allow-clear-text-traffic.md)
- [Compose Qna](/guides/android/knowledge-base/compose-qna.md)
- [Custom Print Functionality](/guides/android/knowledge-base/custom-print-functionality.md)
- [Easily disable share and print options in Android](/guides/android/knowledge-base/disable-share-documentinfo-print.md)
- [Disabling Annotation Rotation](/guides/android/knowledge-base/disabling-annotation-rotation.md)
- [Change page layout dynamically based on orientation](/guides/android/knowledge-base/dynamic-page-layout-when-changing-orientation.md)
- [Managing touch scrolling in Compose containers](/guides/android/knowledge-base/document-view-inside-pager-scroll-handling.md)
- [Getting Signature Location](/guides/android/knowledge-base/getting-signature-location.md)
- [Install Failed Insufficient Storage](/guides/android/knowledge-base/install-failed-insufficient-storage.md)
- [Intercepting Touch Events](/guides/android/knowledge-base/intercepting-touch-events.md)
- [Getting All Digital Signatures](/guides/android/knowledge-base/getting-all-digital-signatures.md)
- [Invoke Search Programmatically](/guides/android/knowledge-base/invoke-search-programmatically.md)
- [Creating invisible digital signatures in Android](/guides/android/knowledge-base/invisible-signature.md)
- [Invoking Share Action Programmatically](/guides/android/knowledge-base/invoking-share-action-programmatically.md)
- [Override Hyperlink Behavior](/guides/android/knowledge-base/override-hyperlink-behavior.md)
- [Making Form Elements Read Only](/guides/android/knowledge-base/making-form-elements-read-only.md)
- [Remove Tool Variant From Toolbar](/guides/android/knowledge-base/remove-tool-variant-from-toolbar.md)
- [Runtime Permissions Cordova](/guides/android/knowledge-base/runtime-permissions-cordova.md)
- [Save signed PDFs directly to a remote server on Android](/guides/android/knowledge-base/save-signed-pdfs-to-remote-server.md)
- [Customize the overflow button color in Android](/guides/android/knowledge-base/styling-overflow-button.md)
- [Using Pspdfkit With Dynamic Feature Modules](/guides/android/knowledge-base/using-pspdfkit-with-dynamic-feature-modules.md)

