Skip to content

HTML to PDF

Convert HTML content to PDF documents. Supports both synchronous and asynchronous conversion modes.

Endpoint: POST /biz/cloud/convert/html2pdf

Parameters

ParameterTypeRequiredDescription
htmlContentStringYesHTML content to convert
paperSizeStringNoPaper size (default: "B6"). Supported: A3, A4, A5, A6, B3, B4, B5, B6, Letter, Legal
request_idStringNoUnique request ID for async conversion
webhookStringNoWebhook URL for async completion notification (only with request_id)

Conversion Modes

  • Synchronous (default): Without request_id, the API waits for conversion to complete and returns the PDF result directly.
  • Asynchronous: With request_id, the API creates a conversion record and processes it in the background. Returns the record immediately. Use the Query Conversion Record endpoint to check status.

Request (Synchronous)

bash
curl -X POST "https://api.alaikis.com/std/biz/cloud/convert/html2pdf" \
  -H "X-API-Key: your_api_key" \
  -H "X-API-Secret: your_api_secret" \
  -d 'bizContent={"htmlContent": "<h1>Hello World</h1><p>This is a test PDF.</p>", "paperSize": "A4"}'

Request (Asynchronous)

bash
curl -X POST "https://api.alaikis.com/std/biz/cloud/convert/html2pdf" \
  -H "X-API-Key: your_api_key" \
  -H "X-API-Secret: your_api_secret" \
  -d 'bizContent={"htmlContent": "<h1>Hello World</h1>", "paperSize": "A4", "request_id": "unique-req-001", "webhook": "https://your-server.com/callback"}'

Response (Asynchronous)

json
{
  "code": 200,
  "msg": "success",
  "data": {
    "id": 1,
    "htmlContent": "<h1>Hello World</h1>",
    "paper": "A4",
    "requestId": "unique-req-001",
    "args": "{\"htmlContent\":\"<h1>Hello World</h1>\",\"paperSize\":\"A4\"}",
    "webhook": "https://your-server.com/callback",
    "status": "processing"
  }
}

Query Conversion Record

Check the status of an asynchronous HTML2PDF conversion.

Endpoint: POST /biz/cloud/convert/html2pdf/record/by-request-id

Parameters

ParameterTypeRequiredDescription
request_idStringYesThe unique request ID used when initiating the conversion

Request

bash
curl -X POST "https://api.alaikis.com/std/biz/cloud/convert/html2pdf/record/by-request-id" \
  -H "X-API-Key: your_api_key" \
  -H "X-API-Secret: your_api_secret" \
  -d 'bizContent={"request_id": "unique-req-001"}'

Paper Size Reference

SizeDimensions (mm)
A3297 × 420
A4210 × 297
A5148 × 210
A6105 × 148
B3353 × 500
B4250 × 353
B5176 × 250
B6125 × 176
Letter216 × 279
Legal216 × 356

Error Codes

CodeDescription
406The requestId already exists (duplicate async request)
406The requestId is required (for record query)
406The record does not exist (for record query)