Skip to main content

remarkable-annotations

Read and write the annotations of reMarkable documents: pen strokes and text highlights on PDF pages, stored as .rm version 6 scene files.

One Rust library, published for three languages:

Language Package Built from
Rust remarkable-annotations (crates.io) this crate
JavaScript remarkable-annotations (npm, WebAssembly) wasm/ (wasm-bindgen)
Python remarkable-annotations (PyPI) src/py (PyO3, maturin)

The library does no I/O: it works on bytes, so it runs the same in a browser, in privileged Firefox code (a Zotero plugin), in Node and in Python.

Status: early. Done: .rm v6 scenes, page annotations (reading, rewriting pages), shape detection, coordinates and PDF page sizes, and a reMarkable cloud client (sans-I/O). All of it is ported from the TypeScript implementation in zotero-remarkable-sync, and tested against it.

Used by

  • zotero-remarkable-sync, a Zotero plugin that syncs annotations between Zotero and a reMarkable tablet. It uses the JavaScript (WebAssembly) package for the .rm scenes, the pages and the reMarkable cloud client.

Scenes

use remarkable_annotations::scene::Scene;

let bytes = std::fs::read("page.rm")?;
let scene = Scene::parse(&bytes)?;
assert_eq!(scene.serialize(), bytes); // byte for byte

Writing back an unmodified scene gives the input bytes: blocks that fail to parse are kept raw, each block keeps its unread tail, and wire details with no meaning (string ASCII flags, absent optional fields) are kept as read.

Reading and writing pages

page::parse_page (parsePage in JavaScript) maps a page's blocks to strokes (line items) and highlights (glyph ranges). Each comes with its scene item ids, so a caller can remove it later.

page::rebuild_page (rebuildPage) drops the items whose id is in remove, keeps every other block as is, then appends the new items (highlights first) after the layer's last item. It returns the ids it gave them.

A page without a .rm file gets one from a template: split_structure copies another page's structure without its items, and blank_structure builds one from scratch.

Rules the tablet enforces

These were checked on a real tablet:

  • Counters: new items must use counters above every counter on the page, whatever their author (max_counter covers tombstones and groups too). The tablet drops the others when it loads the page.
  • Authors: item ids are (author, counter), and the author is a byte, so a page holds at most 255 authors. Authors added to the page's author table (PageUpdate::register) survive tablet saves. An erased item leaves a tombstone that keeps its author id.
  • Per-item authors: PageUpdate::authors sets the author of each added item. The Zotero plugin uses this to tag each item with the annotation it mirrors (an author uuid encoding the Zotero key).

Pages and PDF pages

A document's .content gives the page order (pages, or cPages.pages without deleted pages) and the redirectionPageMap, which maps reMarkable pages to PDF pages; each page's annotations are in {pageUuid}.rm. Page tags (the tablet's tag-a-page feature) name the page they belong to.

Coordinates

The tablet renders a PDF at a fixed resolution (RM_DPI = 226, calibrated on an rM2) and stores coordinates in those device pixels, with x measured from the page centre and y from the top. geometry converts them to PDF points (origin bottom-left) with a single scale:

pdfX = rmX * 72/RM_DPI + x0 + pageWidth/2
pdfY = y0 + pageHeight - rmY * 72/RM_DPI

The mapping was checked against a real export: highlight rectangles matched the PDF's vectors within 1 pt. Pen widths use a factor fitted the same way (ink_width, pdf_width_to_rm).

read_pdf_page_sizes gives each page's visible size. It walks the PDF's page tree (pdf), expanding compressed object streams and honouring inherited boxes. If that fails, it falls back to a plain-text scan of /MediaBox, then to US Letter.

Cloud

cloud is a reMarkable cloud client that does no I/O: each operation hands the host the HTTP requests to make, and continues with the responses. Where rmapi-js runs requests in parallel (Promise.all: listing items, a document's metadata and content, page uploads), the operation hands them over together as a batch, which the host runs concurrently; listing 50 documents takes 4 round trips. The host also provides the clock and uuids. The same client runs in a browser, in privileged Firefox code, in Node and in Python.

import init, { CloudSession, cloudAuth } from "remarkable-annotations";

async function perform(item) {
  // a request, or a sleep before a retry
  if (item.type === "sleep") {
    await new Promise((ok) => setTimeout(ok, Math.random() * item.ms));
    return undefined;
  }
  const r = await fetch(item.url, { method: item.method, headers: item.headers, body: item.body });
  return { status: r.status, statusText: r.statusText, body: new Uint8Array(await r.arrayBuffer()) };
}

async function run(op) {
  for (let step = op.start(); ; ) {
    if (step.type === "batch") step = op.resumeBatch(await Promise.all(step.items.map(perform)));
    else if (step.type === "request" || step.type === "sleep") step = op.resume(await perform(step));
    else if (step.type === "done") return step; // json, bytes or text
    else throw step.error; // {kind: "generation" | "hashNotFound" | "response" | ..., message}
  }
}

const { text: token } = await run(cloudAuth(deviceToken));
const session = new CloudSession(token);
const items = JSON.parse((await run(session.listItems(false))).json);

Operations: listItems, listRefs, getContent, getMetadata, getEntries, getHash, putPdf, putEpub, putFolder, updateDocument, move, purge, putRmPages (one commit; hashNotFound if the document changed), and the document helpers uploadPdf (with the full page list), ensureFolder, fetchAnnotations and mapPdfPages; cloudRegister and cloudAuth for tokens. Generation conflicts and transient errors are retried as rmapi-js does.

The protocol is rmapi-js's, ported operation by operation. cloud-check.mjs runs rmapi-js and this client side by side on fake clouds (fakecloud.mjs): accounts on schema 3 and 4, reads, writes, errors, transient failures, and other devices writing at the same time. Both must return the same results (as JSON text) and leave the same cloud, byte for byte.

Tests

cargo test                          # Rust
uv venv && uv pip install maturin pytest && maturin develop --uv && pytest  # Python

The fixtures in tests/fixtures/rm are real tablet pages (from rmscene) and pages written by the TypeScript implementation. For each one, the tests check that:

  • it round-trips byte for byte;
  • the parsed blocks are those of rmapi-js (X.rmapi.json, written by tests/reference/dump.mjs);
  • corrupted copies (bytes changed, inserted, removed, truncated) still parse and round-trip, without panics.

The page, geometry, shape and PDF modules are compared with the TypeScript implementation: page-dump.mjs and geometry-dump.mjs record its results (annotations of every fixture, rebuilt pages byte for byte, shapes, coordinate conversions, page sizes of the PDFs in tests/fixtures/pdf, made by gen-pdfs.py).

License

Licensed under either of the MIT license or the Apache License, Version 2.0, at your option. See NOTICE for the projects this one derives from.

Metadata

Release files for remarkable-annotations 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remarkable-annotations 0.2.0
File Size Uploaded Provenance Actions
remarkable_annotations-0.2.0.tar.gz 728.0 kB With provenance Details for remarkable_annotations-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for remarkable-annotations 0.2.0
File Actions
remarkable_annotations-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for remarkable_annotations-0.2.0-cp310-abi3-win_amd64.whl
remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
remarkable_annotations-0.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for remarkable_annotations-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
remarkable_annotations-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for remarkable_annotations-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 4.8 MB

Release files / remarkable_annotations-0.2.0.tar.gz

Download URL remarkable_annotations-0.2.0.tar.gz
Size 728.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cb5479634df046f990cc4727e608fe8bf24c2beae09b8df177b0fd7d1767bee0
BLAKE2b-256 checksum
How to use checksums
a84e3e43798437ef99cbbeb99381d767216b91550c411ade65f611df8beb749d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / remarkable_annotations-0.2.0-cp310-abi3-win_amd64.whl

Download URL remarkable_annotations-0.2.0-cp310-abi3-win_amd64.whl
Size 765.0 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f5428974614e6d42ccd78c1fce337fa5aa3084c23bff7a468f5c5f281408a558
BLAKE2b-256 checksum
How to use checksums
571c923fa2746eb71bdcd91b18a9e910d372735e2699c3542acb2ac71924d4b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 869.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
bfe716da4657ed5ab16a5345e3dacb4f3da6e42ef0d005a27b16b11188706a67
BLAKE2b-256 checksum
How to use checksums
58b81a35e65016dcb72c74a602d9eba7667101725997fd54f2c49f0aa1683888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL remarkable_annotations-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 826.5 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4349f88affb8513934f1edfdecbd097b1e6e8a5ea425b5fdd6091afd307c7686
BLAKE2b-256 checksum
How to use checksums
9131ead1a5fdde5ce6fa0f878ffa5d14ed1692de26b03ab0eaa68a3729cd8984
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / remarkable_annotations-0.2.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL remarkable_annotations-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 784.2 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
41449f2931c17b4ba13ab1360acf6829f559914f22b78126aaa6e3ebe3e2a880
BLAKE2b-256 checksum
How to use checksums
b50ab5c063cf8c0eaf98b02ebcd64ba021264cfaeed9b64f305eb271a08c655b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / remarkable_annotations-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL remarkable_annotations-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 840.2 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
13878f791a9be86111c4b4f87cd64fdc0bc56535fe234cd4953d9c475bf4d10d
BLAKE2b-256 checksum
How to use checksums
3281b30ab6e056240e9d5e9c94326b69b4d9c5dd3a94b00a13a6b4831d2b1b27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for remarkable-annotations 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for remarkable_annotations-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page