A high-performance, secure REST API for converting LaTeX documents to PDF format.
1.0K
A high-performance, secure REST API for converting LaTeX documents to PDF format.
main.tex either at the root or inside a single top-level folder (e.g., GitHub or Overleaf exports)The easiest way to run the service is with Docker Compose:
# Clone the repository
git clone https://github.com/rbehzadan/tex2pdf-docker.git
cd tex2pdf
# Start the service
docker-compose up -d
The service will be available at http://localhost:8000.
curl -X POST \
-H "X-API-Key: 1234" \
-F "zip_file=@my_latex_files.zip" \
http://localhost:8000/tex2pdf
Response:
{
"job_id": "28f5bf9b-587f-4f3c-a3de-4d737d9736ce",
"status": "processing",
"message": "Conversion job started"
}
curl -X GET \
-H "X-API-Key: 1234" \
http://localhost:8000/tex2pdf/status/28f5bf9b-587f-4f3c-a3de-4d737d9736ce
Response:
{
"job_id": "28f5bf9b-587f-4f3c-a3de-4d737d9736ce",
"status": "completed",
"created_at": 1741424390.6039968
}
curl -X GET \
-H "X-API-Key: 1234" \
-o output.pdf \
http://localhost:8000/tex2pdf/download/28f5bf9b-587f-4f3c-a3de-4d737d9736ce
curl http://localhost:8000/health
Response:
{
"status": "healthy",
"version": "1.0.0",
"database": "connected",
"storage": true
}
You can specify the main LaTeX file if it's not named main.tex:
curl -X POST \
-H "X-API-Key: 1234" \
-F "zip_file=@my_latex_files.zip" \
-F "options={\"main_file\": \"document.tex\"}" \
http://localhost:8000/tex2pdf
Options:
main_file: Main LaTeX file to compile (default: main.tex)ℹ️ The service now uses latexmk for automatic multiple runs and bibliography support, so you no longer need to set num_runs or use_bibtex.
main.tex (or your specified main_file) either:
myproject/main.tex)The service can be configured via environment variables in the docker-compose.yml file:
| Variable | Description | Default |
|---|---|---|
ALLOWED_API_KEYS | Comma-separated list of valid API keys | "" (empty = no auth) |
API_KEY_REQUIRED | Enable/disable API key validation | "true" |
MAX_WORKERS | Number of uvicorn workers | 2 |
MAX_UPLOAD_SIZE | Maximum file upload size in bytes | 52428800 (50MB) |
MAX_COMPILATION_TIME | Maximum LaTeX compilation time in seconds | 240 |
RATE_LIMIT_WINDOW | Rate limiting window in seconds | 60 |
MAX_REQUESTS_PER_WINDOW | Maximum requests per rate limit window | 10 |
JOB_EXPIRY | Job expiry time in seconds | 3600 (1 hour) |
JOBS_DIR | Directory for storing PDF files | "/data/jobs" |
DB_PATH | Path to SQLite database | "/data/db/jobs.db" |
The service uses a stateless design with background processing:
GitHub Repository: rbehzadan/tex2pdf-docker
Content type
Image
Digest
sha256:d0a9b8642…
Size
2 GB
Last updated
about 1 year ago
docker pull rbehzadan/tex2pdf:v2.5.2