Log InGet OrdStyle

Command Line & Automation

Rendering, exporting and running a server all work from a command line, with no window. That is what makes it scriptable: render a nightly report, run a document through a build, host a server as a service, add a user from a provisioning script.

This page covers the command line, the URL scheme, the file formats, and the one place you can plug your own code in.

Command line

ordstyle [options] [file]

Rendering

Option Effect
--pdf Generate a PDF and exit
--html Generate HTML and exit
--fodt Generate a flat OpenDocument file, which LibreOffice Writer opens
--section <spec> Render only that section, e.g. 1 or 1.2
--html-assets <dir> Write images to a folder instead of inlining them
--fodt-static-toc Write the contents page as fixed text. By default it is one Writer can regenerate
--redgreen Tint the margins of a --pdf render, as the Color Margins view does. HTML and FODT output is never tinted
--allow-scripts Run every Python script the document names, not only the approved ones
--kde-syntax Use the KDE syntax definitions for code highlighting

A style set name can follow the filename. Without one, the set named STYLE is used, or the first set if there is none by that name:

ordstyle --pdf report.ord              # → report.STYLE.pdf
ordstyle --pdf report.ord SLIDES       # → report.SLIDES.pdf
ordstyle --html report.ord DARK        # → report.DARK.html

The output is named after the style set, which is why the first line gives report.STYLE.pdf rather than report.pdf — STYLE is the name of the set most documents start with.

To render with the styles of a different document, give that file before the set name: ordstyle --pdf report.ord house.ord PRINT takes the PRINT set from house.ord and writes report.PRINT.pdf. The set name is optional here too, and report.ord’s own styles are not used. Pictures the style names by a relative path, such as a background image, are looked for beside report.ord.

None of these open a window, so they run under cron, in a container, or over SSH. On a Linux machine with no display, set QT_QPA_PLATFORM=offscreen first:

QT_QPA_PLATFORM=offscreen ordstyle --pdf report.ord

Server

Option Effect
-s, --server Run the collaboration server with no GUI
--port <n> Port to listen on. 0 picks a free one and prints it
--server-debug Verbose logging. May include user names and document paths
--lock-timeout <seconds> Reclaim a settings lock held longer than this when someone else needs it. Default 600; 0 never reclaims
--adduser "user:pass:perm" Create an account and exit. perm is the admin permission bits — 511 for all of them
--test-doc [text] Ephemeral mode: no database, any password accepted. For testing only
--demo <script.demo> Scripted collaborators join a server and act out the script. --check tests the script without acting, --save "NAME" saves the result as a version, --reset restores the script’s starting version

See Server Setup for what the server keeps in its data folder.

The data folder

Documents, their history, chats and a server’s database all live in one data folder, Documents/OrdStyle in your home folder unless one of these says otherwise. The first that applies wins:

Setting Effect
--data-dir <dir> Use this folder, for this run
ORD_DATA_DIR The same, as an environment variable
An ordstyle.portable file beside the program A portable copy: the program’s own folder is the data folder, so it travels with the program
Settings > Connection Settings > Data folder Your choice, used from the next start

The program never writes to the folder it is installed in, unless it is a portable copy.

Diagnostics

Option Effect
-h, --help Print every option, including the test flags not listed here
-d, --debug <0-3> Debug verbosity
-o, --output <file> Output file for a single test run
-bench-highlight <file> Benchmark syntax highlighting on a document
-loadtest Simulate many concurrent users against a server, with -n clients for -t seconds
-genhistory <out.ord> Synthesize a document with simulated editing history

There is also a family of -test-* flags — merge, diff, operational transformation, formulas, style cascade, serialization round-trips, and more. They are the project’s own test suite rather than a public interface, but --help lists them all and they are useful when reporting a problem.

URL scheme

ord://host[:port]/Plans/q3.ord     a document on a server (a #Section may follow)
ord://host[:port]/localshare       a local share — the invite link
ord://host[:port]                  the server itself; opens the File Navigator

Give one of these in place of a filename and the program starts, connects, and goes there. The port may be left out; it then means 8642. The same links work inside a document, where they are clickable, and in Collaboration > Open Link…. Put one in a wiki, a calendar invitation or a chat message and it does the right thing.

File formats

The document: .ord

A UTF-8 text file. It opens in any editor, diffs cleanly, and belongs in version control alongside your code. The structure is:

A short header comes first, then the document body — the words you typed, as you typed them. The header holds:

Section Holds
Users The color assigned to each person who has worked on the document
Comments Comments and suggestions, one per line
Chats The document’s chat, one message per line
History The undo history, as JSON Lines
Styles One section per style set

Every section is optional, and the program writes all of them for you — the styles from File > Settings, the rest as you work. There is no reason to edit the header by hand, and this page does not describe how; see Style Properties for the Settings controls that produce it.

What matters for integration is that all of it is text. The history in particular is JSON Lines rather than an opaque blob, so a document’s whole editing record is readable, greppable and diffable. How much is kept is a setting on the Editor Themes page; zero turns persistence off entirely.

Companion files

File What it is
doc.pdf, doc.STYLE2.pdf Rendered output, named after the style set
doc.ord.lock Held while a document is open, so two copies of the program do not fight over it. Goes stale after a day
doc.<timestamp>.ord A saved version snapshot
<host>_<doc>_<time>.ordcheckout An offline checkout: the document, its history, its comments and its styles, plus everything you change while away
<file>.checkin-residue Written only if a check-in could not merge something. It holds what was dropped, so nothing is ever lost silently
<pdf>.dat Slide annotations, per page
<name>.ini Your editor themes, written by Save Theme and read back by Open Theme. Yours, not the document’s

Data folder files

File What it is
server.db SQLite: users, groups, permissions, folders, document records
docs/ The documents, in the folder tree the File Navigator shows
local.db Saved versions and document links on this computer
checkouts/ Documents checked out for offline editing
server-local.crt, server-local.key This computer’s own TLS certificate and key, made on first use
audit.log Administrative actions
groupchats.dat Group chat history
server-files.lock Held while the server runs, so nothing else writes the same store

Running your own code: Python blocks

This is the extension point. A Python block runs a script while the document is being rendered and puts its output in the page.

![Caption](script.py){width=40% align=center}
input data line 1
input data line 2
~~~

The lines between the opener and the ~~~ terminator are handed to the script on standard input. The script writes a PNG or an SVG to standard output, and that is what appears in the document. The opener takes the same attributes as any picture: width, height, scale, align, wrap, margin, border.

So a chart from a live database, a plot from a data file, a diagram generated from your source code — anything you can produce with a script — is a figure in the document that regenerates every time you render.

width=auto runs the script once to measure the result, then caches it, so measurement does not cost a second run.

A script runs only once it is approved on this computer (File > Review Scripts…), or when the render is given --allow-scripts. An unapproved script is not run: the page shows a “Script not run” note where its figure would be, and the render still exits 0. So a scheduled render will not run a script nobody approved — approve it once in the program, or add --allow-scripts to the job if you trust every script the document can name.

Embedding other documents

The picture syntax with an .ord file pulls in the whole file, or one section of it:

![](appendix.ord)
![](handbook.ord#Safety)

This is how a large document is assembled from parts that people own separately: each contributor keeps their own file, and the master document embeds them.

The network protocol

Clients and servers speak a binary protocol over TLS. Each packet is a size, a type, and a payload. More than 150 packet types cover authentication, document transfer, real-time editing, locking, comments, chat, presence, versions, permissions and file management.

Concurrent editing is decided by identity rather than by position. Every character carries a permanent id, and an edit says what it means in those terms — “put these characters after that one”. The server resolves concurrent edits under one written set of rules, keeps a version number per document, and sends every client the same answer, which each applies by id. Moves are a first-class operation rather than a delete plus an insert, which is what lets an edit made inside a moved passage survive the move.

The protocol is documented in full in network.md, ot-system.md and otPaths.md in the source distribution. It is not a stable public interface — it changes with the software — so if you want to integrate with the program, prefer the file formats and the command line, both of which are stable.

Exit behavior

A headless render returns 0 on success and non-zero when it fails — a missing input file exits 1 — so it behaves properly in a shell script or a build.

ordstyle --pdf report.ord || echo "render failed"

Giving no filename at all prints Need filename and exits 0, so pass the file explicitly rather than relying on the exit code to catch a missing argument.

See also