> 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/web/get-started/samples/readermodetest.md).

# Reader Mode Sample Code

JavaScript sample that lets you open documents in reader mode for easier reading.

{% hint style="info" %}
**Requirements**

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="/web/get-started/readme.md" class="button primary">Web SDK</a><a href="/web/full-api/full-api-overview.md" class="button primary">Full API</a>
{% endhint %}

This JavaScript sample lets you open documents in reader mode to make them easier to read. This sample works on all browsers (including IE11) and mobile devices without using plug-ins.

Learn more about our [Web SDK](/web/get-started/guides.md).

### **Implementation steps**

Step 1: [Get started with WebViewer](/web/get-started/readme.md) in your preferred web stack

Step 2: [Enable the full API](/web/full-api/full-api-overview.md)

Step 3: Add the sample code provided in this guide

This full sample is one of many included in the [manual download of WebViewer.](/web/get-started/manually.md#1-download-webviewer)

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

```js
(() => {
  window.addEventListener('viewerLoaded', () => {
    const instance = window.instance;
    const parentDocument = window.parent.document;

    instance.UI.enableElements(['readerPageTransitionButton']);

    parentDocument.getElementById('select').onchange = e => {
      instance.UI.loadDocument(e.target.value);
    };

    parentDocument.getElementById('file-picker').onchange = e => {
      const file = e.target.files[0];
      if (file) {
        instance.UI.loadDocument(file);
      }
    };

    parentDocument.getElementById('url-form').onsubmit = e => {
      e.preventDefault();
      instance.UI.loadDocument(parentDocument.getElementById('url').value);
    };

    instance.Core.documentViewer.addEventListener(
      'documentLoaded',
      () => {
        instance.UI.setZoomLevel(1);
        instance.UI.toggleReaderMode();
      },
      { once: true }
    );
  });
})();
// eslint-disable-next-line spaced-comment
//# sourceURL=config.js
```

{% endcode %}
{% 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/web/get-started/samples/readermodetest.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.
