Skip to content
ComPDF

Image to HTML API

BASE URLhttps://api-server.compdf.com/server/

❖ Feature Description

Convert image content to HTML for web display and further processing.

❖ Request Mode

Synchronous Request (Sync)
The API returns the result file directly after processing. Recommended for small files and real-time interactive scenarios that need immediate feedback.
Asynchronous Request (Async)
The API first returns task acceptance information, then you query progress and results with taskId. Suitable for large files and batch workloads.
Secure Request Mode
Upload and process files through secure mechanisms such as pre-signed URLs. Suitable for high-security and privacy compliance scenarios.

▎Call Flow

1Upload file
2Call API (sync)
3Get result URL
4Download file

▎Usage Limits

Download validity24 hours

synchronous执行

POSThttps://api-server.compdf.com/server/v2/process/img/html

❖ Request Parameters

Authentication credential sent in the header: x-api-key

Body Parameters multipart/form-data

No file selected
Upload file
API error message language (1 = English, 2 = Chinese)
Whether to use OCR (0 = disabled, 1 = enabled). Default is 0.
OCR recognition language code. See supported languages.
OCR recognition scope. Default is ALL: INVALID_CHARACTER (pages with garbled text), SCAN_PAGE (scanned pages), INVALID_CHARACTER_AND_SCAN_PAGE (both), or ALL (all pages).
Enable AI layout analysis (0 = off, 1 = on, default 1).
Preserve images in the output (0 = no, 1 = yes, default 1).
Preserve annotations in the output (0 = no, 1 = yes, default 1).
Whether to include page background images during conversion (0 = disabled, 1 = enabled). This setting is effective only when OCR is enabled. Default is 1.
是否将公式转为图片(0=保持可编辑,1=转图片,默认 0)。
Specify the layout mode: e_Box for fixed layout, e_Flow for reflowable layout. Default is e_Flow.
HTML option: e_SinglePage (single HTML), e_SinglePageWithBookmark (single HTML with bookmark outline), e_MultiPage (multiple HTML files), or e_MultiPageWithBookmark (multiple HTML files with page-to-page navigation). Default is e_SinglePage.

❖ Response Properties

FieldTypeDescription
codeStringBusiness status code
msgStringMessage
dataObjectResponse data
data.fileKeyStringUnique key of the file in the storage system.
data.taskIdStringTask ID
data.fileNameStringSource file name. Required in presigned mode to generate the object storage upload URL.
data.downFileNameStringOutput file name after conversion.
data.fileUrlStringSource file storage URL or object storage key.
data.downloadUrlStringFile download URL
data.sourceTypeStringSource file type
data.targetTypeStringTarget file type
data.fileSizeIntegerSource file size in bytes.
data.convertSizeIntegerConverted file size in bytes.
data.convertTimeIntegerConversion time for a single file, typically in milliseconds.
data.statusStringFile processing status. Common values: success, failed, processing, etc.
data.failureCodeStringError code when file conversion fails.
data.failureReasonStringError reason when file conversion fails.
data.fileParameterStringConversion parameter JSON string submitted when creating the task.
🔗Request Example
curl --request POST \
  --url https://api-server.compdf.com/server/v2/process/img/html \
  --header 'x-api-key: YOUR API-KEY' \
  --form [email protected]
Response Example
200 OK
{
  "code": "200",
  "msg": "success",
  "data": {
    "fileKey": "<string>",
    "taskId": "<string>",
    "fileName": "<string>",
    "downFileName": "<string>",
    "fileUrl": "<string>",
    "downloadUrl": "<string>",
    "sourceType": "<string>",
    "targetType": "<string>",
    "fileSize": 0,
    "convertSize": 0,
    "convertTime": 0,
    "status": "<string>",
    "failureCode": "<string>",
    "failureReason": "<string>",
    "fileParameter": "<string>"
  }
}