File Conversion API

Production-ready .NET 10 REST API for converting documents and images. HTML/Markdown to PDF, Markdown to HTML, image format conversions, PDF watermarking, password protection, and merge/split with enterprise-grade authentication, webhooks, and monitoring.

.NET 10 MIT License CI

Features

Enterprise-ready file conversion with modern architecture

🔒

JWT Authentication

Secure Bearer token authentication with refresh tokens and configurable expiration.

📄

Document Conversion

HTML/Markdown to PDF, Markdown to HTML using PuppeteerSharp and Markdig with customizable options.

🗎

Office Documents

Convert DOCX and XLSX to PDF using LibreOffice headless mode with watermark and encryption support.

📷

Image Conversions

Convert between PNG, JPEG, WebP, GIF, BMP formats with resize and quality options using ImageSharp.

📸

HTML Screenshots

Capture HTML pages or URLs as PNG, JPEG, or WebP screenshots with configurable viewport and full-page capture.

🖼

PDF to Image

Render PDF pages to PNG, JPEG, or WebP with configurable DPI, single page or all pages, and password support.

📄

PDF Text Extraction

Extract text content from PDF documents with support for specific pages and password-protected files.

Async Processing

Background job processing with status tracking and result retrieval.

🛠

Clean Architecture

CQRS pattern with MediatR, ensuring maintainable and testable code.

🐃

PostgreSQL

Entity Framework Core with PostgreSQL for reliable data persistence.

📦

Docker Ready

Multi-arch containers (AMD64/ARM64) optimized for production deployments.

🔔

Webhook Notifications

HTTP callbacks when jobs complete or fail with configurable retries.

📈

Prometheus Metrics

Built-in /metrics endpoint for Grafana dashboards with conversion and HTTP request metrics.

🩹

Enhanced Health Checks

Detailed /health endpoint reporting database, Chromium, and disk space status.

💧

PDF Watermarking

Add text watermarks to PDFs with customizable font, color, opacity, rotation, and positioning.

🔐

PDF Security

Password protection with user/owner passwords and granular permission controls for printing, copying, and editing.

🗒

PDF Merge & Split

Combine multiple PDFs into one or split PDFs by page ranges into separate files.

📦

Batch Conversions

Process up to 20 conversion requests in a single API call with partial success support.

👑

Admin API

Role-based admin endpoints for user management, job statistics, and system monitoring.

📝

Conversion Templates

Save and reuse conversion settings including page sizes, margins, and watermarks.

🔭

OpenTelemetry Tracing

Distributed tracing for end-to-end request visibility. Export to Jaeger, Zipkin, or OTLP backends.

🛡

Input Validation

Configurable file size limits, URL allowlist/blocklist for SSRF protection, and content type validation.

👤

Admin Seeding

Automatic admin user creation on startup for initial setup. Configurable credentials with production-safe defaults.

📊

Usage Quotas

Per-user monthly limits on conversions and bytes processed. Automatic reset each month with admin exemption support.

🚧

Per-User Rate Limiting

Tiered rate limits (Free, Basic, Premium, Unlimited) with admin-configurable per-user overrides and admin exemption.

Cloud Storage

Store conversion outputs in S3-compatible storage (AWS S3, MinIO, DigitalOcean Spaces, Cloudflare R2). Backward compatible with database storage.

API Endpoints

RESTful endpoints for authentication and file conversion

Authentication

POST /api/v1/auth/register Register a new user
POST /api/v1/auth/login Authenticate and get JWT token
POST /api/v1/auth/refresh Refresh access token

Conversion

POST /api/v1/convert/html-to-pdf Convert HTML content to PDF
POST /api/v1/convert/markdown-to-pdf Convert Markdown to PDF
POST /api/v1/convert/markdown-to-html Convert Markdown to styled HTML
POST /api/v1/convert/image Convert image formats (PNG, JPEG, WebP)
POST /api/v1/convert/html-to-image Convert HTML/URL to image (PNG, JPEG, WebP)
POST /api/v1/convert/pdf-to-image Convert PDF pages to image (PNG, JPEG, WebP)
POST /api/v1/convert/pdf-to-text Extract text from PDF documents
POST /api/v1/convert/docx-to-pdf Convert DOCX to PDF
POST /api/v1/convert/xlsx-to-pdf Convert XLSX to PDF
POST /api/v1/convert/pdf/merge Merge multiple PDFs into one
POST /api/v1/convert/pdf/split Split PDF into multiple files
POST /api/v1/convert/batch Batch convert multiple files
GET /api/v1/convert/{jobId} Get conversion job status
GET /api/v1/convert/{jobId}/download Download converted file
GET /api/v1/convert/history Get conversion history

Health & Monitoring

GET /health Detailed health status (DB, Chromium, disk)
GET /metrics Prometheus metrics endpoint

Admin (requires Admin role)

GET /api/v1/admin/users List all users (paginated)
GET /api/v1/admin/users/{id} Get user details
POST /api/v1/admin/users/{id}/disable Disable a user
POST /api/v1/admin/users/{id}/enable Enable a user
POST /api/v1/admin/users/{id}/reset-api-key Reset user's API key
GET /api/v1/admin/stats Get job statistics
GET /api/v1/admin/users/{id}/quota Get user's quota
GET /api/v1/admin/users/{id}/quota/history Get user's quota history
PUT /api/v1/admin/users/{id}/quota Update user's quota limits

Quota

GET /api/v1/quota Get current user's usage quota

Templates

GET /api/v1/templates List user's conversion templates
GET /api/v1/templates/{id} Get template by ID
POST /api/v1/templates Create a new template
PUT /api/v1/templates/{id} Update a template
DELETE /api/v1/templates/{id} Delete a template

Quick Start

Get up and running in minutes

Docker Compose
# Clone the repository
git clone https://github.com/Roly67/silver-fiesta.git
cd silver-fiesta

# Start with Docker Compose
docker-compose up -d

# API available at http://localhost:5000
# Swagger UI at http://localhost:5000/swagger

Example: Convert HTML to PDF
# 1. Register a user
curl -X POST http://localhost:5000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "SecurePass123!"}'

# 2. Login to get token
curl -X POST http://localhost:5000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "SecurePass123!"}'

# 3. Convert HTML to PDF (with optional webhook)
curl -X POST http://localhost:5000/api/v1/convert/html-to-pdf \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"htmlContent": "<h1>Hello World</h1>", "fileName": "document.pdf", "webhookUrl": "https://example.com/webhook"}'