- HTML/Markdown to PDF conversion via Puppeteer - Invoice and receipt templates - API key auth + rate limiting - Dockerfile for deployment
62 lines
1.6 KiB
Markdown
62 lines
1.6 KiB
Markdown
# DocFast API
|
|
|
|
Fast, simple HTML/Markdown to PDF API with built-in invoice templates.
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
npm install
|
|
npm run build
|
|
API_KEYS=your-key-here npm start
|
|
```
|
|
|
|
## Endpoints
|
|
|
|
### Convert HTML to PDF
|
|
```bash
|
|
curl -X POST http://localhost:3100/v1/convert/html \
|
|
-H "Authorization: Bearer YOUR_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"html": "<h1>Hello</h1><p>World</p>"}' \
|
|
-o output.pdf
|
|
```
|
|
|
|
### Convert Markdown to PDF
|
|
```bash
|
|
curl -X POST http://localhost:3100/v1/convert/markdown \
|
|
-H "Authorization: Bearer YOUR_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"markdown": "# Hello\n\nWorld"}' \
|
|
-o output.pdf
|
|
```
|
|
|
|
### Invoice Template
|
|
```bash
|
|
curl -X POST http://localhost:3100/v1/templates/invoice/render \
|
|
-H "Authorization: Bearer YOUR_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"invoiceNumber": "INV-001",
|
|
"date": "2026-02-14",
|
|
"from": {"name": "Your Company", "email": "you@example.com"},
|
|
"to": {"name": "Client", "email": "client@example.com"},
|
|
"items": [{"description": "Service", "quantity": 1, "unitPrice": 100, "taxRate": 20}]
|
|
}' \
|
|
-o invoice.pdf
|
|
```
|
|
|
|
### Options
|
|
- `format`: Paper size (A4, Letter, Legal, etc.)
|
|
- `landscape`: true/false
|
|
- `margin`: `{top, right, bottom, left}` in CSS units
|
|
- `css`: Custom CSS (for markdown/html fragments)
|
|
- `filename`: Suggested filename in Content-Disposition header
|
|
|
|
## Auth
|
|
Pass API key via `Authorization: Bearer <key>`. Set `API_KEYS` env var (comma-separated for multiple keys).
|
|
|
|
## Docker
|
|
```bash
|
|
docker build -t docfast .
|
|
docker run -p 3100:3100 -e API_KEYS=your-key docfast
|
|
```
|