图片转为文档 您所在的位置:网站首页 wps中图片转文字 图片转为文档

图片转为文档

2024-06-18 19:14| 来源: 网络整理| 查看: 265

图片转为文档 #

将图片转换为文档格式,当前支持的图片格式:png、 jpg、 jpeg、 bmp、 tif、 tiff、 gif。

测试应用单次最多可转换3张图片。

注意

单张图片支持的最大尺寸为50M 目前支持转换为的文档类型: #文档类型扩展名文字docx表格xlsx演示pptx基本信息 #

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

Header 参数 #参数必须类型说明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)Path 参数 #参数必须类型说明office_type是string转换为的文件类型:docx,xlsx,pptxBody 参数 #参数必须类型说明img_urls是array图片url集合text_unify否boolean统一段落字体字号,建议传truesheet_option否integer转换为表格时配置:sheet转换方式 0表示每页pdf(每页图片)一个sheet, 1表示所有页面(图片)转到一个sheet中, 默认为0返回参数 #参数必须类型说明code是integer错误码+data是data {}响应数据task_id是string转换任务 id示例 #请求示例 #curl --request POST \ --url https://solution.wps.cn/api/developer/v1/office/img/convert/to/docx \ --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 '{"img_urls":["https://***.com/***"]}' OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\"img_urls\":[\"https://***.com/***\"]}"); Request request = new Request.Builder() .url("https://solution.wps.cn/api/developer/v1/office/img/convert/to/docx") .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/img/convert/to/docx" payload := strings.NewReader("{\"img_urls\":[\"https://***.com/***\"]}") 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 = "{\"img_urls\":[\"https://***.com/***\"]}" 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/img/convert/to/docx", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

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