RebodocsDocs
Start3
What is Rebodocs
Getting started
Demos to run
Put it in your app8
React component
Headless: your own UI
A complete interface
Without a framework
Only to read: the viewer
Styling and Tailwind
Phones and touch
Accessibility
Documents8
Templates and variables
On a server: DOCX and PDF
Documents in an S3 bucket
Letterheads
Versions
Tracked changes
Fonts
Languages
Together2
Real-time collaboration
AI assistants (MCP)
Reference5
Packages
Components and hooks
Editor API
How it works
Status and roadmap
↑↓ to move↵ to openEsc to close26 pages

Reference Editor API

Editor API

The Editor is what everything else talks to: the toolbar, the hooks, an assistant. Here it is, running, with 216 of its members described below.

tip: press ⌘K and type a method
Start here

Getting the editor

The same object, whichever way you use Rebodocs.

Without React

The editor alone, in an element of yours.

import { Editor } from '@rebodocs/editor';

const editor = new Editor(element);
editor.loadDocx(bytes);

Your own interface

Inside a DocsProvider, from the hook.

const { editor } = useDocs();

editor?.toggleMark('bold');

The whole editor

From the handle of DocsEditor.

const docs = useRef<DocsHandle>(null);
<DocsEditor ref={docs} docx={file} />

docs.current?.editor.find('deposit');

Each call is one step to undo. Methods change the document the way a person would, and ⌘Z takes each back. To change it with the functions of @rebodocs/core, which take a Doc and give another, hand them to edit:

import { fillVariables } from '@rebodocs/core';

// A function of core, on the editor's document, as one step to undo.
editor.edit((doc) => fillVariables(doc, { client: 'Ana López' }));
Live

Try it on a real editor

The sample document in the editor itself, with no toolbar: each button runs the method it shows, and the values under it are read from the editor after each change. Click and type in the page too.

Opening the editor…

Positions are { para, offset }: the index of a paragraph, and of a character in it. Click in the page and watch selection: the anchor is where the selection started, the focus where it ends, so dragging backwards puts the focus first; range gives them in order.

Listening

Knowing when it changes

One listener for everything: onChange is called when the document changes, when the selection moves and when the view does.

To tell them apart, compare editor.doc with the one you had. The document is never changed in place: each change makes a new one, so !== is enough, and costs nothing. The editor above counts both kinds as you use it.

let last = editor.doc;
let timer: ReturnType<typeof setTimeout>;

const stop = editor.onChange(() => {
  if (editor.doc === last) return;     // only the selection or the view moved
  last = editor.doc;                   // a new object: the document changed
  clearTimeout(timer);
  timer = setTimeout(() => save(editor.exportDocx()), 1000);
});

// later, when the editor goes away
stop();

In React, useDocs().state already does this for what a toolbar shows, with state.dirty for “not saved yet”; see hooks. Why a new object each time is cheap is told in how it works.

Reference

Every member, by what it is for

The ones marked “Run it” run on the editor above. The class has a few more, for the collaboration session; its source, packages/editor/src/editor.ts, documents every public member.

Positions and the selection

A Position is { para, offset }: the index of a paragraph, and of a character in it. The selection is an anchor, where it started, and a focus, where it ends.

selection: { anchor: Position, focus: Position }

As made: the focus can come before the anchor.

{ from, to }: the same, in order.

collapsed: boolean

True for a caret, false for a range.

selectedText: string

The text the selection takes in.

setSelection(anchor: Position, focus = anchor)

Selects from anchor to focus; with one position, puts the caret there.

selectAll()
area: EditAreasetArea(area: EditArea, page?, note?)

What is being edited: 'body', 'header', 'footer', 'footnote', 'endnote' or 'textbox'. In a header or footer, positions are those of its own text.

place: { part?, page: number }

Where the selection is: the part, when it is a header or a footer, and the page it is being edited on.

goTo(pos: Position, part?)

Puts the caret at pos and brings it into view: in the text, or in a header, footer or note.

The document

doc: Doc

The document, as an immutable Doc: a new object after each change, so doc !== before says it changed.

load(doc: Doc)loadDocx(bytes: ArrayBuffer | Uint8Array)

Open another document. What could be undone starts over.

exportDocx() → Uint8Array

The document as a DOCX.

exportPdf(title?) → Promise<Uint8Array>

As a PDF, page for page as shown, tagged for screen readers in the language of the text.

exportMarkdown() → string

Its text as Markdown, its tracked changes accepted; as before them while the original is shown.

The browser's print dialog, with the pages.

edit(change: (doc: Doc) => Doc, reveal?: Position)

Changes the document as a whole from outside, as one step to undo.

Does nothingWhen change gives back the same document.

onChange(listener: () => void) → () => void

Called on every change of the document, the selection or the view. Returns how to stop. See “Knowing when it changes”.

pageCount: numbercurrentPage: number

How many pages, and the one the caret is on, from 1.

readOnly: boolean

Set it to only show the document: it can be selected, copied and moved about.

Does nothingWhile it is on, every method that changes the document does nothing, edit() and undo() included. load() and loadDocx() still open another.

restoreVersion(doc: Doc)

Takes the document back to an earlier version of it, as one step to undo. See versions.

Editing

insertText(text: string)insertParagraphBreak()insertPageBreak()

At the caret, over what is selected.

A new line in the same paragraph, as Shift+Enter: insertText splits at each \n, as a paste does.

deleteBackward(byWord = false)deleteForward(byWord = false)

As Backspace and Delete; byWord takes a word at a time.

toggleMark(mark: MarkKey)

'bold', 'italic', 'underline' or 'strike'.

setRunProps(patch: RunProps)

Character formatting of the selection, or of what is typed next.

The paragraphs the selection touches.

activeRunProps() → Required<RunProps>activeParagraphProps() → Required<ParagraphProps>

The formatting at the selection, fully resolved: every field has a value.

setParagraphStyle(id: string)styles: ParagraphStyle[]activeStyleId() → string | undefined

Paragraph styles: Normal, Title, Heading 1…

toggleList(kind: ListKind)shiftListLevel(delta: 1 | -1)shiftIndent(points: number)activeListKind() → ListKind | undefined

Lists, 'bullet' or 'number'. activeListKind is the kind every paragraph of the selection shares, if one.

setListStyle(style: ListStyle)listStyle: ListStyle | undefined

How the labels of the selection's list level are written. Every item of that level changes, as in Word.

restartNumbering()continueNumbering() → boolean

The caret's item and those after it count from 1 again, or go on with the list before of the same kind.

Does nothingcontinueNumbering returns false when there is no list before to go on with.

undo()redo()canUndo: booleancanRedo: boolean

With several people on the document, undo takes back only your own steps.

copy() → Promise<boolean>cut() → Promise<boolean>paste({ plain? }) → Promise<boolean>insertClip(clip) → booleancanPaste: boolean

What is copied goes as text and as HTML, and comes back whole when pasted here; a table goes to Word with its colours, lines and row heights. What comes from Word, Google Docs or a web page keeps its formatting, and its tables their merged cells, widths, colours, lines, row heights and where the text sits in each cell. plain pastes the text alone, looking like the text around it.

Does nothingpaste resolves to false when the browser does not let the page read what was copied: canPaste is false outside HTTPS or this machine, and the browser may ask the person first.

autoformat: boolean

Whether typing # , - or **bold** formats as Markdown would. On by default.

Tables

insertTable(rows: number, columns: number)

Does nothingInside a table, or when canEditTables is false.

insertTableRow(below: boolean)insertTableColumn(right: boolean)deleteTableRow()deleteTableColumn()

Does nothingWhen canEditTables is false.

The whole table the caret is in; for a table inside a cell, only that one.

mergeTableCells()splitTableCell()setTableBorders(on: boolean)tableBorders() → boolean | undefined

tableBorders: whether any cell of the caret's table has borders.

Does nothingmergeTableCells when canMergeCells is false; splitTableCell when canSplitCell is false.

The cells the selection covers: borders, the line they are drawn with, the colour behind them, where the text sits and which way it reads.

setTableRowHeight(points: number, exact = false)setHeaderRow(on: boolean)

The caret's row: its least height, or an exact one, and whether it repeats at the top of each page.

activeCellProps() → { borders, shade, valign, direction, line?, header, height, exact } | undefined

The cell at the caret; undefined outside a table.

inTable: booleancanEditTables: booleancanMergeCells: booleancanSplitCell: boolean

What a toolbar enables. canEditTables is false in a table a header or footer came with from its file: its cells can be written in, but its shape is kept.

Pictures, links, notes, changes

insertImageFile(file: Blob) → Promise<boolean>insertImageGrid(files: Blob[], columns: number) → Promise<number>

A picture at the size it has at 96 pixels to the inch, made smaller if it does not fit; a grid resolves to how many went in.

Does nothingResolves to false for a file that is not a PNG, JPEG or GIF, or does not read as one.

insertImage(bytes: Uint8Array, type: string, width: number, height: number)

A picture from its bytes, width by height points, made smaller if it does not fit the page.

setPictureWrap(wrap: PictureWrap)pictureWrap: PictureWrap | undefinedfitSelectedPicture(fraction: number)pictureSelected: boolean

How the selected picture sits in the text: 'inline', 'square', 'topBottom', 'none' (under the text) or 'behind'.

pictureDescription: string | undefinedsetPictureDescription(text: string)

What the selected picture shows, for whoever cannot see it, as Word keeps it ("Alt Text"): what a screen reader says of it. An empty one takes it away.

addNote(text: string) → string | undefinedsetNoteText(id, text)removeNote(id)removeAllNotes()notes: NoteView[]activeNote: string | undefinedselectNote(id) → boolean

Comments, as Word has them. addNote puts one on the selected text, or on the word the caret is in, and returns its id.

Does nothingaddNote returns undefined outside the text of the document, or with the caret on no word.

author: stringnoteColor: stringsetNoteColor(id, color)

Who the notes and changes made here are by, and the colour notes are marked with: one of NOTE_COLORS.

trackChanges: booleansetTrackChanges(on: boolean)revisions: RevisionView[]hasRevisions: booleanactiveRevision: RevisionView | undefined

Tracked changes, as Word's (⌘⇧E / Ctrl+Shift+E).

restricted: booleansetRestricted(on: boolean)editableRanges: EditableRange[]activeEditable: string | undefined

A document restricted to its areas to fill in, as Word's Restrict editing: only they can be changed, the rest is read, copied and noted on. Said in the file; not a step to undo.

makeEditable() → string | undefinedremoveEditable(id?)nextEditable(dir?: 1 | -1) → boolean

Makes the selection an area to fill in, or the caret an empty one, and returns its id; takes one away, its text staying; selects what the next area holds, going round, as Tab does while restricted.

Does nothingmakeEditable and removeEditable do nothing while the document is restricted; nextEditable returns false with no areas.

onRefused: (() => void) | undefined

Called when a change is not made, the document being restricted and the change outside its areas: for an interface to say so. Changes asked from code are refused the same.

acceptRevision(revision?) → booleanrejectRevision(revision?) → booleanacceptAllRevisions(author?)rejectAllRevisions(author?)goToRevision(dir: 1 | -1) → booleanselectRevision(revision)

Does nothingThe ones that return a boolean return false when there is no change there to take.

changesView: 'all' | 'accepted' | 'original'setChangesView(view)

The changes marked, or the document as it would be with all of them accepted, or with none; shown without them, it is only to be looked at.

Headings, columns and sections

outline: OutlineItem[]activeHeading: numbergoToHeading(para: number)

The headings, which one the caret is under (-1 before the first), and going to one.

moveSection(from: number, before?: number)

Moves the section a heading opens to just before the paragraph before, or to the end.

insertToc()updateToc() → booleanhasToc: booleangoToToc() → boolean

A table of contents. Saving, exporting and printing bring it up to date by themselves.

Does nothinginsertToc when there is one already, in a table, or outside the text of the document. updateToc returns false when nothing changed.

columns: ColumnssetColumns(columns: Columns)

The columns of the caret’s section. With a selection, the selected text alone becomes a section of its own on the same page.

Does nothingIn a header, footer, note or text box: only in the text of the document.

What follows the caret starts at the top of the next column.

Does nothingIn a table, or in a header, footer, note or text box.

insertSectionBreak(start: 'nextPage' | 'continuous' = 'nextPage')

A new section at the caret, as Word’s: what follows can have another orientation, other margins, columns or a header of its own.

Does nothingIn a table, or in a header, footer, note or text box.

insertTextBox(text?) → string | undefinedtextBoxes: { id, text }[]

A text box anchored to the caret's paragraph, the text going round it. Inside it, area is 'textbox'.

Does nothingIn a header, footer, note or text box, where it returns undefined.

insertFootnote(text?)footnotes: { id, number, text }[]

A note at the foot of the page (⌘⌥F / Ctrl+Alt+F). Inside it, area is 'footnote'.

Does nothingIn a header, footer, note or text box: only in the text of the document.

insertEndnote(text?)endnotes: { id, number, label, text }[]

A note at the end of the document, or of its section when the file puts them there, numbered i, ii, iii (⌘⌥D / Ctrl+Alt+D). Inside it, area is 'endnote'.

Does nothingIn a header, footer, note or text box: only in the text of the document.

Templates

Variables are written {{name}} in the text, with formats after a bar: {{amount | currency}}.

blocks: Block[]

The blocks of the template, {{#name}} … {{/name}}: repeated for each item of a list, or kept only when a value is there.

variables: string[]

The names of the variables in the document.

insertVariable(name: string)selectVariable(name: string) → booleanactiveVariable: string | undefined

selectVariable goes to the next place it is used after the caret, into a header, a footer, a note or a text box when it is there.

Does nothingselectVariable returns false for a variable the document does not use.

fillVariables(values: Record<string, string>)

Replaces them everywhere, as one step to undo; while changes are tracked, as changes.

formatLocale: string

The language variables are written in — dates, amounts, capitals: the language of the text, with the browser’s region (en-US, es-MX). fillVariables writes in it.

variableUses(name: string) → number

How many times one is used, headers, footers, notes and text boxes included.

variableNotes(name: string) → string[]

What the notes on it say, on the variable or on a part of it: in a template, what to fill it with. The panel shows them under its box.

variableFormats(name: string) → ActiveFormat[]setVariableFormat(name, id: FormatId, on: boolean, arg?)

The formats every use of a variable has — capitals, bold, how a date or number is written — and giving or taking one away, as one step to undo.

insertSignatures(titles: string[])

A block of signature lines.

Does nothingInside a table, or when canEditTables is false.

The page

page: PageSetupsetPage(patch: Partial<PageSetup>, everywhere = false)

Size and margins, in points, of the section being edited; with everywhere, of every section. See “Points” below.

sectionCount: numbersectionIndex: numbersectionPages() → PageSetup[]setSectionPages(pages: PageSetup[])

The sections, the one being edited (from 0), and the page of each.

Does nothingsetSectionPages when there are not as many pages as sections.

ownHeaders: booleansetOwnHeaders(on: boolean)

Whether a section before the last has a header and footer of its own; without, it shows the last section's.

pageNumbering: PageNumbering | undefinedsetPageNumbering(numbering: PageNumbering | undefined)
firstPageDifferent: booleansetFirstPageDifferent(on: boolean)

A header and footer of its own for the first page of the section.

endnotesAt: 'document' | 'sections'setEndnotesAt(at: 'document' | 'sections')

Whether the endnotes go after the last line of the document or after that of each section.

noteNumbering(kind: 'footnote' | 'endnote'): NoteNumbering | undefinedsetNoteNumbering(kind: 'footnote' | 'endnote', numbering: NoteNumbering | undefined)

How the section numbers its notes: format, the number it starts at, and whether the count starts again in it, or on each page for footnotes. Undefined for 1, 2, 3 and i, ii, iii, going on from the section before.

hasLetterhead: booleanletterhead: { bytes, type } | undefinedsetLetterheadFile(file: Blob, fit = true) → Promise<boolean>setLetterhead(bytes, type)fitLetterheadMargins() → Promise<boolean>removeLetterhead()

A picture over the whole page. With fit, the top and bottom margins grow to clear what it prints there. See letterheads.

Does nothingThe promises resolve to false for a file that is not a picture, or when there was nothing to change.

language: string | undefined

The language the text is in, as a tag ('es-MX'), written in the DOCX it makes when the file does not say one: the interface's language, with its region, when not set.

textLanguage: stringsetTextLanguage(tag: string)

The language of the text as it is used: the one a person chose at the foot of the editor (setTextLanguage, which goes into the DOCX over what the file said), else language, else the one the file says, else the interface’s when the document was opened. It does not follow the interface after that: the two are apart. A screen reader reads the text in it, and variables are written in it.

embedFonts: boolean | 'subset'

Whether a DOCX made here carries the fonts the application gave whose licence lets them be embedded: whole by default, cut down to the characters used with 'subset'.

Finding

find(query: string, options?: FindOptions) → number

Marks every place it is found in the text the selection is in, and returns how many; an empty query stops the search. findStep selects them.

findStep(dir: 1 | -1) → booleanfindCount: numberfindIndex: number

To the next or previous one, going round at the ends; how many there are, and which is selected, from 1.

Does nothingfindStep returns false when nothing was found.

replaceFound(text: string) → booleanreplaceAllFound(text: string) → number

The selected one, then on to the next; or all of them as one step to undo, returning how many.

Does nothingreplaceFound returns false, and only goes to the next, when none is selected.

Spelling

Words are asked about only on the pages near the view, a moment after typing stops, in the language of the text. See spelling.

spellChecker: SpellChecker | undefined

What says which words are spelled wrong: createSpellChecker({ dictionaries }), or one of your own with check and suggest. None, and nothing is marked.

misspelling: { word, range } | undefined

The word spelled wrong the caret is in, or at the end of; undefined while the dictionary has not said.

spellingSuggestions() → Promise<string[]>

What that word could be instead, the likeliest first.

replaceMisspelling(text: string)

Puts text in its place, as any edit: undone with ⌘Z, tracked when changes are.

ignoreMisspelling()addMisspelling()canAddWords: boolean

Leaves the word, and every one like it, unmarked in this document; or gives it to the dictionary, when it takes new words.

onSpellingMenu: (() => void) | undefined

Called when a word with the wave is pressed with the other button or tapped: the caret is in it, for a bar to offer its suggestions.

onMenu: (() => void) | undefined

Called when the pages are pressed with the other button anywhere else, in place of the browser's menu: the caret is there, or the selection stays if pressed inside it. The bubble offers copy, cut and paste there.

The view

The view is the editor’s, not the document’s: it is not saved in the file.

zoom: numbersetZoom(zoom: number)

0.25 to 4. At 1, a point is 4/3 of a CSS pixel. setZoom stops fit.

fit: ZoomFit | undefinedsetFit(fit: 'width' | 'page')

A zoom that follows the size of the window.

view: ViewModesetView(view: 'column' | 'spread' | 'grid' | 'flow')

One page, two across, a grid, or text as wide as the window.

showNotes: booleansetShowNotes(on: boolean)

Comments in a margin beside the pages.

Gives the keyboard to the document.

theme: 'light' | 'dark' | 'auto'

The colours of the interface around the pages, and of the bars and menus made for this editor, also those shown outside it. The pages stay white.

screenReader: boolean

Screen reader mode: the hidden field holds the caret’s paragraph. Off by default; ⌘⌥Z (Ctrl+Alt+Z) turns it on and off.

announce(text: string, urgent = false)

Says text to a screen reader, through the editor’s live region.

element: HTMLElement

The element the pages scroll in.

Takes everything away.

For a collaboration of your own

What @rebodocs/collab asks of an editor (CollabHost), which the Editor is: for wiring it to a server of your own, as the room on the Real-time collaboration page does.

replace(doc: Doc, selection: Selection, reveal?: boolean)

Shows the document as someone else left it: not a step to undo, and what is on the screen stays where it is unless reveal.

commits: numbersteps: number

How many changes the person made here, and how many of them were steps of their own to undo: a change is theirs when commits moved after it, and a new step when steps did too.

history: { undo(), redo(), canUndo, canRedo } | undefined

Who undoes in place of the editor: with several people, ⌘Z must take back only what this person did. While it is set, undo, redo, canUndo and canRedo are its.

Draws where the others are: the caret and selection of each, with its name and colour, in the text or in the header or footer they are in.

For your own interface

What a bar beside the selection, a menu or a touch interface of your own needs.

selectionBounds() → DOMRect | undefined

Where the selection is in the window: the selected text or picture, or the caret.

pageBounds(page?: number) → DOMRect

Where a page is in the window, at the size the zoom shows it; the caret’s unless another is asked for.

textColumn() → { left, right }

The edges, in points from the left of the page, of the column the caret’s paragraph is set in: the margins, or the inside of its table cell.

True when the caret is in a paragraph with nothing in it.

onLinkKey: (() => void) | undefined

What ⌘K does, when given: asking for the address of a link is for whoever shows the editor.

byTouch: booleanonTouchSelect: (() => void) | undefined

True from a touch until the mouse is used; called when a selection was made by touch.

pagesOf(doc: Doc) → (para: number) => number

The page each paragraph of a document would start on, from 1, laid out as this editor lays out.

layoutOf(doc: Doc) → Layout

A document laid out in pages as this editor lays out: the one it shows, for the document it has open. The assistant reads its pages with it (read_pages).

Reference

Types

What the methods take, as @rebodocs/core defines them; @rebodocs/react exports them as types too. A field whose name ends in ? may be left out.

PeerCareteditor/src/editor.ts

Someone else on the document, as setPeers draws them.

namestring
Shown beside their caret.
colorstring
Hex RGB without #.
part?StoryPart
The header or footer they are in; the text when there is none.
pagenumber
The page they are editing it on.
anchorPosition
focusPosition
Their selection: where it started and where it ends.

Positioncore/src/model.ts

A place in the text being edited. Range is { from, to }, in order.

paranumber
Index of the paragraph, from 0.
offsetnumber
Index of the character in it, from 0.

RunPropscore/src/model.ts

The formatting of characters. A patch sets only the fields it has.

bold?, italic?, underline?, strike?boolean
fontSize?number
In points.
fontFamily?string
color?string
Hex RGB without '#': 'C0392B'.
highlight?string
Hex RGB without '#'. Word has only the colours of HIGHLIGHT_COLORS.

ParagraphPropscore/src/model.ts

The formatting of paragraphs. Lengths in points.

align?'left' | 'center' | 'right' | 'justify'
spacingBefore?, spacingAfter?number
lineHeight?number
A multiplier over the natural height of the line: 1.15, 2.
indentLeft?, indentRight?number
indentFirstLine?number
Added to indentLeft on the first line; negative for a hanging indent.
pageBreakBefore?, keepNext?, keepLines?boolean
widowControl?boolean
On unless switched off, as in Word.
styleId?string
Better set with setParagraphStyle.
tabs?TabStop[]
{ pos, align: 'left' | 'center' | 'right' | 'decimal' | 'bar', leader? }.

PageSetupcore/src/model.ts

The page of a section, in points. A new document is Letter with 1-inch margins.

width, heightnumber
Landscape is a width larger than the height.
marginTop, marginRight, marginBottom, marginLeftnumber
headerDistance?, footerDistance?number
From the edge of the page to the header, and to the footer.

Columnscore/src/model.ts

How the text of a section is set in columns, as in a newspaper.

countnumber
1 when the text runs the whole width.
spacenumber
Room between two columns, in points.
widths?{ width, space }[]
When they are not all as wide.
separator?boolean
A line down the middle of the room between two.

CellPatchcore/src/tables.ts

What can be set on the cells the selection covers.

borders?boolean
line?Border | null
{ width, color, style: 'single' | 'double' | 'dashed' | 'dotted' }; null for the plain line.
shade?string
The colour behind, hex RGB without '#'.
valign?'top' | 'center' | 'bottom'
direction?'level' | 'up' | 'down'
Which way the text reads.

ListStylecore/src/ops.ts

How the labels of a list level are written, with # where the number goes: { format: 'lowerLetter', text: '#.-' } is “a.-”.

format'decimal' | 'decimalZero' | 'lowerLetter' | 'upperLetter' | 'lowerRoman' | 'upperRoman' | 'bullet' | 'none'
textstring
The label around #, or a bullet's character: '–'.

PageNumberingcore/src/pageNumbers.ts

A page number in the header or the footer.

place'header' | 'footer'
align'left' | 'center' | 'right'
format'number' | 'numberOfTotal' | 'page' | 'pageOfTotal'
“3”, “3 / 9”, “Page 3”, “Page 3 of 9”.
words?{ page, of }
The word before the number and the one before the total. setPageNumbering gives those of the editor’s language unless these are given.

FindOptionscore/src/find.ts

How find looks.

matchCase?boolean
Capitals and small letters count as different.
wholeWord?boolean
Only matches that are not part of a longer word.
Good to know

Points

Every length is in points, 1/72 of an inch, as in Word: page sizes, margins, indents, font sizes, row heights. Type a length in what you have, and set a page on the editor above.

Any length

points
70.87
inches
0.98
centimetres
2.5
millimetres
25
CSS pixels at zoom 1
94.49

In code, always the points: { indentLeft: 70.87 }

A page

PageSetup, in points

width × height595.3 × 841.9
each margin70.87
text area453.56 × 700.16
A4 · 595.3 × 841.9 pt

On screen at zoom 1, a point is 4/3 of a CSS pixel, so a picture put in from a file comes in at its size at 96 pixels to the inch: 800 pixels wide is 600 points, made smaller when it does not fit the page.