HTML to PDF
Convert HTML content to PDF documents. Supports both synchronous and asynchronous conversion modes.
Endpoint: POST /biz/cloud/convert/html2pdf
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| htmlContent | String | Yes | HTML content to convert |
| paperSize | String | No | Paper size (default: "B6"). Supported: A3, A4, A5, A6, B3, B4, B5, B6, Letter, Legal |
| request_id | String | No | Unique request ID for async conversion |
| webhook | String | No | Webhook 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| request_id | String | Yes | The 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
| Size | Dimensions (mm) |
|---|---|
| A3 | 297 × 420 |
| A4 | 210 × 297 |
| A5 | 148 × 210 |
| A6 | 105 × 148 |
| B3 | 353 × 500 |
| B4 | 250 × 353 |
| B5 | 176 × 250 |
| B6 | 125 × 176 |
| Letter | 216 × 279 |
| Legal | 216 × 356 |
Error Codes
| Code | Description |
|---|---|
| 406 | The requestId already exists (duplicate async request) |
| 406 | The requestId is required (for record query) |
| 406 | The record does not exist (for record query) |