ONLYOFFICE Docs 是一个文档中间件,为文档管理软件提供 Office 格式的文档的在线预览与编辑。
支持主流格式:docx、xlsx、pptx、odt、ods、odp、doc、xls、ppt、pdf、txt、rtf、html、epub、csv。
实现多种类型转换,支持列表如下

文档地址:https://api.onlyoffice.com/docs/docs-api/additional-api/conversion-api/
Docker部署OnlyOffice
docker run -i -t -d -p 45680:80 --restart=always -e JWT_ENABLED=false onlyoffice/documentserver
转换说明
POST converter
POST /converter
Body 请求参数
{"async": false,"filetype": "pptx","key": "10","outputtype": "pdf","title": "file.pptx","url": "http://ip:port/file"
}
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | object | 否 | none |
| » async | body | boolean | 是 | 是否异步执行:默认false |
| » filetype | body | string | 是 | 源文件扩展 |
| » key | body | string | 是 | 唯一标识 |
| » outputtype | body | string | 是 | 转换类型 |
| » title | body | string | 是 | 文件名 |
| » url | body | string | 是 | 文件地址 |
返回示例
{"fileUrl": "http://localhost:45680/cache/files/data/conv_10_513/output.pdf/599966900621830.pdf?md5=7LDUEjVdOXpo03IQLfsFCg&expires=1738981689&filename=599966900621830.pdf","fileType": "pdf","percent": 100,"endConvert": true
}
返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » fileUrl | string | true | none | 文件下载地址 | |
| » fileType | string | true | none | 转换类型 | |
| » percent | integer | true | none | 转换进度 | |
| » endConvert | boolean | true | none | 转换状态 |
请求示例

转换结果

