oxidize-pdf-api
REST API for oxidizePdf - A high-performance PDF manipulation library written in Rust.
Features
- RESTful API: Clean and intuitive HTTP endpoints for PDF operations
- Async Processing: Built on Tokio for high-performance async I/O
- File Upload Support: Multipart form data handling for PDF uploads
- CORS Support: Cross-origin resource sharing for web applications
- Community Edition: Full-featured API for common PDF operations
Installation
From Source
Using Cargo
Running the Server
# Default port 3000
# Custom port
# With environment variables
OXIDIZEPDF_API_PORT=8080 RUST_LOG=info
API Endpoints
Health Check
GET /health
Returns server status and version information.
Merge PDFs
POST /api/merge
Content-Type: multipart/form-data
Merge multiple PDF files into a single document.
Request:
files: Multiple PDF files (form field name:file)preserve_metadata: Boolean (optional, default: true)optimize: Boolean (optional, default: false)
Response:
Returns the merged PDF file with appropriate headers.
Split PDF
POST /api/split
Content-Type: multipart/form-data
Split a PDF into individual pages or chunks.
Request:
file: PDF file to splitmode: "pages" | "chunks" (optional, default: "pages")chunk_size: Number (optional, for chunks mode)
Response: ZIP file containing split PDFs
Extract Pages
POST /api/extract
Content-Type: multipart/form-data
Extract specific pages from a PDF.
Request:
file: Source PDF filepages: Page range (e.g., "1-5,10,15-20")
Response: PDF containing only the specified pages
Rotate Pages
POST /api/rotate
Content-Type: multipart/form-data
Rotate pages in a PDF.
Request:
file: PDF fileangle: 90 | 180 | 270pages: Page range (optional, rotates all if not specified)
Response: PDF with rotated pages
Extract Text
POST /api/text
Content-Type: multipart/form-data
Extract text content from a PDF.
Request:
file: PDF filepages: Page range (optional)format: "plain" | "json" (optional, default: "plain")
Response:
- Plain text or JSON structure with page-by-page text
Get PDF Info
POST /api/info
Content-Type: multipart/form-data
Get metadata and information about a PDF.
Request:
file: PDF file
Response:
Example Usage
cURL
# Merge PDFs
# Extract pages
# Get PDF info
JavaScript/Fetch
// Merge PDFs
const formData = ;
formData.;
formData.;
formData.;
const response = await ;
const blob = await response.;
// Handle the merged PDF blob
Python
# Merge PDFs
=
=
Configuration
Environment variables:
OXIDIZEPDF_API_PORT: Server port (default: 3000)OXIDIZEPDF_API_HOST: Server host (default: 0.0.0.0)OXIDIZEPDF_MAX_FILE_SIZE: Maximum upload size in bytes (default: 100MB)RUST_LOG: Logging level (trace, debug, info, warn, error)
Error Handling
All endpoints return consistent error responses:
HTTP status codes:
- 200: Success
- 400: Bad Request (invalid input)
- 413: Payload Too Large
- 415: Unsupported Media Type
- 500: Internal Server Error
Security
- File size limits to prevent DoS
- Input validation for all parameters
- Temporary file cleanup after processing
- CORS configuration for web security
License
This project is licensed under the MIT License - see the LICENSE file for details.
See Also
- oxidize-pdf - Core PDF library
- oxidize-pdf-cli - CLI tool
- API Documentation - Detailed API docs