How it works
CloudPDF serves PDF pages and document data over HTTP. Your backend decides which documents a user can open and what they can do with them.
The big picture#
CloudPDF signs(shared secret, HS256)
Your backend calls the issue token API. CloudPDF signs and returns the JWT.
or
Your backend signs(public-key verification)
Your backend signs with its private key. CloudPDF verifies with the matching public key.
Your backend gives the browser a short-lived document JWT.
CloudPDF checks the JWT’s signature, document ID, and permissions before serving the request.
The bundled npm and Docker server use HS256 with CLOUDPDF_JWT_SECRET. To use a
public key or a JWKS URL, set verifier in buildApp in a custom Node deployment.
See Signing modes.
The HTTP API#
The Fastify server exposes these routes.
| Routes | Auth | Purpose |
|---|---|---|
/v1/docs/* | Document JWT in the browser | Render pages, extract text, work with annotations and metadata, and unlock encrypted PDFs. |
/v1/tenants/* | API token or tenant JWT with the required scope | Create documents, upload files, and manage tokens from your backend. The issue token API is available in HS256 mode. |
/healthz, /readyz | None | Liveness and readiness probes. |
See API authentication for accepted credentials and the permissions each can carry.
The native worker pool#
PDFium is a native C++ library. The server runs it inside a pool of Node
worker_threads so that CPU-heavy rendering never blocks the HTTP event loop and
several requests can render in parallel.
The pool size is controlled by
CLOUDPDF_WORKER_POOL_SIZE. The
default is conservative — min(2, cpu count) — and you raise it as you give the
process more cores and memory.
Native code parsing hostile PDFs will eventually crash. Two layers keep that
survivable: set CLOUDPDF_ENGINE_ISOLATION=host so a crash costs
a sub-second engine respawn inside the instance (documents
that repeatedly crash the engine are quarantined automatically), and run
multiple replicas so even an instance restart never means
zero capacity. See
Health & scaling.
Storage: database + object store#
The server separates metadata from bytes:
- Database — document records, annotations, tokens, and the audit log. Use SQLite (a single file, zero setup) to start, or Postgres for multi-replica production. See Database.
- Object store — the actual PDF bytes and rendered artifacts. Use the local filesystem for a single host, or S3 / GCS / Azure Blob for durable, shared storage. See Storage.
- Cache — a local directory of recently used documents and renders so repeat requests are fast. It is disposable; the server rebuilds it from the object store.
This split is what lets the same binary run as a zero-config single file and as a horizontally-scaled cluster — you only change configuration.
The smallest possible setup — SQLite + local disk + local cache — needs no external services at all. That is exactly what the Quick start uses.
Twelve-factor by design#
Everything is configured through CLOUDPDF_* environment variables, the
process logs to stdout, and state lives in the database, object store, and
cache — never in the container. That is what makes the same image safe to run as
one container or fifty pods.