---
title: "Turn features on and off — Vanilla JS"
description: "Say what people can do in this viewer, move one button, make the viewer read-only, and say what a user may do, with the right tool for each."
integration: "Vanilla JS"
other_integrations:
  "React": "https://www.embedpdf.com/docs/viewer/react/features/turning-off.md"
  "Vue": "https://www.embedpdf.com/docs/viewer/vue/features/turning-off.md"
  "Svelte": "https://www.embedpdf.com/docs/viewer/svelte/features/turning-off.md"
  "Angular": "https://www.embedpdf.com/docs/viewer/angular/features/turning-off.md"
source: "https://www.embedpdf.com/docs/viewer/vanilla/features/turning-off"
---

# Turn features on and off

Say what people can do in this viewer with `features`. A feature you name is on or off everywhere at
once; one you leave out keeps its default:

```js
{
  features: {
    measurement: true,
    redaction: true,
    'documents.download': false,
  },
}
```

The Measure and Redact tabs appear, and nothing downloads the file: no Download in the document
menu, and no shortcut.

Most features are on from the start. Measuring, redaction, building forms and snapshots wait until
you turn them on, because most viewers don't need them.

## Which one to use

Three questions, three tools, each with its own names:

- **What people can do in this viewer:** `features`, or `readOnly`. They name features, such as
  `annotations` and `documents.download`, and reach everywhere at once: every button, menu row,
  tab, panel and shortcut.
- **Where a button goes:** the [`layout`](https://www.embedpdf.com/docs/viewer/vanilla/customize/layout.md). It names buttons, such as
  `tool:highlight` and `document:print`, and changes one place: a bar or a menu. The feature still
  works everywhere else.
- **What this user may do:** the [scope](#what-a-user-may-do). It names permissions, such as
  `doc.download`, and reaches everything, your code included: the engine refuses it.

A button shows when its feature is on, it's in the layout, the scope allows it, and it makes sense
right now (Copy needs a selection).

## What to write

Annotating, all of it or one tool:

```js
// No annotating at all
{ features: { annotations: false } }

// No highlighter in any bar, and no shortcut
{ features: { 'annotations.highlight': false } }

// Only the highlighter, no other annotating
{
  features: {
    annotations: false,
    'annotations.highlight': true,
  },
}

// Highlighting from selected text only, not the Annotate bar
{
  layout: (layout) =>
    layout.remove('tool:highlight', { from: 'annotate' }),
}
```

The features that start off:

```js
// Measuring
{ features: { measurement: true } }

// Redaction
{ features: { redaction: true } }

// Building forms: the Form tab
{ features: { 'forms.building': true } }

// Snapshots
{ features: { snapshots: true } }

// All four
{
  features: {
    measurement: true,
    redaction: true,
    'forms.building': true,
    snapshots: true,
  },
}
```

Downloading, printing and read-only:

```js
// No downloading or printing in this viewer
{
  features: {
    'documents.download': false,
    'documents.print': false,
  },
}

// Read-only
{ readOnly: true }

// Read-only, but people fill in the form
{ readOnly: { except: ['forms.filling'] } }
```

To stop a user downloading, from your code too, leave `doc.download` out of their
[scope](#what-a-user-may-do). To put a tool in a bar of your own, take it out of its bar with
`layout.remove()`, or the whole Measure tab with `layout.removeBar('measure')`, and
[add it](https://www.embedpdf.com/docs/viewer/vanilla/customize/layout.md#add-a-button) to yours.

## Every feature

All of them start on, except `forms.building`, `redaction`, `measurement` and `snapshots`. These
change the document, and `readOnly` turns them off:

| Feature       | What it covers                                                                                                                                                               |
| :------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `annotations` | `.highlight`, `.markup` (underline, strike out, squiggly), `.drawing` (ink and ink highlighter), `.text` (text boxes, callouts, insert and replace text), `.notes`, `.links` |
| `shapes`      | Squares, circles, lines, arrows, polygons and polylines                                                                                                                      |
| `stamps`      | Stamps and images                                                                                                                                                            |
| `comments`    | `.writing` (new comments and replies). `readOnly` turns off only this part, so people still read comments.                                                                   |
| `forms`       | `.filling`, `.building`                                                                                                                                                      |
| `signatures`  | `.signing`, `.checking`. `readOnly` turns off only `.signing`.                                                                                                               |
| `redaction`   | Marking redactions and applying them                                                                                                                                         |
| `measurement` | Distance, perimeter and area, and calibrating the scale                                                                                                                      |
| `pages`       | Rotating, moving, inserting and deleting pages in the thumbnails panel                                                                                                       |
| `attachments` | `.adding` (the attachment tool, and attaching and deleting files in the attachments panel). `readOnly` turns off only this part, so people still see and save the files.     |
| `outline`     | `.editing` (adding, renaming, moving and deleting items). `readOnly` turns off only this part, so people still follow the outline.                                           |

These don't change the document, and `readOnly` keeps them on:

| Feature      | What it covers                                  |
| :----------- | :---------------------------------------------- |
| `text`       | `.selection`, `.copy`                           |
| `search`     | Searching the text                              |
| `thumbnails` | The thumbnails panel                            |
| `snapshots`  | Copying or saving an area of a page as an image |
| `documents`  | `.open`, `.download`, `.print`, `.tabs`         |

A feature takes `true` or `false`, and so does each part, by its feature's name and its own:
`'annotations.highlight'`. The dot makes it a string, so it goes in quotes.

When a feature and one of its parts are both there, the part wins, in any order:

```js
{
  features: {
    annotations: false,
    'annotations.highlight': true,
  },
}
```

That's highlighting and nothing else. A part added in a later version follows its feature, so here
it stays off. The same goes the other way: `forms: true` turns on building forms too, while
`'forms.building': true` adds building to the filling that's already on.

Extracting pages into a new PDF is a download: it goes with `documents.download`, so `readOnly`
keeps it for your code (`page:extract`).

A mode tab disappears by itself when only its bar's
[dependent groups](https://www.embedpdf.com/docs/viewer/vanilla/customize/layout.md#build-a-bar), undo, redo and style, are left, so
`features: { shapes: false }` removes the Shapes tab. Annotations, comments and form values already in the
document still show; only making and changing them goes.

`features` and `readOnly` follow their props: change them while the viewer runs, and the tools
disappear or come back without a reload. That's how a feature can follow a user's plan:

```js
{ features: { measurement: user.plan === 'pro' } }
```

## Read-only

```js
{ readOnly: true }
```

It turns off every feature that changes the document, marked in the table above. People still
scroll, zoom, search, select and copy text, read annotations and comments, follow links, download
and print, and take snapshots when they're on. The tools just aren't there, as in a PDF reader. To
tell people why, add the **View only** label to your [layout](https://www.embedpdf.com/docs/viewer/vanilla/customize/layout.md); it shows while
nothing can change the document:

```js
{
  readOnly: true,
  layout: (layout) =>
    layout.add(
      { custom: 'view-only' },
      { to: 'main', before: 'panel:search' },
    ),
}
```

`readOnly` comes after `features`, so `measurement: true` doesn't bring the Measure tab back into a
read-only viewer. Keep one way of changing the document with `except`, and use `features` for what
else should go:

```js
{
  readOnly: { except: ['forms.filling'] },
  features: {
    'documents.download': false,
    'documents.print': false,
  },
}
```

That's a form people fill in and can't otherwise change, with no download or print button. Here
is `readOnly: true` with the same `features`, on a report someone marked up:

**`read-only.html`**

```html
<embedpdf-viewer id="viewer" style="height: 100%"></embedpdf-viewer>

<script type="module">
  import 'https://cdn.jsdelivr.net/npm/@embedpdf/viewer@3/dist/embedpdf.js';

  const report = 'https://www.embedpdf.com/pdfs/report.pdf';

  document.getElementById('viewer').config = {
    src: report,
    readOnly: true,
    features: { 'documents.download': false, 'documents.print': false },
  };
</script>
```

> **Try it:** the highlight, the underline and the red box around the "Documents opened" row show,
> and nothing changes them. The menu at the top left has no Download or Print, and search and copy
> still work.

## What a user may do

`features` and `readOnly` decide what the viewer offers. To decide what a user *may* do, give the
document a scope: the list of permissions the engine checks on every call, from a button or from
your code.

```js
{
  scope: [
    'doc.open',
    'doc.render',
    'doc.text.select',
    'doc.text.search',
    'doc.annotate.read',
  ],
  identity: { displayName: 'Ada Lovelace' },
}
```

Without a `scope`, the user may do what the file allows: everything, unless the PDF restricts
itself, such as no printing, as in Acrobat. `scope: ['*']` ignores the file's permission flags.
The scope and every permission in it are the [headless ones](https://www.embedpdf.com/docs/headless/react/concepts/permissions.md).

What the scope doesn't allow is hidden, like a feature that's off: a user without
`doc.annotate.modify` gets no annotation tools and no Annotate tab, and one without
`doc.render.thumbnail` (which `doc.render` includes) no thumbnails panel. To show those buttons greyed out
instead, with the reason in their tooltip, for example to offer an upgrade:

```js
{ notAllowed: 'disable' }
```

### The PDF's own restrictions

A PDF can carry restrictions of its own, set by its author with an owner password, such as no
printing or no copying. They count when the scope includes `'pdf.permissions'`, which grants what the
file allows:

```js
{ scope: ['pdf.permissions'] }
```

Permissions add up: a scope that lists `'doc.print'` next to `'pdf.permissions'` allows printing even
when the file says no. To let the file decide, list `'pdf.permissions'` and leave its permissions out.
The same rule holds on the server, so a document behaves the same on both engines.

## Your own code

- **Commands follow the viewer.** A command whose feature is off doesn't run, from a button or from
  `viewer.commands.execute()`, because commands are what the interface does. Your own Snapshot
  button needs `snapshots: true` too.
- **Plugins follow the scope.** `viewer.get('form').importValues(…)` works in a read-only viewer,
  so your app can fill in a form from its own data and show it read-only.

So `features` and `readOnly` are about the interface, and `scope` is about security. Someone who
opens the browser's developer tools can call the plugins too, so whatever a user truly may not do
belongs in the scope.

> **Keep the file on your server**
>
> With the local engine, the PDF is in the browser, so even a scope without `doc.download` can't stop
> someone who saves the file from the network panel. With CloudPDF, pages arrive as images and the
> server checks every call: a user who may not download never receives the file, and one who may not
> copy never receives the text.
>
> [Protect documents with CloudPDF](https://www.cloudpdf.com/docs/viewer/features/turning-off.md)

## Good to know

### Shortcuts don't fall through

A command that's off or not allowed still catches its keys. `Ctrl`/`Cmd`+`C` on text the user may
not copy says so, instead of the browser doing something else with the key.

### Your own commands

A command of yours joins a feature through `categories`, so `features` turns it off with it, and a
name of your own makes a new feature: `categories: ['acme.review']`, then
`features: { 'acme.review': false }`. A command that needs a permission says which with `requires`.
See [Buttons & commands](https://www.embedpdf.com/docs/viewer/vanilla/customize/commands.md#permissions).

### One button, everywhere

The layout takes a button out of one bar or menu, and its shortcut still works. To take a button out
of every bar and menu and its shortcut too, while its feature stays, turn the command off in the
commands plugin:

```js
{
  plugins: {
    commands: { disabledCommands: ['zoom:in', 'zoom:out'] },
  },
}
```

### `disable`, from 3.0

`disable` still works, until 4.0: a feature in it counts as `false` under `features`, and a button
in it as one in `disabledCommands`. Where both name the same feature, `features` wins.
