---
title: "Rotate PDF Android library | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/editor/page-manipulation/rotate/"
md_url: "https://www.nutrient.io/guides/android/editor/page-manipulation/rotate.md"
last_updated: "2026-06-09T10:25:14.336Z"
description: "Nutrient Android SDK lets you rotate the pages of a document using the Processor API or the Document Editor API."
---

# Rotating PDF pages on Android

Nutrient Android SDK lets you rotate the pages of a document using the Processor API or the Document Editor API.

## Using the Processor API

To rotate pages via the [`PdfProcessor`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor/index.html) API, load your document and then configure the parameters for page rotation on a [`PdfProcessorTask`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document.processor/-pdf-processor-task/index.html) instance. The Processor API is a great choice if you want to build an automated document processing operation:

### KOTLIN

```kotlin

// Create a `PdfProcessorTask` in which to store the operation.
val task = PdfProcessorTask.empty()
// Rotate the first page 90 degrees.
task.rotatePage(0, PdfDocument.ROTATE_90)

// Process to an output document.
val outputFile = File(context.filesDir, "outputDocument.pdf")
PdfProcessor.processDocument(task, outputFile)

```

### JAVA

```java

// Create a `PdfProcessorTask` in which to store the operation.
final PdfProcessorTask task = PdfProcessorTask.empty();
// Rotate the first page 90 degrees.
task.rotatePage(0, PdfDocument.ROTATE_90);

// Process to an output document.
final File outputFile = new File(context.getFilesDir(), "outputDocument.pdf");
PdfProcessor.processDocument(task, outputFile)

```

## Using the Document Editor API

Page removal is also available as part of the Document Editor API. The Document Editor API 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.

Here’s how you can use the Document Editor API to rotate the current page of a displayed document to 90 degrees:

### KOTLIN

```kotlin

// Instance method on a `PdfActivity` subclass.
fun rotatePages() {
    // Use the `PdfDocumentEditorFactory` to create a `PdfDocumentEditor`.
    val documentEditor = PdfDocumentEditorFactory.createForDocument(document)

    // Set up the output file location.
    val outputFile = File(filesDir, "outputDocument.pdf")

    // Rotate the current page.
    val pagesToRotate = setOf(pageIndex)

    // Make sure `disposable` is managed by the activity and destroyed correctly
    // when the activity is destroyed.
    val disposable: Disposable = documentEditor.rotatePages(pagesToRotate, PdfDocument.ROTATE_90).flatMapCompletable { documentEditor.saveDocument(context, outputFile.outputStream(), null) }
        // Use `subscribeOn` to put `saveDocument` on a background thread, as it can be slow..subscribeOn(Schedulers.io())
        // Make sure the resulting document rendering goes back on the main thread..observeOn(AndroidSchedulers.mainThread())
        // You can display the saved document in a new activity with the following action on `subscribe`..subscribe { showDocument(context, Uri.fromFile(outputFile), null) }
}

```

### JAVA

```java

// Instance method on a `PdfActivity` subclass.
public void rotatePages() {
    // Use the `PdfDocumentEditorFactory` to create a `PdfDocumentEditor`.
    final PdfDocumentEditor documentEditor =
        PdfDocumentEditorFactory.createForDocument(document);

    // Set up the output file location.
    final File outputFile = new File(getFilesDir(), "outputDocument.pdf");

    // Rotate the current page.
    final HashSet<Integer> pagesToRotate = new HashSet<>(Arrays.asList(getPageIndex()));

    // Make sure `disposable` is managed by the activity and destroyed correctly
    // when the activity is destroyed.
    final Disposable disposable = documentEditor.rotatePages(pagesToRotate, PdfDocument.ROTATE_90).flatMapCompletable(saved -> documentEditor.saveDocument(context, new FileOutputStream(outputFile), null))
        // Use `subscribeOn` to put `saveDocument` on a background thread, as it can be slow..subscribeOn(Schedulers.io())
        // Make sure the resulting document rendering goes back on the main thread..observeOn(AndroidSchedulers.mainThread())
        // You can display the saved document in a new activity with the following action on `subscribe`..subscribe( () -> { PdfActivity.showDocument(context,
            Uri.fromFile(outputFile), null);
        });
}

```

## Using the built-in UI

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

## Related pages

- [Cropping PDF pages on Android](/guides/android/editor/page-manipulation/crop.md)
- [Scale or resize PDFs on Android](/guides/android/editor/page-manipulation/scale-or-resize.md)
- [Move or copy PDF pages on Android](/guides/android/editor/page-manipulation/move-or-copy.md)
- [Removing pages from a PDF on Android](/guides/android/editor/page-manipulation/remove.md)

