Skip to content

Repository files navigation

docmost-export

DOCX and PDF export for Docmost, as a small service that runs beside Docmost rather than inside it.

Docmost's own DOCX and PDF export are commercial features. This is an independent implementation built on the public API of the community edition: it asks Docmost for the HTML export it already produces, then converts that locally with pandoc (DOCX) and WeasyPrint (PDF).

No Docmost code is copied, no license check is bypassed, and Docmost itself is never modified — so docker compose pull keeps working and there is no fork to maintain.

The converter: a form taking a Docmost page URL, a choice of DOCX or PDF, and bookmarklets for one-click export

If the paid features fit your situation, buying a license is the simpler answer and supports the people who build Docmost. This exists for those who need two formats and not a subscription.


How it works

Diagram: the browser reaches a reverse proxy, which serves Docmost unchanged and the converter on the same origin behind a password. On export the converter resolves the page slug to a UUID, asks Docmost for HTML plus attachments, injects a print stylesheet, then renders with pandoc or WeasyPrint.

What it does

  • Single page, optionally with its subpages (returned as a ZIP)
  • A whole space, one file per page in a ZIP
  • Attachments included — images are fetched with the page and embedded
  • Buttons inside Docmost's UI, added by one <script> tag your reverse proxy injects; no browser extension, nothing installed per user
  • A bookmarklet, if you would rather not touch your proxy at all
  • Diagnostics for when an export misbehaves, so a bug report can be specific
  • English and Polish UI, LANG_UI=en|pl

Requirements

  • Docmost you can reach over HTTP(S)
  • An API key from Docmost (Settings → API keys), or an account without MFA
  • Docker with Compose v2

Install

git clone https://github.com/mrtipeq/docmost-export.git
cd docmost-export
sudo bash scripts/install.sh          # creates .env, then stops
$EDITOR .env                          # DOCMOST_URL + DOCMOST_API_KEY
sudo bash scripts/install.sh          # builds and starts

Open http://127.0.0.1:8091, paste a page URL, pick a format.

Optional, so it returns after a reboot:

sudo bash scripts/install-boot.sh

Security

The service authenticates to Docmost with a key that can read every page that account can see. Treat it as a credential store:

  • it binds to 127.0.0.1 by default — do not change that to 0.0.0.0
  • publish it, if at all, through your reverse proxy with authentication
  • .env is created 0640, owned by root

Buttons inside Docmost

Your reverse proxy serves the converter on the same origin as Docmost and adds one script tag to the HTML it already proxies. Snippets for Apache, nginx and Caddy.

Same origin matters: an HTTPS page cannot load an HTTP script, and a separate host would need CORS. Serving the converter under a path such as /_export/ avoids both.

inject.js is deliberately served without authentication — it contains no secrets, and a password prompt on a <script> load would only stop the buttons appearing.

A Docmost page with PDF and DOCX buttons in the bottom right corner, added without modifying Docmost

Prefer not to touch your proxy? The converter page offers bookmarklets: drag one to your bookmarks bar and it opens the converter prefilled from whatever Docmost page you are on.

Configuration

Variable Default Meaning
DOCMOST_URL Where Docmost's API lives
DOCMOST_API_KEY Preferred credential; revocable from the Docmost UI
DOCMOST_EMAIL / DOCMOST_PASSWORD Fallback; the account must not have MFA
BIND_ADDR / BIND_PORT 127.0.0.1 / 8091 Where the container publishes
ROOT_PATH / PUBLIC_BASE empty Set both (e.g. /_export) when proxied under a path
LANG_UI en en or pl; add a file in app/locales/ for more
PAGE_SIZE / PAGE_MARGIN A4 / 18mm 16mm PDF page setup
REQUEST_TIMEOUT 120 Seconds allowed for a Docmost call

Known limits

  • Draw.io and Excalidraw diagrams export as whatever image Docmost puts in the HTML
  • Mermaid blocks may come through as code rather than a rendered diagram
  • Video is replaced with a labelled placeholder — paper cannot play it
  • DOCX layout is pandoc's default; a house style needs a --reference-doc

Troubleshooting

See docs/TROUBLESHOOTING.md. The short version: /diag?page=<url> reports what Docmost answers for every combination of export options, and the "do not convert" checkbox shows exactly which images arrived and whether they resolve.

Working on Windows

The repository pins LF line endings via .gitattributes, because the shell scripts run on a Linux host and a CRLF shebang fails there with bad interpreter: /bin/bash^M. Nothing to configure; just do not "fix" the endings in an editor.

Contributing

Translations are the easiest way in: copy app/locales/en.json, translate the values, and CI will tell you if a key is missing. Bug reports are far more useful with the output of /diag?page=<url> or the image diagnostics attached.

License

MIT — see LICENSE. Docmost itself is a separate project under its own licenses; this repository contains none of its code.

About

DOCX and PDF export for Docmost — runs beside it, no fork, no license bypass

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages