接入说明
本文档提供两种方式接入预览服务,智享文库文档在线预览服务地址为:https://view.56wenku.cn/。
var fileUrl = 'https://view.56wenku.cn/demo/test.docx'; //要预览文件的访问地址
window.open('https://view.56wenku.cn/online?format=html&url='+fileUrl);
var fileUrl = 'https://view.56wenku.cn/demo/test.docx'; //要预览文件的访问地址
window.open('https://view.56wenku.cn/online?format=html&url='+fileUrl+'&watermarkTxt=智享文库文档在线预览');
var fileUrl = 'https://view.56wenku.cn/demo/test.docx'; //要预览文件的访问地址
window.open('https://view.56wenku.cn/online?format=html&url='+fileUrl+'&limit=1');
接口调用
接口地址:https://view.56wenku.cn/online
请求方式:GET/POST
请求参数:
| 参数名 | 参数类型 | 是否必须 | 参数说明 |
|---|---|---|---|
| url | String | 是 | http/https文档地址支持:doc、docx、xls、xlsx、ppt、pptx、pdf、ofd、zip、rar、txt、图片等格式。 |
| format | String | 否 | 返回结果格式,可选值:json、html,默认json |
| limit | int | 否 | office文档控制预览页数,对pdf/doc/docx/ppt/pptx有效 |
| watermarkTxt | String | 否 | 水印文本,显示文本水印 |
返回结果
当参数format=json时返回如下结果,返回示例:
{
"code":0,
"success":true,
"msg":"success",
"content":"https://view.56wenku.cn/view?url=aHR0cHM6Ly92aWV3LnpoaXBhbGwuY24vZGVtby90ZXN0LmRvY3g%3D&limit=2&watermarkTxt=watermark"
}
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| code | int | 返回码,0表示成功,非0表示失败 |
| success | bool | 业务状态,true成功 |
| msg | String | 返回信息 |
| content | String | 返回预览地址 |