> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/page-manipulation/rotate.md).

# Rotate a page

Learn how to rotate pages in Android PDF documents using UI components or programmatically with this comprehensive API guide. Rotate pages easily at 90, 180, and 270 degrees. The Apryse Android SDK st

There are two options to rotate a page. First is using a UI component that can rotate at 90 degree angles. Second is an API guide to programmatically rotate a page.

{% tabs %}
{% tab title="UI component" %}

## Rotate document pages in Android

The [`RotateDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/RotateDialogFragment.html) allows users to rotate pages of the opened document by 90, 180 and 270 degrees. It also displays a thumbnail of the current page at the selected rotation angle.

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-d0718c252eae7f467bdd6787e08ad2bba244c288%2F27bb7a99be917df7c058cc3ff91c5663c2d7b581-600x1200.gif?alt=media)

## Show rotate page dialog

To show a rotate pages dialog in your activity, create a new instance of [`RotateDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/RotateDialogFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html):

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
private PDFViewCtrl mPdfViewCtrl;
// ...
public void showRotateDialog(FragmentManager fragmentManager) {
    RotateDialogFragment.newInstance()
                        .setPdfViewCtrl(mPdfViewCtrl)
                        .show(fragmentManager, "rotate_pages_dialog");
}
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
private var mPdfViewCtrl: PDFViewCtrl? = null
// ...
fun showRotateDialog(fragmentManager: FragmentManager) {
    RotateDialogFragment.newInstance()
                        .setPdfViewCtrl(mPdfViewCtrl)
                        .show(fragmentManager, "rotate_pages_dialog")
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="API guide" %}

## API to programmatically rotate pages in Android

To rotate a page in a PDF document.

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);

// Rotate the first page 90 degrees clockwise.
Page page = doc.getPage(1);
int originalRotation = page.getRotation();
int rotation;
switch (originalRotation)
{
  case Page.e_0:   rotation = Page.e_90;  break;
  case Page.e_90:  rotation = Page.e_180; break;
  case Page.e_180: rotation = Page.e_270; break;
  case Page.e_270: rotation = Page.e_0;   break;
  default:         rotation = Page.e_0;   break;
}
page.setRotation(rotation);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)

// Rotate the first page 90 degrees clockwise.
val page = doc.getPage(1)
val originalRotation = page.getRotation()
val rotation = when (originalRotation)
{
  Page.e_0    -> Page.e_90
  Page.e_90   -> Page.e_180
  Page.e_180  -> Page.e_270
  Page.e_270  -> Page.e_0
  else        -> Page.e_0
}
page.setRotation(rotation)
```

{% endcode %}
{% endtab %}
{% endtabs %}

## About rotating pages

A page can be rotated clockwise, by 90 degrees, when displayed or printed. The `Page.GetRotation()` method returns the `Page.Rotate` enum specifying the current rotation. Similarly, `Page.SetRotation()` sets the current rotation.
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/page-manipulation/rotate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
