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

Async Task APIs

Async task creation uses the same path pattern as synchronous processing. Task query, download, and cancel APIs keep the task-id based lifecycle path.

Create a Task

ItemValue
Request URLPOST http://localhost:8080/api/v1/task/{source}/{target}
Authenticationx-api-key: your_api_key_here
Request Typemultipart/form-data

Multipart Fields

FieldTypeDescriptionRequired
fileFilePrimary source file for single-file operations.Required except merge and generation-from-inline-data
filesFile[]Source files for PDF merge.Required for merge
insertFileFilePDF file to insert for task/pdf/insert-from-pdf.Required for insert-from-pdf
imageFileFileWatermark image for task/pdf/watermark/add.Optional
iccFileFileICC profile for task/pdf/pdfa.Required for PDF standards conversion
htmlFileFileHTML file for task/pdf/generation/html-to-pdf.Optional when request.html or request.htmlUrl is used
templateFileFileHTML template file for task/pdf/generation/template-to-pdf.Optional when request.template is used
dataFileFileJSON data file for template rendering.Optional
requestStringPDF tool or PDF generation parameter JSON string.Optional
optionsStringConversion options JSON string.Optional
passwordStringSource file password.Optional

curl Example

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"}'

Response

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

Query a Task

bash
curl -X GET "http://localhost:8080/api/v1/task/7fdc1fb6-1f4d-4b5c-88d6-4b4c4c1e8f44" \
  -H "x-api-key: your_api_key_here"

Download the Result

bash
curl -L "http://localhost:8080/api/v1/task/7fdc1fb6-1f4d-4b5c-88d6-4b4c4c1e8f44/download" \
  -H "x-api-key: your_api_key_here" \
  -o result.bin

The result download API returns a binary file stream after the task succeeds. If the task exists but is not ready, it returns 409 with TASK_NOT_READY.

Cancel a Task

bash
curl -X POST "http://localhost:8080/api/v1/task/7fdc1fb6-1f4d-4b5c-88d6-4b4c4c1e8f44/cancel" \
  -H "x-api-key: your_api_key_here"