---
title: "Kition Viewer — preview docx, xlsx, pptx, PDF and Markdown attachments read-only, and ask your AI about them"
description: "One call opens an attachment read-only in the kit its file name picks, with no toolbar: for OA, CRM and any business system that previews files. Your assistant reads the document through the agent port and cannot change it. Watermark, no download or print, and your permissions decide who edits. Free, no key."
canonical: "https://developer.kition.ai/viewer"
---

> Canonical HTML: [https://developer.kition.ai/viewer](https://developer.kition.ai/viewer)

Kition Viewer · read-only · @kition/sdk/embed

# Preview any attachment, and ask your AI about it

OA, CRM and other business systems mostly show attachments: a contract in .docx, a quote in .xlsx, a deck in .pptx, a receipt in .pdf. One call opens each in the kit its file name picks, and your assistant can answer questions about it. Kition Viewer opens a file read-only, with no toolbar: the person reads, selects, zooms and copies, and every change is refused.

Need people to edit? That is the [editor](https://developer.kition.ai/embed); the two are the same kit package, and your permissions pick one per person.

Live

## Five files, one viewer

Each file opens read-only in the real kit, with no toolbar, from this site’s kits origin. Switch files, try to type, then ask the assistant beside it. The files stay in this tab.

kition-doc · project-proposal.docx

Opens project-proposal.docx read-only in the real Doc kit. Loads about 37 MB.

### Ask about this file

Mock AI

The assistant here is a mock AI: there is no model. Its answers come from fixed rules over real reads of the open document through the agent port; in your product, your own model answers.

1.  Open the file on the left, then pick a question.

The code this demo runs

viewer.ts · project-proposal.docx

```
import { KitionEmbed } from 'https://kits.kition.ai/embed/index.js'

// the kit, picked by this page from the file's extension
const viewer = await KitionEmbed.mount(element, {
  kit: {
    id: 'kit.doc',
    // this site's static kits origin; in your product, your own CDN
    url: 'https://kits.kition.ai/doc-ui/',
  },
  file: { id: 'sample-doc', name: 'project-proposal.docx' },
  storage, // read and stamp: the sample's bytes in this tab
  permissions: { mode: 'view' },
  ui: { toolbar: 'none' },
  locale: 'en-US',
  theme: { colorScheme: 'dark' },
})
const port = viewer.agentPort({ label: 'Mock AI', draft: false })
```

The demo picks the kit from the file’s extension and mounts it with `KitionEmbed.mount`, view mode and no toolbar: what `KitionViewer.mount` does for you. PDF is not live on this site yet.

Code

## One call per attachment

[The viewer guide](https://developer.kition.ai/docs/viewer)

KitionViewer.mount takes the kit packages you host and picks the kit from the file’s extension; a file no kit opens fails with unsupported-file, so your page can offer a download instead. Your storage only reads: `read` and `stamp`.

`npm i @kition/sdk`

Until `KitionViewer` is in the published `@kition/sdk/embed`, the same viewer is one `KitionEmbed.mount` with view mode and no toolbar, the kit picked by your own code:

viewer.ts · KitionEmbed.mount, read-only

```
import { KitionEmbed } from '@kition/sdk/embed'

const editor = await KitionEmbed.mount(element, {
  kit: {
    id: 'kit.doc', // your own choice, from the file's extension
    // static files on your CDN: the editor and its WebAssembly engine
    url: 'https://cdn.example.com/kition/doc-ui/',
  },
  file: { id: 'contract-118', name: 'Contract.docx' },
  storage,
  permissions: { mode: 'view' }, // read-only: every change is refused
  ui: { toolbar: 'none' },       // no ribbon tabs
})
```

viewer.ts · KitionViewer.mount

```
import { KitionViewer, relayAgentPort } from '@kition/sdk/embed'

const viewer = await KitionViewer.mount(element, {
  // the file name picks the kit
  file: { id: 'contract-118', name: 'Contract.docx' },
  // the kit packages you host, and what each opens
  // static files on your CDN: the editor and its WebAssembly engine
  kits: [
    { id: 'kit.doc', extensions: ['.docx'],
      url: 'https://cdn.example.com/kition/doc-ui/' },
    { id: 'kit.sheet', extensions: ['.xlsx', '.csv'],
      url: 'https://cdn.example.com/kition/sheet-ui/' },
    { id: 'kit.pdf', extensions: ['.pdf'],
      url: 'https://cdn.example.com/kition/pdf-ui/' },
  ],
  storage, // yours: read and stamp are enough, a viewer writes nothing
})

// Optional: your assistant reads the open document through the agent port;
// your page shows the chat, your server runs the model.
void relayAgentPort(viewer.agentPort({ label: 'Assistant' }), transport)
```

Side by side

## Editor or viewer

Editor and Kition Viewer: the differences

|  | Editor | Kition Viewer |
| --- | --- | --- |
| The person | Reads and edits, with the kit’s full ribbon and panels | Reads, selects, zooms, pans and copies; every change is refused |
| You pass | KitionEmbed.mount with one kit, the file, your storage and your identity | The file and the list of kit packages you host; the file’s name picks the kit |
| Toolbar | The kit’s ribbon tabs, or the ones you keep with ui | None: ui: { toolbar: 'none' } hides the ribbon tabs |
| Your assistant | Reads and edits through editor.agentPort(); its edits go to a draft the person merges or discards | Reads through the agent port (\_inspect, \_query, \_check); every write is refused with read-only, and there is no draft |
| Your storage | read, stamp, write (versioned), create | read and stamp only: a viewer writes nothing |
| What loads | The kit package from your CDN the first time, then from the browser’s cache | The same package: the viewer is the editor opened read-only, so a kit loads once for both |

From kition-sdk’s [embed guide, “Two modes”](https://developer.kition.ai/docs/embed#two-modes) (view mode, the toolbar setting, the agent port) and its [viewer guide](https://developer.kition.ai/docs/viewer).

Who gets which

## Your permissions decide

The same file opens as an editor for the people who may edit it and as a viewer for everyone else, from your server’s answer for each person and file.

-   Your identity provider answers `permissions(fileId)` with `edit`, `comment` or `view`, each time the file opens; the stricter of it and the page’s own `permissions` applies.
-   How much interface shows is a setting of its own: `ui: { toolbar: 'none' }` for a viewer.
-   To go from viewing to editing, close it and mount the file again as an editor.

page.ts · identity.permissions

```
// your server's answer, for this person and this file
// 'edit' | 'comment' | 'view'
const { mode } = await api.permissions(file.id)

const opened = await KitionEmbed.mount(element, {
  kit, file, storage,
  identity: { ...identity, permissions: async () => ({ mode }) },
  // people who may only read get the viewer: no ribbon tabs
  ...(mode === 'view' ? { ui: { toolbar: 'none' } } : {}),
})

// Granted edit since? Close it and mount again as an editor.
opened.destroy()
```

Download, print, watermark

## What a viewer may take out

You decide what a viewer may take out: download, export and print, and share, and a watermark the kit draws over the document. They are display permissions: your server still decides which bytes it serves.

-   `download`: the kit’s Download.
-   `export`: Export and Print.
-   `share`: the kit’s Share.
-   `watermark`: text drawn faint and repeated over the document, in previews and prints too.

The kit builds in this page’s demo do not draw the watermark yet, so the demo has no switch for it.

viewer.ts · a contract, previewed

```
// a contract, previewed: a watermark, nothing to take out
const viewer = await KitionViewer.mount(element, {
  file, kits, storage,
  display: {
    // export also covers Print
    permissions: { download: false, export: false, share: false },
    watermark: { text: 'Ann Lee · Confidential' },
  },
})
```

Your assistant

## Ask about the file, never change it

[Agents and the kit tools](https://developer.kition.ai/agents)

In a viewer your assistant reads the open document through the agent port (\_inspect, \_query, \_check), and every write is refused with read-only; there is no draft.

The SDK ships neither the chat nor the model. Your page shows the chat; `relayAgentPort` carries the port’s messages to your server, where your model calls the read tools. The demo’s assistant is a mock that runs those same calls in the browser.

-   `_inspect`what the document holds: text, pages, sheets, slides, layers
-   `_query`objects of the document through its object model
-   `_check`what the kit finds wrong with the file
-   `_run, _batch`refused: `read-only`

Files

## What it opens

At launch the viewer is polished for Doc, Sheet, Slide, PDF and Note files, with automated tests; Photo, Vector, CAD and HTML open read-only with their look checked kit by kit; the other seven kits open read-only too.

The files Kition Viewer opens, by kit

| Kit | Opens and saves | Opens read-only only | At launch |
| --- | --- | --- | --- |
| Note | `.md .markdown` | — | Polished for viewing |
| Doc | `.docx` | `.html .htm` | Polished for viewing |
| Sheet | `.xlsx .xlsm` | `.xltx .xltm .xls .xlt .et .ett .xlsb .ods .csv` | Polished for viewing |
| Slide | `.kslide .pptx` | — | Polished for viewing |
| PDF | `.pdf` | — | Polished for viewing |
| HTML | `.html .htm` | — | Opens read-only, look checked per kit |
| Photo | `.psd .psb .kphoto` | — | Opens read-only, look checked per kit |
| Vector | `.kvector` | `.svg .ai .eps` | Opens read-only, look checked per kit |
| CAD | `.dxf` | — | Opens read-only, look checked per kit |
| Table | `.ktable` | — | Opens read-only |
| Board | `.kboard` | — | Opens read-only |
| Layout | `.klayout` | `.idml` | Opens read-only |
| Design | `.kdesign` | `.fig .sketch` | Opens read-only |
| Film | `.kfilm` | — | Opens read-only |
| Motion | `.kmotion` | — | Opens read-only |
| Scene | `.kscene` | — | Opens read-only |

From each kit’s `kit.json` (`formats`). Not opened before launch: .doc, .ppt, images (.png, .jpg), plain text (.txt). For those, offer a download.

Size

## How much loads

-   In your page, `@kition/sdk/embed` is about 80 KB.
-   The viewer is the kit’s editor opened read-only, so it loads the same kit package from your CDN: in this site’s demos about 22 to 37 MB the first time a kind of file opens, most of it the WebAssembly engine and fonts.

-   After that the package comes from the browser’s cache: the hashed files under `assets/` are cached for a year.
-   A kit loaded once for viewing is already cached for editing, and the other way round.

## Preview attachments in your product

Install the package, put the kit packages on your CDN, and open each attachment read-only with one call.

`npm i @kition/sdk`

[Open playground](https://developer.kition.ai/playground)
