PDF tools you host yourself. Files never leave your machine or your Cloudflare account.
ream is a small web app for everyday PDF chores. A Go server runs proven
command line tools (qpdf, pdfcpu, ghostscript, img2pdf, poppler,
libreoffice) behind an Astro UI. It holds no state: each request works in its
own temporary folder, which is deleted when the response is sent. When idle it
uses nothing, on a server or on Cloudflare.
The grids support drag to reorder, typed page ranges, and click to preview. Running a tool shows its result on the page, ezgif-style: the file's name and size, Save, Preview, and a "Continue with" row that hands a PDF result straight to the next tool (compress, then reorder, then split, and so on). The file rides in IndexedDB across the page load and never goes back to the server.
Runs on Cloudflare Containers, which needs the Workers Paid plan ($5 a month). Personal use stays within the plan's included container time.
- Click Deploy to Cloudflare above. Cloudflare copies this repository into
your GitHub account, builds the container image and deploys the Worker. It
asks for
REAM_ACCESS_TEAM_DOMAINandREAM_ACCESS_AUD: enter your team domain (Zero Trust > Settings > Team domain, likeyourteam.cloudflareaccess.com) and any placeholder for the AUD for now. - Put Cloudflare Access in front of the Worker: Workers & Pages > your Worker
Settings > Domains & Routes, turn on Access for
workers.dev(or add a custom domain with its own Access application), and allow your email. - Copy that Access application's Application Audience (AUD) Tag (Zero Trust >
Access > Applications, open it) into the Worker's
REAM_ACCESS_AUDsecret (Worker > Settings > Variables and Secrets).
Until Access is set up, ream answers every request with 403: the Worker checks the Access token itself, so a forgotten setting fails closed instead of opening LibreOffice to the internet.
- Uploads: Cloudflare caps a request body at 100 MB, so the UI sends each file in 64 MiB pieces first. A file can be up to 2 GiB.
- Cold start: after 5 idle minutes the container sleeps; the next request waits a few seconds for it to start.
- One instance: every request goes to the same container, so all pieces of an upload land on the same disk.
nix run github:xav-ie/ream # http://127.0.0.1:8086
docker build -t ream . && docker run -p 127.0.0.1:8086:8086 reamThe Nix package wraps every tool onto PATH, so it needs no other setup. On a
host, run it under a systemd socket unit: ream adopts the socket
(LISTEN_FDS), starts on the first request and exits after 5 idle minutes.
Without socket activation it binds $REAM_HOST:--port (default
127.0.0.1:8086). There is no login, so put it behind something that has one.
nix develop # Go, Node, pnpm and every CLI (or: direnv allow)
cd frontend && pnpm install && pnpm build # emits frontend/dist
cd .. && REAM_WEBROOT=frontend/dist go run . # http://localhost:8086cd frontend && pnpm dev runs the Astro dev server for UI work. pnpm install
at the root installs the Worker's tooling; pnpm exec wrangler dev runs the
Worker and container locally, which needs Docker or Podman (the dev shell
routes Podman through scripts/podman-docker, which drops the buildx flags
Podman rejects).
Deploy through a release (see Releases) or from a machine with
Docker. pnpm run deploy under Podman builds the image but fails to start it:
Podman recompresses the layers on push, so the registry holds a different
digest than the one wrangler recorded (IMAGE_REGISTRY_DOESNT_CONTAIN_IMAGE).
nix flake check # go vet + go test against the real CLIs, the package build, formatting
cd frontend && pnpm check # eslint, knip, astro check, prettier, fallow
pnpm check:types && pnpm test # the Worker and its Access checknix fmt formats Nix, Go and the root files; the frontend keeps its own
prettier (pnpm format) for the Astro plugin. Run pnpm types after changing
wrangler.jsonc.
- Server:
main.go, standard library only.POST /api/<tool>takes a multipart upload, runs the tool with a 3 minute timeout, and streams the result back. - Chunked uploads:
PUT /api/upload/<id>?offset=Nwrites one piece of a file at its offset; the tool request then names it as<id>/<filename>. Uploads are single use. Plain multipart files still work. - Cloudflare:
src/worker.tschecks the Access token and forwards the request to oneReamcontainer (standard-1: ½ vCPU, 4 GiB). TheDockerfilebuildspackage.nixwith Nix and copies only its runtime closure into an empty image, so the container runs exactly whatnix buildproduces. - LibreOffice:
libreoffice-headless.nixcopies nixpkgs' prebuilt LibreOffice and deletes what--convert-tonever loads (help, other languages, GTK, GStreamer, Java, Python), which also drops those dependencies: the closure goes from ~2.8 GB to ~900 MB without compiling anything. - Image layers: Cloudflare's runtime refuses to unpack a single layer that
holds all of LibreOffice, though the same files over several layers start
fine. The
Dockerfilespreads any store path over 256 MB across four layers and the rest of the closure over 32.
Each user facing change adds a note with pnpm changeset. Every push to
main keeps one "chore: version packages" PR up to date with the next version
and its changelog; merging it tags v<version>, publishes a GitHub release and
deploys the Worker (when the repository has the CLOUDFLARE_ACCOUNT_ID
variable and the CLOUDFLARE_API_TOKEN and REAM_DOMAIN secrets; see
.github/workflows/release.yml). package.nix reads its version from
package.json, so the Nix package and the release always agree.