# Integration: Postext inside a content system

> What Postext gives a content management, editorial or review system, or a reading app, that shows laid-out pages: text geometry, anchors that survive revisions, annotation marks and an embeddable page viewer, and what it leaves to the host

- HTML version: https://postext.dev/en/docs/integration
- Last updated: 2026-12-04
- Reading time: 6 min
- Other languages: [es](https://postext.dev/es/docs/integration.md), [ca](https://postext.dev/ca/docs/integration.md), [de](https://postext.dev/de/docs/integration.md), [el](https://postext.dev/el/docs/integration.md), [fr](https://postext.dev/fr/docs/integration.md), [it](https://postext.dev/it/docs/integration.md), [pt](https://postext.dev/pt/docs/integration.md), [ru](https://postext.dev/ru/docs/integration.md), [zh](https://postext.dev/zh/docs/integration.md), [ja](https://postext.dev/ja/docs/integration.md), [ar](https://postext.dev/ar/docs/integration.md)

## In short

This page is for developers who build a content system, such as a tool where authors write and editors correct. It explains what Postext gives them to show the real pages of a book inside their own tool. Readers can select words on a page, and the tool learns which words of the text they are. The tool can draw highlights, crossed-out words and notes on the pages. Who may change what, and what happens to a note, stays the tool's own business.

**A content system shows the book's real pages, lets people point at its words, and draws its own marks on them. Postext does the page work; the system keeps the workflow.**

A team that writes and corrects books in a content management system wants
to see the pages as they will print, select a sentence on page 37, attach a
comment to it, strike a word and write the correction between the lines, and
find that comment again after the author has rewritten the paragraph. Each of
these steps needs to know where a piece of text lies on a laid-out page, and
that is what Postext computes.

The same questions come from the other side of publishing. A reading app,
an e-reader or a study platform shows the finished book and lets its
readers highlight passages, write notes in the margin and find them again
in the next edition. [Reading apps and other
viewers](https://postext.dev/en/docs/integration-readers.md) works through both, a highlighter
and a reader's notebook, and shows the same marks in a viewer the app
draws itself.

The integration API answers four questions in terms of the Markdown the book
is written in:

| Question | Answer | Where |
| --- | --- | --- |
| Where on the pages is this range of the text? | Rotated rectangles, one per piece of a line, on any page and in any writing mode | [Text on the page](https://postext.dev/en/docs/integration-geometry.md) |
| Which offset of the text, which word, which block is under this point? | `caretAt`, `wordAt`, `blockAt` | [Text on the page](https://postext.dev/en/docs/integration-geometry.md) |
| Where is a comment's text now that the author has edited it? | Anchors with context, resolved as exact, moved, ambiguous or orphaned; edits that carry the other anchors along | [Anchors and edits](https://postext.dev/en/docs/integration-anchors.md) |
| How do I draw a highlight, a strike, a replacement, a note? | Marks laid out in the text's own frame, painted on a canvas or written as SVG, found under a point | [Annotation marks](https://postext.dev/en/docs/integration-marks.md) |

The [page viewer](https://postext.dev/en/docs/integration-viewer.md) (`postext-viewer`) puts the
four together: it shows the pages in a scrolling column, reports selections
and presses as Markdown ranges and offsets, paints the marks and gives the
host layers of its own over each page.

## What stays in the host

Postext has no idea of people, roles, states or decisions. There is no
"reviewer", no "pending change", no "approve" button in any of these
packages, and there will not be. A content system already has its own model
of who may do what. It stores its comments and suggestions in its own
database. It decides whether a struck word is a suggestion, an order or a
change already made.

The host maps its records onto what Postext understands:

- a **range** of the Markdown (`{ start, end }`, UTF-16 offsets in the chapter's file, front matter counted);
- an **anchor**, the range with the text it covered and some context on each side, to store beside the record;
- an **annotation**, a range with a kind of mark (`highlight`, `underline`, `strike`, `replace`, `insert`, `note`, `box`), an optional colour, label or text.

Everything else (threads, authors, notifications, accepting a suggestion and
writing it into the Markdown) is the host's code. `applyEdits` writes the
Markdown and moves the other anchors, but deciding to call it belongs to the
host.

## The packages

| Entry | For |
| --- | --- |
| `postext` | `rangeRects`, `caretRect`, `caretAt`, `wordAt`, `blockAt`, `wordRangeAt`, beside `buildDocument`, `renderPage` and `sourceAt` |
| `postext/geometry` | The same, plus the pieces they are built from (line placement, band titles, frame matrices), for a host that paints its own caret |
| `postext/annotate` | `textAnchor`, `resolveAnchor`, `applyEdits`, `mapOffset`, `layoutAnnotations`, `paintAnnotations`, `annotationsSvg`, `annotationAt` |
| `postext-viewer` | `createViewer`, the embeddable viewer; `<PostextViewer>` from `postext-viewer/react` |

```sh
npm install postext postext-viewer
```

All of them run in the browser. `postext/geometry` and `postext/annotate`
also run in Node on a document laid out there (with an `OffscreenCanvas`
such as `@napi-rs/canvas`), for a server that writes page images with their
marks for an e-mail or a PDF of comments.

## Where to start

- To show pages and react to selections, start with the [viewer](https://postext.dev/en/docs/integration-viewer.md). It is the shortest path: one call, a few events.
- To draw on pages your system already shows (PNG files from the [command line](https://postext.dev/en/docs/command-line.md), the HTML renderer, your own canvas), use [Text on the page](https://postext.dev/en/docs/integration-geometry.md) and [Annotation marks](https://postext.dev/en/docs/integration-marks.md), which give SVG to lay over an image.
- To keep comments in place while the text changes, read [Anchors and edits](https://postext.dev/en/docs/integration-anchors.md) before you design your tables: store anchors, not bare offsets.
- To let readers highlight and annotate a book in your reading app or viewer, follow the two worked examples in [Reading apps and other viewers](https://postext.dev/en/docs/integration-readers.md).

The [Cookbook](https://postext.dev/en/cookbook.md) has a part for developers with small runnable
examples of each step, each with its own CodePen.
