---
url: /en-us/standard/blocks/canvas.md
---
* Type ID: `2`
* Type: Map

**A Canvas is "one layer of one page on one screen"**. The Ink, Shape, Media and Clear blocks that follow it are all drawn on this Canvas until the next Canvas appears. The Canvas also stores the page's metadata: page number, background, PPT binding, and the pan and zoom state `viewport`.

::: tip Levels

* **Core**: `pageGuid`, `pageIndex`, `layerIndex`, `workspaceGuid`, `deviceGuid`; for the same unique key, the last occurrence wins.
* **Basic**: `pageNumber`, `background`.
* **Standard**: `viewport`; for PPT, `slideId`, `binding`, `pageState`, `pageKind`.
* **Full**: compositing of multiple layers (`layerIndex > 0`), `layerNumber`.
  :::

## Fields

| Field | Type | Requirement | Level | Description |
| --- | --- | --- | --- | --- |
| `type` | uint16 | Required | Core | Always `2` |
| `workspaceGuid` | string(36) | Conditional | Core | Required when an explicit Workspace registry is used |
| `deviceGuid` | string(36) | Conditional | Core | Required when an explicit Device registry is used |
| `pageGuid` | string(36) | Required | Core | Permanent UUID of the page |
| `pageIndex` | uint32 | Required | Core | Order of the page within the Workspace, starting at `0` |
| `pageNumber` | uint32 | Required | Basic | Page number shown in the UI; not used for ordering |
| `layerIndex` | uint32 | Required | Core | Layer order, starting at `0` |
| `layerNumber` | uint32 | Required | Full | Layer number shown in the UI; not used for ordering |
| `viewport` | Map | Optional | Standard | Pan and zoom, written on layer 0 only; see [viewport](#viewport) |
| `background` | Map | Optional | Basic | Page background, written on layer 0 only; see [Page metadata](#page-metadata) |
| `pageState` | int32 | Optional | Standard | Page state, written on layer 0 only |
| `pageKind` | int32 | Optional | Standard | Page kind, written on layer 0 only |
| `binding` | int32 | Optional | Standard | PPT binding method, written on layer 0 only |
| `slideId` | int32 | Conditional | Standard | PowerPoint `SlideID`; see [PPT binding](#ppt-binding) |
| `extra` | Map | Optional | — | App-private fields |

## Page identity

* **CANVAS-1** `pageGuid` is unique within the whole file and stays unchanged after pages are reordered or the file is fully saved; a copied page must get a new UUID.
* **CANVAS-2** Canvases of the same page on multiple Devices and multiple layers share `pageGuid` and `pageIndex`.
* **CANVAS-3** In a compact file, within one Workspace `pageGuid` and `pageIndex` correspond one to one, and `pageIndex` is contiguous starting at `0`. During page append there may temporarily be duplicates or gaps; readers handle them per SAVE-14.
* **CANVAS-4** Under each `(Workspace, Device, pageGuid)`, `layerIndex` is contiguous starting at `0`. Different Devices may have different numbers of layers.
* **CANVAS-5** `(Workspace, Device, pageGuid, layerIndex)` is the unique key of a Canvas. When the same key appears more than once, the later one replaces the earlier one entirely (FILE-8).
* **CANVAS-6** `pageNumber` and `layerNumber` are for display only and may skip numbers or repeat.
* **CANVAS-7** When a page is copied, the new page inherits the original page's `viewport` and page metadata.

## Page metadata

Page metadata belongs to "a page on a given Device" and, like `viewport`, is written on layer 0 only:

* **CANVAS-8** `viewport`, `background`, `pageState`, `pageKind` and `binding` may only be written on the Canvas with `layerIndex = 0`; other layers inherit them from layer 0. When readers find these fields on other layers, they ignore them and report a warning.

### `background` (Basic)

| Field | Type | Requirement | Description |
| --- | --- | --- | --- |
| `color` | [Color Map](../common/color) | Required | Background color |
| `pattern` | int32 | Optional | `0` Blank (default), `1` Dots, `2` Grid (square grid); `3`–`127` reserved, `128`+ private |

* **CANVAS-9** The pattern's spacing and line color are up to the app. An unknown `pattern` is shown as Blank.
* **CANVAS-10** Without `background`, the background is transparent (screen annotation, PPT) or up to the app (whiteboard).

### `pageState`, `pageKind`, `binding` (Standard)

| Field | Value | Meaning |
| --- | --- | --- |
| `pageState` | `0` Active (default) | Normal page |
| | `1` Retained | Retained page: its content is still saved but not shown in the normal page order. For example, annotations in PPT whose slide has been deleted |
| `pageKind` | `0` Normal (default) | Ordinary page |
| | `1` EndScreen | The black screen page after a PPT slide show ends; may have no `slideId` |
| `binding` | `0` SlideId (default) | Bound to a slide by `slideId` |
| | `1` PageIndex | Bound by order: page `pageIndex` corresponds to slide `pageIndex + 1` |

* **CANVAS-11** Standard readers do not put retained pages into the normal page order; they may list them separately for the user to view or rebind.
* **CANVAS-12** Unknown values of `pageState`, `pageKind` and `binding` are treated as the default.

## PPT binding

* **CANVAS-13** When `workspaceType = 2`, an ordinary page with `binding = 0` (default) must write `slideId`; pages with `binding = 1` or `pageKind = 1` may omit it.
* **CANVAS-14** When binding by `slideId`, readers locate the slide with `Slides.FindBySlideID`. If it cannot be found, readers must keep the Canvas, mark it as unbound and notify the user; they must not automatically reattach it by `pageIndex`, the current page or any other slide. After the user picks a new slide through an explicit rebind action, writers save the new binding.
* **CANVAS-15** When the same slide is shown on multiple Devices, the Canvases share `pageGuid` and `slideId`, and their content is independent.

## viewport

The `viewport` specifies which point on the Canvas maps to the Device's top-left corner and what scale factor to use.

| Field | Type | Requirement | Description |
| --- | --- | --- | --- |
| `x` | float32 | Required | Canvas X corresponding to the Device's top-left corner; may be negative |
| `y` | float32 | Required | Canvas Y corresponding to the Device's top-left corner; may be negative |
| `scale` | float32 | Required | Scale factor, a finite positive number; `1` means one Canvas unit corresponds to one Device pixel |

Conversion between Canvas coordinates and Device coordinates:

```text
deviceX = (canvasX − viewport.x) × viewport.scale
deviceY = (canvasY − viewport.y) × viewport.scale

canvasX = deviceX / viewport.scale + viewport.x
canvasY = deviceY / viewport.scale + viewport.y
```

* **CANVAS-16** When `viewport` is missing, it is `{ x: 0, y: 0, scale: 1 }`.
* **CANVAS-17** All content blocks (Ink, Shape, Media) are mapped by the same `viewport`; Ink stroke widths and Shape stroke widths are also multiplied by `scale`.
* **CANVAS-18** The Canvas range currently visible on the Device is `Device.width / scale` wide and `Device.height / scale` high. When the Device size changes, the top-left corner stays fixed and the visible range grows or shrinks toward the bottom right.
* **CANVAS-19** `viewport.x` / `y` are Canvas coordinates and have nothing to do with the Device's own `x` / `y` (DEV-3).
* **CANVAS-20** UInk does not register viewport rotation, skew or non-uniform scaling.
* **CANVAS-21** All Workspace types may use `viewport`. An app may disallow user panning and zooming, but when it encounters a valid non-default `viewport` it must display it using the formulas in this section.
* **CANVAS-22** When `viewport` is missing a field, `x` / `y` is not a finite number, or `scale` is not a finite positive number, the whole `viewport` is invalid and the default is used.

## Other rules

* **CANVAS-23** A Canvas does not store its own bounds; its display viewport always fills the Device it references (FILE-10).
* **CANVAS-24** When explicit registries are used and `workspaceGuid` or `deviceGuid` is missing or cannot be found, readers create a temporary Workspace or root Device and report a warning (FILE-23).
* **CANVAS-25** When `pageGuid` or `pageIndex` is missing or invalid, readers may generate temporary pages in object stream order; when `layerIndex` is missing or invalid, they generate temporary layers under the temporary page in object stream order. Temporary results must not be written back to the file.

## Example

```jsonc
{
  "type": 2,
  "workspaceGuid": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
  "deviceGuid": "11111111-1111-4111-8111-111111111111",
  "pageGuid": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
  "pageIndex": 0,
  "pageNumber": 1,
  "layerIndex": 0,
  "layerNumber": 0,
  "viewport": { "x": -320.0, "y": 180.0, "scale": 1.5 },
  "background": { "color": { "fallback": 16777215 }, "pattern": 1 }   // white background with a dot pattern
}
```

PPT end page:

```jsonc
{
  "type": 2,
  "workspaceGuid": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
  "pageGuid": "dddddddd-dddd-4ddd-8ddd-dddddddddddd",
  "pageIndex": 24, "pageNumber": 25, "layerIndex": 0, "layerNumber": 0,
  "pageKind": 1                                                         // no slideId
}
```

## Fallback

| Capability the reader lacks | How it is shown |
| --- | --- |
| `background` (Core) | Transparent or the app's default background |
| `viewport` (Core, Basic) | Shown as `{ x: 0, y: 0, scale: 1 }` |
| PPT binding, `pageState`, `pageKind` (Core, Basic) | All pages are shown as ordinary pages by `pageIndex`, retained pages included |
| Multiple layers (below Full) | Overlaid by `layerIndex` from low to high and shown as one layer |

## Related

* [Main Ink File](../file/main)
* [Header Extension Block](headerextension)
* [Device Structure](device)
* [Saving, Appending and Recovery](../incremental)
