> 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/viewer/view-mode.md).

# View mode

Discover how to optimize your PDF viewing experience with different layout and fit options. Learn about page presentation modes and view settings for a seamless reading experience. The Apryse Android

There are a few view modes which can be adjusted to provide an optimal presentation such as layout, fit, or reflow. Additionally, you can present a view mode dialog allowing a user to change these settings.

{% tabs %}
{% tab title="Layout" %}

## Page layout/presentation mode

[`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html) supports a number of page layouts ([presentation modes](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)), as listed below:

| Page presentation mode                                                                                                            | Description                                                                                             |
| --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [`SINGLE`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)            | Displays one page at a time, swiping left and right to change pages.                                    |
| [`SINGLE_CONT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)       | Displays one page at a time, scrolling up and down to change pages.                                     |
| [`SINGLE_VERT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)       | Displays one page at a time, swiping up and down to change pages.                                       |
| [`FACING`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)            | Displays two pages at a time, with odd-numbered pages on left, swiping left and right to change pages.  |
| [`FACING_CONT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)       | Displays pages in two columns, with odd-numbered pages on left, scrolling up and down to change pages.  |
| [`FACING_VERT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)       | Displays two pages at a time, with odd-numbered pages on left, swiping up and down to change pages.     |
| [`FACING_COVER`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html)      | Displays two pages at a time, with odd-numbered pages on right, swiping left and right to change pages. |
| [`FACING_COVER_CONT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html) | Display pages in two columns, with odd-numbered pages on right, scrolling up and down to change pages.  |
| [`FACING_COVER_VERT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PagePresentationMode.html) | Displays two pages at a time, with odd-numbered pages on right, swiping up and down to change pages.    |

## Set the page presentation mode

You can set page presentation mode in your `PDFViewCtrl` by using [`PDFViewCtrl.setPagePresentationMode(PagePresentationMode)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setPagePresentationMode\(com.pdftron.pdf.PDFViewCtrl.PagePresentationMode\)):

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

```java
mPdfViewCtrl.setPagePresentationMode(PDFViewCtrl.PagePresentationMode.FACING);
```

{% endcode %}
{% endtab %}

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

```kotlin
mPdfViewCtrl.pagePresentationMode = PDFViewCtrl.PagePresentationMode.FACING
```

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

{% tab title="Fit" %}

## Page fit & default zoom mode in Android

[`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html)'s page view mode controls the default zoom level of pages and documents. New documents will automatically open at the zoom level specified by the mode.

{% hint style="info" %}
If you configured `PDFViewCtrl` by using \[`AppUtils.setupPDFViewCtrl`]\(<https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/utils/AppUtils.html#setupPDFViewCtrl(PDFViewCtrl>, com.pdftron.pdf.config.PDFViewCtrlConfig)), the page view mode and zoom level is maintained automatically. Click [here](/android/open-save-document/open/view.md) to learn more about setting up `PDFViewCtrl`.
{% endhint %}

## Page view modes

`PDFViewCtrl` supports the following page view modes:

| Page view mode                                                                                                                  | Description                                                            | Screenshot-portrait                                                                                                                                                                                                                              | Screenshot-landscape                                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`PageViewMode.FIT_PAGE`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PageViewMode.html)   | The zoom is set so that the entire page is visible without scrolling.  | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-75dac026a54c93293e068ea0126e7b2254223347%2F3bc90440e459b1e155b0f9a9a7b9f754b42cd5a3-1226x2502.png?alt=media) | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-59ee3c57818fc825dd337857ea392d65db11b26e%2F841cc04ecb1c2ef5520ce434ba27648c5bbaa084-2502x1226.png?alt=media) |
| [`PageViewMode.FIT_WIDTH`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PageViewMode.html)  | The zoom is set so that the page's width matches the viewer's width.   | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-75dac026a54c93293e068ea0126e7b2254223347%2F3bc90440e459b1e155b0f9a9a7b9f754b42cd5a3-1226x2502.png?alt=media) | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-74b859d92340e86d05d9af23069457d040ecbea5%2F42f381b7f550ab570da82f3afa419094122b4fd6-2502x1226.png?alt=media) |
| [`PageViewMode.FIT_HEIGHT`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PageViewMode.html) | The zoom is set so that the page's height matches the viewer's height. | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-79b17d5d72e78c79c78f49f46ce25c5551cfc569%2Fb5d49d5c12472369c3a26dacaeb96562b27c6b86-1226x2502.png?alt=media) | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-59ee3c57818fc825dd337857ea392d65db11b26e%2F841cc04ecb1c2ef5520ce434ba27648c5bbaa084-2502x1226.png?alt=media) |
| [`PageViewMode.ZOOM`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.PageViewMode.html)       | The viewer's zoom is not adjusted based on the page.                   | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-572196d94e5fa9ef10e4f80437b30d02f03c79b8%2Ff75a6a20b2eff23f7081d162d834b79adc01cf57-1226x2502.png?alt=media) | ![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-0919e301109558a25e8cd471fdaaa13fafef21aa%2F0ac86387d778f0aa34b4652898261bdfa4813f8a-2502x1226.png?alt=media) |

## Set the default page fit mode

You can set a default page fit mode in your `PDFViewCtrl` by using [`setPageRefViewMode(PageViewMode)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setPageRefViewMode\(com.pdftron.pdf.PDFViewCtrl.PageViewMode\)).

## Set the page fit mode dynamically

If you want to dynamically change the page fit mode, use [`setPageViewMode(PageViewMode)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setPageViewMode\(com.pdftron.pdf.PDFViewCtrl.PageViewMode\)). Note that when the user flips the page, the page view mode will be automatically reset to the default mode set by `setPageRefViewMode`.

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

```java
mPdfViewCtrl.setPageViewMode(PDFViewCtrl.PageViewMode.FIT_WIDTH);
```

{% endcode %}
{% endtab %}

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

```kotlin
mPdfViewCtrl.pageViewMode = PDFViewCtrl.PageViewMode.FIT_WIDTH
```

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

**It is also possible to maintain the zoom level when switching pages.**

`PDFViewCtrl` allows users to zoom in and out with touch gestures. To maintain zoom level when flipping pages, call [`setMaintainZoomEnabled(boolean)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setMaintainZoomEnabled\(boolean\)). Note that when you double tap `PDFViewCtrl` will end zooming and reset the page view mode to preferred page view mode. To set preferred page view mode, call[`setPreferredViewMode(PageViewMode)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html#setPreferredViewMode\(com.pdftron.pdf.PDFViewCtrl.PageViewMode\)).

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

```java
private PDFViewCtrl mPdfViewCtrl;
// ...
private void zoomSettingSample() throws PDFNetException {
    // Enable maintain zoom level
    mPdfViewCtrl.setMaintainZoomEnabled(true);
    // Set preferred view mode to PageViewMode.FIT_PAGE
    mPdfViewCtrl.setPreferredViewMode(PDFViewCtrl.PageViewMode.FIT_PAGE);
    // Set PageViewMode.FIT_PAGE to current page view mode
    mPdfViewCtrl.setPageViewMode(PDFViewCtrl.PageViewMode.FIT_PAGE);
}
```

{% endcode %}
{% endtab %}

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

```kotlin
private var mPdfViewCtrl: PDFViewCtrl? = null
// ...
private fun zoomSettingSample() {
    // Enable maintain zoom level
    mPdfViewCtrl!!.isMaintainZoomEnabled = true
    // Set preferred view mode to PageViewMode.FIT_PAGE
    mPdfViewCtrl!!.preferredViewMode = PDFViewCtrl.PageViewMode.FIT_PAGE
    // Set PageViewMode.FIT_PAGE to current page view mode
    mPdfViewCtrl!!.pageViewMode = PDFViewCtrl.PageViewMode.FIT_PAGE
}
```

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

{% tab title="Reflow" %}

## Reflow document mode in Android

{% hint style="warning" %}
For Android, available in the full version of the library only. See [Apryse full or standard?](/xamarin/get-started/faq/full-vs-standard.md)
{% endhint %}

Reflow makes the document more flexible and easier to read, especially on small devices. Apryse is able to extract the reflowable layout of each page in a PDF document to an HTML file. First, we explain how simple it is to show a widget that allows the user to swipe left or right through the pages of the document to see reflowable document pages. Then, we provide the methods necessary for converting a hard-layout PDF page to an HTML document page.

## Show reflow pager

[`ReflowControl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/ReflowControl.html) is a [`ViewPager`](https://developer.android.com/reference/androidx/viewpager/widget/ViewPager.html) that allows the user to flip left and right through the reflowable layout of pages in a PDF document.

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

### Implementation

To set up your layout with `ReflowControl`, add a `<ReflowControl>` element to your XML layout. For example, if each page in the swipe view should consume the entire layout, then your layout looks like this:

{% code lineNumbers="true" %}

```xml
<com.pdftron.pdf.controls.ReflowControl xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/reflow_pager" android:layout_width="match_parent" android:layout_height="match_parent" />
```

{% endcode %}

Then, you need to attach a [`PDFDoc`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFDoc.html) to the reflow pager:

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

```java
ReflowControl reflowControl = (ReflowControl) findViewById(R.id.reflow_pager);
reflowControl.setup(pdfDoc);
```

{% endcode %}
{% endtab %}

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

```kotlin
val reflowControl = findViewById(R.id.reflow_pager) as ReflowControl
reflowControl.setup(pdfDoc)
```

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

### Scrolling direction

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

```java
// horizontal (default)
reflowControl.setOrientation(ReflowControl.HORIZONTAL);
// vertical
reflowControl.setOrientation(ReflowControl.VERTICAL);
```

{% endcode %}
{% endtab %}

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

```kotlin
// horizontal (default)
reflowControl.orientation = ReflowControl.HORIZONTAL;
// vertical
reflowControl.orientation = ReflowControl.VERTICAL;
```

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

That is everything you need to have a simple reflow pager. Next, we will go through advanced features.

### Post-processing color

If you want to map each original color to a new color (for example for handling night mode) you need to pass an [`OnPostProcessColorListener`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/ReflowControl.OnPostProcessColorListener.html) listener to the `ReflowControl`.

To do so, you can provide an `OnPostProcessColorListener` listener when setting up the `ReflowControl`:

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

```java
ReflowControl reflowControl = (ReflowControl) findViewById(R.id.reflow_pager);
reflowControl.setup(pdfDoc, mOnPostProcessColorListener);
```

{% endcode %}
{% endtab %}

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

```kotlin
val reflowControl = findViewById(R.id.reflow_pager) as ReflowControl
reflowControl.setup(pdfDoc, mOnPostProcessColorListener)
```

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

For example, `OnPostProcessColorListener` can be defined by `PDFViewCtrl` as:

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

```java
final ReflowControl.OnPostProcessColorListener mOnPostProcessColorListener =
    new ReflowControl.OnPostProcessColorListener() {
        @Override
        public ColorPt getPostProcessedColor(ColorPt cp) {
            if (mPDFViewCtrl != null) {
                return mPDFViewCtrl.getPostProcessedColor(cp);
            }
            return cp;
        }
    };
```

{% endcode %}
{% endtab %}

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

```kotlin
val mOnPostProcessColorListener = ReflowControl.OnPostProcessColorListener { cp ->
    if (mPDFViewCtrl != null) {
      mPDFViewCtrl.getPostProcessedColor(cp)
    } else cp
  }
```

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

Alternatively you can set a listener:

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

```java
ReflowControl reflowControl = (ReflowControl) findViewById(R.id.reflow_pager);
reflowControl.setup(pdfDoc);
reflowControl.setOnPostProcessColorListener(mOnPostProcessColorListener);
```

{% endcode %}
{% endtab %}

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

```kotlin
val reflowControl = findViewById(R.id.reflow_pager) as ReflowControl
reflowControl.setup(pdfDoc)
reflowControl.setOnPostProcessColorListener(mOnPostProcessColorListener)
```

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

### Notify the reflow pager that the document has been modified

To refresh the reflow pager to show the latest changes on your document, you should let the reflow pager know that the document has been modified:

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

```java
void notifyReflowModified(ReflowControl reflowControl) {
    if (reflowControl != null && reflowControl.isReady()) {
        reflowControl.notifyPagesModified();
    }
}
```

{% endcode %}
{% endtab %}

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

```kotlin
fun notifyReflowModified(reflowControl: ReflowControl?) {
    if (reflowControl != null && reflowControl.isReady) {
        reflowControl.notifyPagesModified()
    }
}
```

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

### Set the text size

It is possible to change the size of reflowable text. The default text size is `100`; valid values are `5`, `10`, `25`, `50`, `75`, `100`, `125`, `150`, `200`, `400`, `800`, and `1600`. See the following code as an example:

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

```java
void changeReflowSize(ReflowControl reflowControl, int percent) {
    if (reflowControl != null && reflowControl.isReady()) {
        reflowControl.setTextSizeInPercent(percent);
    }
}
```

{% endcode %}
{% endtab %}

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

```kotlin
fun changeReflowSize(reflowControl: ReflowControl?, percent: Int) {
    if (reflowControl != null && reflowControl.isReady) {
        reflowControl.textSizeInPercent = percent
    }
}
```

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

Alternatively, you can zoom in/out to change the reflowable text size:

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

```java
void zoomReflow(ReflowControl reflowControl, boolean zoomIn) {
    if (reflowControl != null && reflowControl.isReady()) {
        if (zoomIn) {
            reflowControl.zoomIn();
        } else {
            reflowControl.zoomOut();
        }
    }
}
```

{% endcode %}
{% endtab %}

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

```kotlin
fun zoomReflow(reflowControl: ReflowControl?, zoomIn: Boolean) {
    if (reflowControl != null && reflowControl.isReady) {
        if (zoomIn) {
            reflowControl.zoomIn()
        } else {
            reflowControl.zoomOut()
        }
    }
}
```

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

Assuming the current text size is 100%, by calling zoomReflow(reflowControl, true) and zoomReflow(reflowControl, false) the new text size will be 125% and 75% of the original size, respectively.

### Set background color

There are three methods to change the background color:

`setDayMode()`: no background

`setNightMode()`: night background

`setCustomColorMode(int)`: customized background

### Set right-to-left direction

You can support right-to-left (RTL) languages by setting the direction of reflowable text by calling [`setRightToLeftDirection(isRtlMode)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/ReflowControl.html#setRightToLeftDirection\(boolean\))

## Generate a reflow page

It is not necessary to use a reflow pager to create a reflowable layout of PDF pages. It is also possible to extract the reflowable layout by creating an HTML file from a specific page of the document using the [`ReflowProcessor`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/ReflowProcessor.html) class. The first step is to let the Core know you are going to use reflow by calling [`initialize()`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/ReflowProcessor.html#initialize\(\)). Please note that this method clears all existing reflowable data. Thus, preferably put this call in your Application or Activity.

When reflow processor has been initialized, it is possible to turn reflow on by calling \[`getReflow(Page, RequestHandler, Object)`]\(<https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/ReflowProcessor.html#getReflow(com.pdftron.pdf.Page>, com.pdftron.pdf.RequestHandler, java.lang.Object)) and passing a [`RequestHandler`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/RequestHandler.html) callback in order to be notified once the reflowable HTML file is ready::

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

```java
void getReflowPage(PDFViewCtrl pdfViewCtrl, final int pageNum) throws Exception {
    final PDFDoc doc = pdfViewCtrl.getDoc();
    pdfViewCtrl.docLockRead(new PDFViewCtrl.LockRunnable() {
        @Override
        public void run() throws Exception {
            Page page = doc.getPage(pageNum);
            ReflowProcessor.getReflow(page, mRequestHandler, pageNum);
        }
    });
}
RequestHandler mRequestHandler = new RequestHandler(new RequestHandler.RequestHandlerCallback() {
    @Override
    public void RequestHandlerProc(RequestHandler.JobRequestResult result, String outFilename, Object customData) {
        if (result == RequestHandler.JobRequestResult.FINISHED) {
            // int pageNum = (int) customData;
            // A reflowable HTML file with a page number of pageNum is located at outFilename
        }
    }
});
```

{% endcode %}
{% endtab %}

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

```kotlin
fun getReflowPage(pdfViewCtrl: PDFViewCtrl, pageNum: Int) {
    val doc = pdfViewCtrl.doc
    pdfViewCtrl.docLockRead {
        val page = doc.getPage(pageNum)
        ReflowProcessor.getReflow(page, mRequestHandler, pageNum)
    }
}
var mRequestHandler = RequestHandler(RequestHandlerCallback { result, outFilename, customData ->
    if (result == JobRequestResult.FINISHED) { // int pageNum = (int) customData;
        // A reflowable HTML file with a page number of pageNum is located at outFilename
    }
})
```

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

To cancel all reflow requests, call [`cancelAllRequests()`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/ReflowProcessor.html#cancelAllRequests\(\)).

Finally, if you want to clear all HTML files created in the cache, you may need to call [`clearCache()`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/ReflowProcessor.html#clearCache\(\)).
{% endtab %}

{% tab title="Dialog" %}

## View mode dialog

[`ViewModePickerDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/ViewModePickerDialogFragment.html) allows users to: [pick page layout mode](/android/viewer/view-mode.md), [select page color mode](/android/viewer/themes.md), [rotate pages](/android/page-manipulation/rotate.md), and [crop pages](/android/open-save-document/basics/crop-pages.md).

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-7b175a1e703e24bfaff14fd21ae65dfa59f8c494%2F5fc71d5279a47e45b78afc52cb32a2297b109b90-1080x2220.png?alt=media)

## Show view mode dialog

To show a view mode dialog in your activity, create a new instance of [`ViewModePickerDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/ViewModePickerDialogFragment.html) by calling `newInstance(PagePresentationMode, boolean, boolean, int)`:

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

```java
private PDFViewCtrl mPdfViewCtrl;
// ...
public void showViewModeDialog(FragmentManager fragmentManager) {
  ViewModePickerDialogFragment dialog = ViewModePickerDialogFragment.newInstance(mPdfViewCtrl.getPagePresentationMode(), false, false, 0);
  // Set a custom style for this dialog
  dialog.setStyle(DialogFragment.STYLE_NORMAL, com.pdftron.pdf.tools.R.style.PDFTronAppTheme);
  // Show the dialog
  dialog.show(fragmentManager, "view_mode_picker");
}
```

{% endcode %}
{% endtab %}

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

```kotlin
private var mPdfViewCtrl: PDFViewCtrl? = null
// ...
fun showViewModeDialog(fragmentManager: FragmentManager) {
  val dialog = ViewModePickerDialogFragment.newInstance(mPdfViewCtrl?.pagePresentationMode, false, false, 0)
  // Set a custom style for this dialog
  dialog.setStyle(DialogFragment.STYLE_NORMAL, com.pdftron.pdf.tools.R.style.PDFTronAppTheme)
  // Show the dialog
  dialog.show(fragmentManager, "view_mode_picker")
}
```

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

## Set view mode dialog listener

In order to let users pick PDF page presentation mode, color mode, etc. you need to set a [`ViewModePickerDialogFragmentListener`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener.html) by calling [`setViewModePickerDialogFragmentListener`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/ViewModePickerDialogFragment.html#setViewModePickerDialogFragmentListener\(com.pdftron.pdf.dialog.ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener\)). Implement each method in the listener to change page presentation mode, color mode, reflow, etc.

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

```java
dialog.setViewModePickerDialogFragmentListener(new ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener() {
   /**
    * Called when a view mode has been selected.
    *
    * @param viewMode The selected view mode
    */
    @Override
    public void onViewModeSelected(String viewMode) {
        // Implement functionality for each view mode selected
        // ...
    }

    /**
      * Called when a color mode has been selected.
      *
      * @param colorMode The color mode
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onViewModeColorSelected(int colorMode) {
        return false;
    }

    /**
      * Called when a custom color mode is selected
      *
      * @param bgColor  The selected background color
      * @param txtColor The selected text color
      * @return True if the dialog should be dismissed
      */
    @Override
    public boolean onCustomColorModeSelected(int bgColor, int txtColor) {
        return false;
    }

    /**
      * Called when the dialog has been dismissed.
      */
    @Override
    public void onViewModePickerDialogFragmentDismiss() {
        // Do something when the dialog is dismissed
    }

    /**
      * The implementation should zoom in/out reflow
      *
      * @param flagZoomIn True if zoom in; False if zoom out
      * @return The text size raging from 0 to 100
      */
    @Override
    public int onReflowZoomInOut(boolean flagZoomIn) {
        return 0;
    }

    /**
      * The implementation should check tab conversion and shows the alert if needed.
      *
      * @param messageID      The message ID
      * @param allowConverted True if conversion is allowed
      * @return True if handled
      */
    @Override
    public boolean checkTabConversionAndAlert(int messageID, boolean allowConverted) {
        return false;
    }
});
```

{% endcode %}
{% endtab %}

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

```kotlin
dialog.setViewModePickerDialogFragmentListener(object : ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener {
  /**
    * Called when a view mode has been selected.
    *
    * @param viewMode The selected view mode
    */
  override fun onViewModeSelected(viewMode: String) {
    // Implement functionality for each view mode selected
    // ...
  }

  /**
    * Called when a color mode has been selected.
    *
    * @param colorMode The color mode
    * @return True if the dialog should be dismissed
    */
  override fun onViewModeColorSelected(colorMode: Int): Boolean {
    return false
  }

  /**
    * Called when a custom color mode is selected
    *
    * @param bgColor The selected background color
    * @param txtColor The selected text color
    * @return True if the dialog should be dismissed
    */
  override fun onCustomColorModeSelected(bgColor: Int, txtColor: Int): Boolean {
    return false
  }

  /**
    * Called when the dialog has been dismissed.
    */
  override fun onViewModePickerDialogFragmentDismiss() {
    // Do something when the dialog is dismissed
  }

  /**
    * The implementation should zoom in/out reflow
    *
    * @param flagZoomIn True if zoom in; False if zoom out
    * @return The text size raging from 0 to 100
    */
  override fun onReflowZoomInOut(flagZoomIn: Boolean): Int {
    return 0
  }

  /**
    * The implementation should check tab conversion and shows the alert if needed.
    *
    * @param messageID The message ID
    * @param allowConverted True if conversion is allowed
    * @return True if handled
    */
  override fun checkTabConversionAndAlert(messageID: Int, allowConverted: Boolean): Boolean {
    return false
  }
})
```

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

In [`onViewModeSelected(String)`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/dialog/ViewModePickerDialogFragment.ViewModePickerDialogFragmentListener.html#onViewModeSelected\(java.lang.String\)), the selected view mode values are defined in `PdfViewCtrlSettingsManager` and include the following:

| **View Mode**                              | **Description**                                                                             | **Value**           |
| ------------------------------------------ | ------------------------------------------------------------------------------------------- | ------------------- |
| `KEY_PREF_VIEWMODE_CONTINUOUS_VALUE`       | Single page in continuous mode is selected.                                                 | "continuous"        |
| `KEY_PREF_VIEWMODE_SINGLEPAGE_VALUE`       | Single page presentation mode is selected.                                                  | "singlepage"        |
| `KEY_PREF_VIEWMODE_FACING_VALUE`           | Facing two pages presentation mode is selected.                                             | "facing"            |
| `KEY_PREF_VIEWMODE_FACINGCOVER_VALUE`      | Facing two pages with odd page number on right side of PDF is selected.                     | "facingcover"       |
| `KEY_PREF_VIEWMODE_FACING_CONT_VALUE`      | In continuous mode, Facing two pages presentation mode is selected.                         | "facing\_cont"      |
| `KEY_PREF_VIEWMODE_FACINGCOVER_CONT_VALUE` | In continuous mode, Facing two pages with odd page number on right side of PDF is selected. | "facingcover\_cont" |
| `KEY_PREF_VIEWMODE_ROTATION_VALUE`         | Rotate pdf pages is selected.                                                               | "rotation"          |
| `KEY_PREF_VIEWMODE_USERCROP_VALUE`         | User-level crop pages is selected.                                                          | "user\_crop"        |

To learn about setting page presentation mode, see [PDFViewCtrl page presentation mode ](/android/viewer/view-mode.md).

{% hint style="info" %}
To learn about setting page color mode, see [PDFViewCtrl color modes ](/android/viewer/themes.md).
{% endhint %}

{% hint style="info" %}
To learn about reflow, see [reflow ](#reflow).
{% endhint %}

{% hint style="info" %}
To learn about cropping pages, see [crop page dialog ](/android/open-save-document/basics/crop-pages.md).
{% endhint %}
{% 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/viewer/view-mode.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.
