简介
本文档提供关于文档预览的相关的 API 概览以及 SDK 示例代码。
API | 操作名 | 操作描述 |
文档转 HTML 同步请求 | 获取文档转 HTML 的请求 URL |
文档转 HTML
功能说明
文档转 HTML 同步请求,获取文档转 HTML 的请求 URL。
示例代码
<?phprequire dirname(__FILE__, 2) . '/vendor/autoload.php';$secretId = "SECRETID"; //替换为用户的 secretId,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$secretKey = "SECRETKEY"; //替换为用户的 secretKey,请登录访问管理控制台进行查看和管理,https://console.cloud.tencent.com/cam/capi$region = "ap-beijing"; //替换为用户的 region,已创建桶归属的 region 可以在控制台查看,https://console.cloud.tencent.com/cos5/bucket$cosClient = new Qcloud\\Cos\\Client(array('region' => $region,'schema' => 'https', //协议头部,默认为 http'credentials'=> array('secretId' => $secretId ,'secretKey' => $secretKey)));try {// 2. 文档转 HTML https://cloud.tencent.com/document/product/460/52518$bucket = 'examplebucket-1250000000';$key = 'exampleobject';$url = $cosClient->getObjectUrl($bucket, $key, "+30 minutes");$params = array('ci-process' => 'doc-preview',// 'srcType' => '','dstType' => 'html',// 'sign' => '',// 'copyable' => '',// 'htmlParams' => '',// 'htmlwaterword' => '',// 'htmlfillstyle' => '',// 'htmlfront' => '',// 'htmlrotate' => '',// 'htmlhorizontal' => '',// 'htmlvertical' => '',);$query = http_build_query($params);echo $url . $query; // 生成的可访问链接} catch (\\Exception $e) {// 请求失败echo($e);}
参数说明
名称 | 描述 | 类型 | 是否必选 |
Key | 对象文件名,例如 folder/document.pdf | String | 是 |
ci-process | 数据万象处理能力,文档 HTML 预览固定为 doc-preview | String | 是 |
dstType | 转换输出目标文件类型,文档 HTML 预览固定为 html(需为小写字母) | String | 是 |
srcType | 指定目标文件类型,支持的文件类型请见下方 | String | 否 |
sign | 注意:需要进行 urlencode | String | 否 |
copyable | 是否可复制。默认为可复制,填入值为1;不可复制,填入值为0 | String | 否 |
htmlParams | String | 否 | |
htmlwaterword | String | 否 | |
htmlfillstyle | String | 否 | |
htmlfront | String | 否 | |
htmlrotate | 水印文字旋转角度,0 - 360,默认315度 | String | 否 |
htmlhorizontal | 水印文字水平间距,单位 px,默认为50 | String | 否 |
htmlvertical | 水印文字垂直间距,单位 px,默认为100 | String | 否 |
注意
目前支持的输入文件类型包含如下格式:
演示文件:pptx、ppt、pot、potx、pps、ppsx、dps、dpt、pptm、potm、ppsm。
文字文件:doc、dot、wps、wpt、docx、dotx、docm、dotm。
表格文件:xls、xlt、et、ett、xlsx、xltx、csv、xlsb、xlsm、xltm、ets。
其他格式文件: pdf、 lrc、 c、 cpp、 h、 asm、 s、 java、 asp、 bat、 bas、 prg、 cmd、 rtf、 txt、 log、 xml、 htm、 html。
输入文件大小限制在200MB之内。
输入文件页数限制在5000页之内。
返回结果示例
同步请求 URLhttps://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/example.ppt?sign=q-sign-algorithmxxxxxxxxxxxxx&ci-process=doc-preview&dstType=html