文档转换成 pdf 您所在的位置:网站首页 wps可以word转pdf 文档转换成 pdf

文档转换成 pdf

2023-11-13 23:33| 来源: 网络整理| 查看: 265

文档转换成 pdf #

将文档格式转换成 pdf

基本信息 #

请求路径:POST /api/developer/v1/office/convert/to/pdf

限流频次 #目前支持的文档类型 #文档类型扩展名演示.pptx .pptWPS 文字.docx .docWPS 表格.xlsx .xlsHeader 参数 #参数必须类型说明Date是string使用 RFC1123 时间格式的当前时间Content-Md5是stringHTTP Body 中数据的 MD5 值十六进制表达方式, 必需小写, 如果是 get 请求一律使用 URI 计算 MD5Content-Type是string目前固定为: application/jsonAuthorization是string"WPS-2:" + app_id + ":" + sha1( app_key + Content-Md5 + Content-Type + DATE)Body 参数 #参数必须类型说明url是string文档下载地址filename是string文档名称,包含扩展名,例如:文字文稿.docxpassword否string文档打开密码(如果文档有加密,该项则必填)ranges否string自定义需要转换的分页范围,例如:"1,2-4,7",则表示转换文档的 1、2、3、4、7 页面 (与 from_page和to_page 互斥)from_page否int转换起始页,从 1 开始计数(与 ranges互斥)to_page否int转换结束页,需要大于 from_page, (与 ranges互斥)show_comments否int是否显示批注。默认值为 false,不显示批注返回参数 #参数必须类型说明code是integer错误码+data是data {}响应数据task_id是string转换任务 id示例 #请求示例 #curl --request POST \ --url https://solution.wps.cn/api/developer/v1/office/convert/to/pdf \ --header 'Authorization: WPS-2:******:ac59dac1460772a04b3a97d7ef78409f28241e3a' \ --header 'Content-Md5: d41d8cd98f00b204e9800998ecf8427e' \ --header 'Content-Type: application/json' \ --header 'Date: Wed, 23 Jan 2013 06:43:08 GMT' \ --data '{"url":"https://xxx.com/xxx","filename":"文字文稿.docx"}' OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\"url\":\"https://xxx.com/xxx\",\"filename\":\"文字文稿.docx\"}"); Request request = new Request.Builder() .url("https://solution.wps.cn/api/developer/v1/office/convert/to/pdf") .post(body) .addHeader("Date", "Wed, 23 Jan 2013 06:43:08 GMT") .addHeader("Content-Md5", "d41d8cd98f00b204e9800998ecf8427e") .addHeader("Content-Type", "application/json") .addHeader("Authorization", "WPS-2:******:ac59dac1460772a04b3a97d7ef78409f28241e3a") .build(); Response response = client.newCall(request).execute(); package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://solution.wps.cn/api/developer/v1/office/convert/to/pdf" payload := strings.NewReader("{\"url\":\"https://xxx.com/xxx\",\"filename\":\"文字文稿.docx\"}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Date", "Wed, 23 Jan 2013 06:43:08 GMT") req.Header.Add("Content-Md5", "d41d8cd98f00b204e9800998ecf8427e") req.Header.Add("Content-Type", "application/json") req.Header.Add("Authorization", "WPS-2:******:ac59dac1460772a04b3a97d7ef78409f28241e3a") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } import http.client conn = http.client.HTTPSConnection("solution.wps.cn") payload = "{\"url\":\"https://xxx.com/xxx\",\"filename\":\"文字文稿.docx\"}" headers = { 'Date': "Wed, 23 Jan 2013 06:43:08 GMT", 'Content-Md5': "d41d8cd98f00b204e9800998ecf8427e", 'Content-Type': "application/json", 'Authorization': "WPS-2:******:ac59dac1460772a04b3a97d7ef78409f28241e3a" } conn.request("POST", "/api/developer/v1/office/convert/to/pdf", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有