Skip to content
ComPDF
DemoAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

API for File Processing

ComPDF Self-hosted exposes file processing APIs under /api/v1. Protected file processing APIs require the x-api-key request header.

API Types

TypeEndpointSuccess Response
Synchronous conversionPOST /api/v1/process/{source}/{target}Result file stream
Synchronous PDF toolsPOST /api/v1/process/pdf/{operation}Result file stream
Synchronous PDF generationPOST /api/v1/process/pdf/generation/{operation}Result PDF stream
Async task creationPOST /api/v1/task/{source}/{target}JSON envelope with taskId and status
Task statusGET /api/v1/task/{id}JSON envelope with task information
Task result downloadGET /api/v1/task/{id}/downloadResult file stream

Request Examples

Synchronous PDF to Word:

bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/docx" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F 'options={"pageRanges":"1-3"}' \
  -o result.docx

Synchronous PDF merge:

bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/merge" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F "[email protected]" \
  -F 'request={"pageRanges":["all","all"]}' \
  -o merged.pdf

Create an async task:

bash
curl -X POST "http://localhost:8080/api/v1/task/pdf/docx" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F 'options={"pageRanges":"1-3"}'

JSON Success Response

Async creation and task query APIs return a JSON envelope:

json
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "7fdc1fb6-1f4d-4b5c-88d6-4b4c4c1e8f44",
    "status": "pending"
  }
}

Synchronous result APIs return a binary stream with Content-Type and Content-Disposition headers.