> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supernote.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Coordinate System

> With sn-plugin-lib later than 0.1.65, plugin coordinates use Android pixels and are based on the actual page size from getPageSize.

Supernote devices are e-ink devices. With `sn-plugin-lib` later than `0.1.65`, the coordinates a plugin reads from and writes to the SDK use a single system: **Android pixel coordinates**, based on the **actual page size**.

> [!NOTE]
>
> `sn-plugin-lib` `0.1.65` and earlier return EMR (electromagnetic digitizer) coordinates. Later versions return Android pixel coordinates only. The host decides which one to return based on the **`sn-plugin-lib` version the plugin uses**, not on the device system version.

## Android Coordinate System

**Definition**

* The unit is **pixels (px)**.
* Conventionally, **top-left is the origin**: `x` increases to the right, `y` increases downward.
* `width/height` represent the pixel dimensions of the page (e.g., A5X often uses `1404×1872`, Manta often uses `1920×2560`).

**Where It Applies**

* Stroke sample points (`points` in [`Stroke`](https://docs.supernote.com/en/api-reference/supernote-plugin/types/stroke)) and five-star points
* The lasso rectangle and lasso element points. See [Lasso](https://docs.supernote.com/en/plugin-base/lasso.md)
* Positions and regions of geometry, links, titles, text boxes, and similar elements

You do not need to convert these coordinates to EMR. You can use them directly to draw and position React Native views, and compare them directly across APIs.

## Use the Actual Page Size

Every coordinate you pass to the SDK, and every coordinate you get back, is based on the actual page size. Get that size with [`PluginFileAPI.getPageSize`](https://docs.supernote.com/en/api-reference/supernote-plugin/plugin-file-api/get-page-size), which returns `{ width, height }`. Coordinates should fall within `0..width` and `0..height`, regardless of the size shown on screen.

```ts wrap theme={null}
import { PluginFileAPI } from 'sn-plugin-lib';

/**
 * Read the actual page size as the baseline for the coordinate range.
 */
export async function exampleReadPageSize(notePath: string, page: number) {
  const res = await PluginFileAPI.getPageSize(notePath, page);
  if (!res?.success || !res.result) {
    throw new Error(res?.error?.message ?? 'Failed to get page size');
  }

  const { width, height } = res.result;
  return { width, height };
}
```

> [!NOTE]
>
> When you operate on the current page, the actual page size from `getPageSize` is still the baseline. Use [`getCurrentFilePath`](https://docs.supernote.com/en/api-reference/supernote-plugin/plugin-comm-api/get-current-file-path) and [`getCurrentPageNum`](https://docs.supernote.com/en/api-reference/supernote-plugin/plugin-comm-api/get-current-page-num) to get the current file path and page number, then call `getPageSize`.

## EMR Coordinate System (Older Versions)

> [!NOTE]
>
> EMR coordinates are used only in `sn-plugin-lib` `0.1.65` and earlier. Converting between EMR and Android coordinates is tedious, so later versions no longer let plugins read or write EMR coordinates. The SDK APIs perform all conversions internally. Plugins pass in and get back Android pixel coordinates only, and do not need to convert anything themselves. This section is kept so you know what EMR is when you read older plugins or older docs.

EMR (Electro-Magnetic Resonance) coordinates, also called digitizer coordinates, are defined at the hardware level by the EMR handwriting system. They describe the absolute position of the pen tip on the sensing surface.

**Definition**

* The unit is not pixels, but the digitizer's **hardware coordinate unit** (you can think of it as a finer grid).
* It is typically higher precision: one screen pixel may correspond to multiple EMR units.
* Axes and origin may differ from screen coordinates (varies by device and orientation), so conversion is required.

**Characteristics**

* Not equivalent to UI pixels: you cannot use EMR values as px for layout directly.

**Differences from Android Pixel Coordinates**

| Dimension | EMR coordinate system | Android pixel coordinate system |
| - | - | - |
| Data source | Digitizer/EMR pen sampling | Screen rendering/layout |
| Unit | Hardware units (not px) | Pixels (px) |
| Precision | Usually higher | Limited by screen resolution |
| Can be used directly for layout | No | Yes |
| Read and written by plugins in | `sn-plugin-lib` `0.1.65` and earlier | `sn-plugin-lib` later than `0.1.65` |

In older versions, use [`PointUtils`](https://docs.supernote.com/en/api-reference/supernote-plugin/utils/point-utils) to convert between EMR and pixel coordinates.

## Compatibility APIs for Older Versions

The following APIs are kept only for plugins that use `sn-plugin-lib` `0.1.65` or earlier. With later versions, avoid using them:

* `androidPoint2Emr` / `emrPoint2Android` in [`PointUtils`](https://docs.supernote.com/en/api-reference/supernote-plugin/utils/point-utils): convert between EMR and pixel coordinates
* [`getPageDisplaySize`](https://docs.supernote.com/en/api-reference/supernote-plugin/plugin-comm-api/get-page-display-size): get the display size of the current page
* `maxX` / `maxY` on [`Element`](https://docs.supernote.com/en/api-reference/supernote-plugin/types/trail): maximum values in EMR units

> [!WARNING]
>
> After you upgrade `sn-plugin-lib` to a version later than `0.1.65`, remove any `PointUtils` conversion. The SDK already returns and accepts Android pixel coordinates, so converting again produces wrong positions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.