# SDKMode and the resting tool

`mode` says what the viewer is for and `defaultTool` which tool it rests in. Both are top-level keys of `PDFViewerConfig`, beside `tools`, `toolbar` and the other sections. The mode sets which tools exist at all, and the [`tools`](https://kernstra.com/docs/web-sdk/config/tools) map turns individual tools off within it — it cannot add a tool the mode does not offer. Select, Pan and Search exist in every mode; Sign also in `'form-fill'` (for your own button — the toolbar shows no tools there); every other tool in `'full'` only. `viewer.isToolEnabled(tool)` answers for any tool.

Print and download stay available in every mode (`toolbar.print`, `toolbar.download` turn them off), and so does the rest of the programmatic API. Form values are the exception: in `'view-only'` every field is read-only, so `doc.forms.setValues()` rejects each field with the reason `read_only` (a signature field, as always, with `unsupported_type`).

## Example

```ts
import { PDFViewer, SDKMode } from '@kernstra/pdf-web-sdk';

// A reader — nothing on the page can change
new PDFViewer(container, doc, { mode: SDKMode.VIEW_ONLY });

// Form filling only — clean, focused UI
new PDFViewer(container, doc, { mode: SDKMode.FORM_FILL });

// Everything, minus a few tools
new PDFViewer(container, doc, {
  mode: SDKMode.FULL,
  tools: { stamp: false, link: false },
});
```

## Options (2)

### `mode`

- Type: `SDKMode ('view-only' | 'form-fill' | 'full')`
- Default: `SDKMode.FULL`
- Page: https://kernstra.com/docs/web-sdk/config/mode/mode

What the viewer is for. `SDKMode` is a frozen object whose values are these strings, so `mode: 'view-only'` and `mode: SDKMode.VIEW_ONLY` are the same thing. A `mode` that names none of the three — an old `'VIEW_ONLY'` spelling, say — falls back to `'full'` with a console warning. See [SDKMode](https://kernstra.com/docs/web-sdk/api/enums#s-sdkmode).

- `SDKMode.VIEW_ONLY ('view-only')`: A reader. Pan and Select, the panels (pages, outline, attachments, signatures), search from the keyboard, print and download. Form fields show their values and cannot be filled. No tools, no undo.
- `SDKMode.FORM_FILL ('form-fill')`: Complete a document. Form fields and signatures are interactive; the toolbar carries the panel toggles and actions only, with no authoring tools.
- `SDKMode.FULL ('full')`: **Default.** Everything: Pan, Select, undo/redo, Add Text, Edit Text, Sign, Check, Cross, Dot, Arrow, Draw, Line, Rectangle, Ellipse, Polygon, Polyline, Erase, Highlight, Text Highlight, Text Box, Image, Stamp, Link, Note, Search, Manage Pages, Security. Turn off what you do not need.

```ts
new PDFViewer(container, doc, { mode: SDKMode.VIEW_ONLY });
```

### `defaultTool`

- Type: `'selectText' | 'pan' | null`
- Default: `'selectText'`
- Page: https://kernstra.com/docs/web-sdk/config/mode/defaulttool

The resting tool. A document opens in Select, as it does in Acrobat, and every other tool goes back to it when it is put away — Escape, its button pressed again, the Close on a phone's sheet, a tool that finishes on its own. Select's button shows pressed and `viewer.activeTool` answers `'selectText'` from that moment; `toolChanged` reports it once it has started, and is never told `null` in between. Select and Pan need no license feature and no document permission.

In Select, **text** is selected by dragging over it, which brings up the selection bar. Ctrl/Cmd+C (or the browser's Copy) copies the selection, unless the document forbids copying, a field has the focus, or the host page has a selection of its own or answered the copy itself. A press anywhere else — outside the viewer, on the pages off the text — lets go of the selection, and so do Escape and a zoom. Wherever the words leave the viewer — Copy and Ctrl/Cmd+C, Search for this, the first words of Add a note — the license rule of the accessible text layer applies: the `extract` feature, or a production license's clean output. On a development key without `extract` the bar has neither Copy nor Search for this, and a note starts empty. A click on an **annotation** selects it; over one, the pointer is the arrow, not the text cursor; Escape puts it down without leaving Select. **Links and form fields** answer as with no tool: a click follows a link, and a field takes the click and the typing. On **touch**, one finger scrolls the pages; a long press (half a second, held still) selects the word under it, with handles and the bar in the phone's sheet; a tap selects the annotation under it. A page's text is read when a mouse or pen first comes over that page, or a finger holds still on it — never when the document opens or is scrolled — and read again after a zoom.

`tools.selectText: false` (or `pan: false` for a Pan rest) leaves no tool active; any other value is ignored with a console warning.

- `'selectText'`: Default. Rest in Select: drag over text to select it, click an annotation to select it, links and fields answer as with no tool.
- `'pan'`: Rest in Pan instead: drag to scroll, a click selects an annotation; links are not followed in Pan.
- `null`: Rest in no tool: the pages' own text selection and copy (see the accessible text layer), links and fields, and a click on an annotation still selects it.

```ts
new PDFViewer(container, doc, { defaultTool: 'pan' });
```

## Notes

The full `PDFViewerConfig` interface has these optional keys: `mode`, `tools`, `defaultTool`, `forms`, `export`, `confirmations`, `fonts`, `toolbar`, `navigation`, `sidebar`, `links`, `print`, `theme`, `locale`, `callbacks`, `performance`, `accessibility`, `loader`, `annotations` and `layout`. Each has its own section in this reference.


Web page: https://kernstra.com/docs/web-sdk/config/mode
