---
title: "Split PDF Android library | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/editor/split/"
md_url: "https://www.nutrient.io/guides/android/editor/split.md"
last_updated: "2026-06-09T10:32:42.684Z"
description: "Nutrient Android SDK lets you split a document into multiple documents using the Processor API or the Document Editor API."
---

# Split PDFs on Android

Nutrient Android SDK lets you split a document into multiple documents using the Processor API or the Document Editor API. You can create documents consisting of any combination of pages from the original document.

## Splitting documents with PDF Processor

Nutrient’s [`PdfProcessor`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor/index.html) API enables you to split a PDF document into multiple documents.

[`PdfProcessor`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor/index.html) combined with a [`PdfProcessorTask`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor-task/index.html) can extract ranges of pages from one document and put them into another document. If you run this operation multiple times with different page indexes, you can effectively split a PDF into as many documents as you require.

In most cases, you’ll want to use [`PdfProcessor`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor/index.html) to create PDF documents on disk based on a current [`PdfDocument`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/index.html). This example code will split a single PDF document into two using the provided page indexes:

### KOTLIN

```kotlin

val originalDocument: PdfDocument =...

// First, define the pages you want to split out of the original document.
val pagesToSplit: HashSet<Int> = HashSet(listOf(2, 3))

// Next, create a `PdfProcessor` task to perform the new document operation.
// Start with an empty document for the split pages.
val newDocumentTask = PdfProcessorTask.empty()
var index = 0
for (i in pagesToSplit) {
    if (i < originalDocument.pageCount) {
        newDocumentTask.addNewPage(NewPage.fromPage(originalDocument, i).build(), index++)
    }
}

// Create a new task to remove the pages from the original document.
val originalDocumentTask = PdfProcessorTask.fromDocument(originalDocument).removePages(pagesToSplit)

// Finally, define some files in which to save the split documents.
val fileA = File(context.getFilesDir(), "A.pdf")
val fileB = File(context.getFilesDir(), "B.pdf")
PdfProcessor.processDocument(originalDocumentTask, fileA)
PdfProcessor.processDocument(newDocumentTask, fileB)

```

### JAVA

```java

PdfDocument originalDocument =...

// First, define the pages you want to split out of the original document.
HashSet<Integer> pagesToSplit = new HashSet(Arrays.asList(2, 3));

// Next, create a `PdfProcessor` task to perform the new document operation.
// Start with an empty document for the split pages.
PdfProcessorTask newDocumentTask = PdfProcessorTask.empty();
int index = 0;
for (int i : pagesToSplit) {
    if (i < originalDocument.getPageCount()) {
        newDocumentTask.addNewPage(NewPage.fromPage(originalDocument, i).build(),
            index++);
    }
}

// Create a new task to remove the pages from the original document.
PdfProcessorTask originalDocumentTask =
    PdfProcessorTask.fromDocument(originalDocument).removePages(pagesToSplit);

// Finally, define some files in which to save the split documents.
File fileA = new File(context.getFilesDir(), "A.pdf");
File fileB = new File(context.getFilesDir(), "B.pdf");
PdfProcessor.processDocument(originalDocumentTask, fileA);
PdfProcessor.processDocument(newDocumentTask, fileB);

```

## Splitting documents with Document Editor

Splitting pages is also available as part of the Document Editor API. The Document Editor is particularly useful if you want to build a general-purpose UI for manipulating pages, as it provides helpers that make building a document editing UI easy.

The document editing operations work with [ReactiveX](http://reactivex.io) objects, returning [`io.reactivex.Single`](http://reactivex.io/RxJava/javadoc/io/reactivex/Single.html) observable instances containing a list of [`EditingChange`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.undo/-editing-change/index.html)s:

### KOTLIN

```kotlin

val document: PdfDocument =...

// Create some files in which to save the split documents.
val outputFileA = File(filesDir, "A.pdf")
val outputFileB = File(filesDir, "B.pdf")
val outputA = FileOutputStream(outputFileA)
val outputB = FileOutputStream(outputFileB)

// Define the pages to split.
val pagesToSplit = HashSet(Arrays.asList(2, 3))

// Create a Document Editor.
val documentEditor = PdfDocumentEditorFactory.createForDocument(document)

// Use `exportPages` to export the pages to a new file.
val disposableA: Disposable = documentEditor.exportPages(context, outputA, pagesToSplit, null).subscribe()

// Use `removePages` to remove the exported pages from the original document,
// and save the result to a new file.
val disposableB: Disposable = documentEditor.removePages(pagesToSplit).flatMapCompletable { documentEditor.saveDocument(context, outputB, null) }.subscribe()

```

### JAVA

```java

PdfDocument document =...

// Create some files in which to save the split documents.
final File outputFileA = new File(getFilesDir(), "A.pdf");
final File outputFileB = new File(getFilesDir(), "B.pdf");
FileOutputStream outputA = new FileOutputStream(outputFileA);
FileOutputStream outputB = new FileOutputStream(outputFileB);

// Define the pages to split.
HashSet<Integer> pagesToSplit = new HashSet(Arrays.asList(2, 3));

// Create a Document Editor.
final PdfDocumentEditor documentEditor =
    PdfDocumentEditorFactory.createForDocument(document);

// Use `exportPages` to export the pages to a new file.
final Disposable disposableA = documentEditor.exportPages(context, outputA,
    pagesToSplit, null).subscribe();

// Use `removePages` to remove the exported pages from the original document,
// and save the result to a new file.
final Disposable disposableB = documentEditor.removePages(pagesToSplit).flatMapCompletable(saved -> documentEditor.saveDocument(context, outputB, null)).subscribe();

```

## Using the built-in UI

Nutrient Android SDK comes with a prebuilt user interface for document editing that includes an option to export and remove pages. To learn more, check out the [Document Editor UI](https://www.nutrient.io/guides/android/features/document-editor.md) overview.
---

## Related pages

- [Add and insert images into PDFs on Android](/guides/android/editor/add-image.md)
- [Add pages to PDF files on Android](/guides/android/editor/add-page.md)
- [Attach files to PDFs on Android](/guides/android/features/embedded-files.md)
- [Customizing PDF editing permissions on Android](/guides/android/editor/document-permissions.md)
- [Edit text in PDFs on Android](/guides/android/editor/edit-text.md)
- [Merge multiple PDF files on Android](/guides/android/editor/merge-or-combine.md)
- [PDF editor library for Android](/guides/android/features/document-processing.md)

