如果你需要将文档转为图片,可以通过调用 OpenAPI WbTranscodeCreate 进行转码。支持将 PPT、PPTX、DOC、DOCX、PDF格式文件转为格式为 PNG、JPG/JPEG 的静态图片。文档中的每个页面转换为一张图片。
每次调用 WbTranscodeCreate 只能发起一份文档转码。
转码的任务处理是异步的,你可以通过 WbTranscodeQuery 查询到转码任务完成后,调用 WbTranscodeGet 获取转换好的图片链接集合。
获取图片链接后,在 Web 端调用
whiteBoard.createPages将图片插入到白板中。参见 Web 端文件上传。
在 RTC 控制台开通转码服务
在火山引擎或其他 TOS 服务商开通了 TOS 服务
WbTranscodeCreate 发起一个文件转码任务,将 ppt、pptx、doc、docx、pdf 格式文件转为格式为 PNG、JPG/JPEG 的静态图片。
使用 Post 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeCreate | 接口名称,本接口取值:WbTranscodeCreate |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| app_id | string | 是 | 600000000000000000000000 | 应用的唯一标志。你可以通过控制台查看和复制你的 app_id。或通过调用 ListApps 接口获取。 |
| resource | string | 是 | https://resource.com | 需要转换为图片的文档链接地址。每次调用接口只能请求处理一份文档。 |
| operator | string | 是 | your_user_id | 用户 ID |
transcode_config | 是 | | 转码参数设置 | |
storage_config |
| | 对象存储属性 | |
transcode_mode | int | 否 |
| 转码类型 |
priority | int | 否 |
| 转码优先级
|
pre_sign_duration | int | 否 |
| 转码成功后返回的 URL 预签名有效期。有效范围:
|
https://rtc.volcengineapi.com?Action=WbTranscodeCreate&Version=2020-12-01
postscript{
"app_id":"600000000000000000000000",
"oprator":"your_user_id",
"resource":"https://resource.com",
"priority":0,
"transcode_config":{
"input_format":1,
"output_format":1,
"output_width":1080,
"output_height":720
},
"storage_config":{
"type":0,
"tos_config":{
"account_id":"xxx",
"region":0,
"bucket":"xxx"
}
}
}
json{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeCreate",
"Version": "2020-12-01"
},
"Result": {
"task_id": "xxx" //task_id 为查询任务进度和获取图片链接的必填参数
}
}
json发起文件转码任务,可以通过调用 WbTranscodeQuery 查询转码任务的进度。
使用 Get 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeQuery | 接口名称,本接口取值:WbTranscodeQuery |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
app_id | string | 是 |
| |
| task_id | string | 是 | 0000000000 | 成功调用 WbTranscodeQuery后返回的任务ID |
https://rtc.volcengineapi.com?Action=WbTranscodeQuery&Version=2020-12-01&app_id=your_app_id&task_id=your_task_id
postscript{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeQuery",
"Version": "2020-12-01"
},
"Result": {
"status": 2, // 0:未开始,1:进行中,2:已完成:3:失败
"progress": 100, //转码进度。100 表示已完成
"err_code": 0,
"err_msg": ""
}
}
json文件转码任务完成后,可以通过 WbTranscodeGet 获取文件转码后的图片链接。
使用 Get 方式发起请求。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
以下是接口特有的请求参数。关于其他公共请求参数,参看请求参数。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | string | 是 | WbTranscodeGet | 接口名称,本接口取值:WbTranscodeGet |
| Version | string | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
app_id | string | 是 |
| |
| task_id | string | 是 | 0000000000 | 成功调用 WbTranscodeQuery后返回的任务ID |
https://rtc.volcengineapi.com?Action=WbTranscodeGet&Version=2020-12-01&app_id=your_app_id&task_id=your_task_id
json{
"ResponseMetadata": {
"RequestId": "your_request_id",
"Service": "rtc",
"Region": "cn-north-1",
"Action": "WbTranscodeGet",
"Version": "2020-12-01"
},
"Result": {
"file_name": "cs.pptx",
"width": 1920,
"height": 1080,
"transcode_mode": 0,
"images": [
{
"page_id": 1,
"img": "https://result1.com",
"thumbnail_url": "https://result1_thm.com"
},
{
"page_id": 2,
"img": "https://result2.com",
"thumbnail_url": "https://result2_thm.com"
}
],
"h5_url": ""
}
json| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
input_format | int | 是 | 输入文件类型 |
output_format | int | 是 | 输出文件类型 |
force_use_resolution | bool | 否 | 是否按照指定分辨率拉伸图片 |
| output_width | int | 是 | 转码后的图片宽度,单位为像素 |
| output_height | int | 是 | 转码后的图片高度,单位为像素 |
| thumbnail | bool | 否 | 是否生成缩略图,默认为 false |
| thumbnail_wdth | int | 否 | 缩略图分辨率宽,默认为 320 |
| thumbnail_height | int | 否 | 缩略图分辨率高,默认为 180 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
type | int | 是 | 存储类型 |
| tos_config | TosConfig | 否 | 火山引擎的对象存储服务参数设置 |
| custom_config | CustomConfig | 否 | 第三方对象存储服务参数设置 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
account_id | string | 是 | Bucket 所属的火山引擎账号 ID。在登陆火山引擎后,可在头像的悬浮菜单中找到账号 ID。 |
| region | int | 是 | 0: 北京 |
| bucket | string | 是 | 桶名称。登陆 TOS 控制台 开通和获取。 |
| 参数 | 类型 | 必须 | 描述 |
|---|---|---|---|
vendor | int | 是 | 第三方存储供应商 |
region | int | 是 | 区域 |
| bucket | string | 是 | 桶名称 |
| access_key | string | 是 | Access Key |
secret_key | stiring | 是 | Secret Key |