pdf-compiler is a simple LaTeX and HTML → PDF compiler over HTTP, written in Go. It supports compiling LaTeX documents using pdflatex and HTML documents using headless Chrome.
- Go 1.25+
swag— for generating Swagger docsdocker— for running the full stack
The default make target vendors dependencies, generates Swagger docs, and builds the binary:
makeRun it:
./pdf-compilerOther useful targets:
| Target | Description |
|---|---|
make swag |
Regenerate Swagger docs from source annotations |
make templates_sync |
Clone the private LaTeX templates repo into ./templates |
make clean |
Remove the built binary and templates directory |
make update |
Update all Go dependencies to their latest versions |
The canonical way to run the full stack (pdf-compiler + texlive sidecar + templates):
docker compose upThe service is then reachable at http://localhost:8080.
All options are read from environment variables (or a .env file in the working directory):
| Variable | Default | Description |
|---|---|---|
BASE_PATH |
/api/v1 |
HTTP path prefix for all API routes |
PORT |
:8080 |
Listen address (e.g. :80) |
TEMPLATE_DIR |
templates |
Directory added to TEXINPUTS for LaTeX templates |
LOG_LEVEL |
info |
Zerolog level (trace, debug, info, warn, error) |
PATH_TO_CHROME_BIN |
google-chrome-stable |
Path or name of the Chrome binary used for HTML→PDF |
Compiles a LaTeX document to PDF.
{ "tex": "\\documentclass{article}\n\\begin{document}\nHello!\n\\end{document}" }Returns application/pdf on success, or a JSON error on failure.
Compiles an HTML document to PDF using headless Chrome.
{ "html": "<html><body><h1>Hello!</h1></body></html>" }Returns application/pdf on success.
Returns 200 OK.
Interactive Swagger UI: http://localhost:8080/swagger/index.html
Raw spec: http://localhost:8080/swagger/doc.json — also committed to the docs/ directory.
A generated TypeScript client is published to npm. See the client README for usage.
