A REST API for converting documents to PDF using LibreOffice via unoserver. Features memory-efficient streaming, comprehensive LibreOffice PDF export options, and Docker-based deployment.
Warning
Security Notice
It is NOT RECOMMENDED to expose this service directly to the internet. This should be deployed in a private network or behind authentication/authorization layers.
- Universal Document Conversion - DOCX, XLSX, PPTX, ODT, ODS, ODP, images, and more to PDF
- PDF Export Options - Complete LibreOffice PDF export control including:
- Watermarks (text and tiled)
- Password encryption and permissions
- Page ranges and selection
- PDF/A compliance (1b, 2b, 3b)
- Accessibility (PDF/UA and tagged PDFs)
- Image compression and quality control
- Bookmarks, forms, notes, and hidden slides
- Smart Conversion Modes - Automatic stream mode (≤10MB) or filesystem mode (>10MB) for optimal performance
- OpenAPI Documentation - OpenApi at
/openapiwith complete API specs - Production Ready - Docker-based deployment with unoserver and LibreOffice pre-configured
- Memory Efficient - Streams PDF output in chunks
- Health Checks - Built-in
/healthendpoint for monitoring and load balancers
Supported Formats:
- Documents: DOCX, DOC, ODT, RTF, TXT, HTML
- Spreadsheets: XLSX, XLS, ODS, CSV
- Presentations: PPTX, PPT, ODP
- Images: PNG, JPG, JPEG, TIFF
- PDF: PDF (for applying options/re-processing existing PDFs)
Create a compose.yaml file:
services:
php:
image: ghcr.io/ikerls/unoserver-api:latest
ports:
- "8088:8080"
environment:
UNOSERVER_TIMEOUT: 120
UPLOAD_MAX_SIZE: 100MStart the service:
docker compose up -d
# View logs
docker compose logs -f
# Stop service
docker compose downdocker run -d \
--name unoserver-api \
-p 8080:8080 \
-e UNOSERVER_TIMEOUT=120 \
-e UPLOAD_MAX_SIZE=100M \
ghcr.io/ikerls/unoserver-api:latest| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check endpoint (returns {"status":"ok"}) |
/convert |
POST | Convert document to PDF with options |
/openapi |
GET | OpenApi file |
curl -X POST http://localhost:8080/convert \
-F "file=@document.docx" \
-o output.pdfParameters:
file(required): Document file- LibreOffice PDF export options as form fields
Configure the service using environment variables:
| Variable | Default | Description |
|---|---|---|
UNOCONVERT_BINARY |
unoconvert |
Path to the unoconvert binary |
UNOSERVER_HOST |
127.0.0.1 |
Host where unoserver daemon runs |
UNOSERVER_PORT |
2003 |
Port for unoserver connection |
UNOSERVER_TIMEOUT |
120 |
Maximum conversion time in seconds |
UNOSERVER_STREAM_THRESHOLD |
10485760 |
File size (bytes) to switch from stream to filesystem mode (default: 10MB) |
UPLOAD_MAX_SIZE |
100M |
Maximum upload file size (e.g., 50M, 200M) |
Setting variables:
Via Docker Compose:
services:
php:
environment:
UNOSERVER_TIMEOUT: 300
UPLOAD_MAX_SIZE: 150M
UNOSERVER_STREAM_THRESHOLD: 20971520 # 20MBVia Docker Run:
docker run -e UNOSERVER_TIMEOUT=300 -e UPLOAD_MAX_SIZE=150M ...This project uses LibreOffice and unoserver. Please review their respective licenses: