关于office:onlyoffice教程0x05文件转换

阐明

onlyoffice提供文档转换服务,根本涵盖了简直所有常见文档之间的转换,能够看下word文档能转换成的文档格局就晓得其弱小

实现

转换接口

文档转换是通过接口来实现的,接口地址是https://documentserver/ConvertService.ashx,documentserver是documentserver的地址。这里列举几个常见的转换例子

  • word转pdf
 ➜ curl --location --request POST 'http://47.113.219.133:9001/ConvertService.ashx' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "async": false,
    "filetype": "docx",
    "key": "Khirz6zTPdfd7",
    "outputtype": "pdf",
    "title": "example.docx",
    "url": "https://zhengjianfeng.cn/document/example.docx"
}'


{
    "fileUrl": "http://47.113.219.133:9001/cache/files/conv_Khirz6zTPdfd7_pdf/output.pdf/example.pdf?md5=iPboTbRhw7JVpcicXZhiZg&expires=1638502601&filename=example.pdf",
    "percent": 100,
    "endConvert": true
}

参数阐明

  • async:指定转换是同步的还是异步的,如果是false那么转换会同步进行,转换实现后才会返回
  • filetype:文档类型
  • key:文档标识符
  • outputtype:输入文档类型
  • title:题目
  • url:文档门路

另外在header中须要申明承受类型Accept: application/json,不然默认返回的是xml格局的数据

响应阐明

  • fileUrl:转换后文件下载门路
  • percent:转换进度,如果async为false的话,这里永远都是100
  • endConvert:是否转换完结

如果不指定Accept默认返回的是xml,须要将fileUrl中的&aml;变成&能力拜访,不然会报403谬误

参考文档

  • 转换API

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理