Convert 接口描述

 

将 Word 文档转换为其他文档格式,如PDF、XPS, PCL、WordXML、ODT、DOCM、RTF等。

接口方法 1:convertInRequest() 转换 Word 到指定格式

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/convertInRequest

请求参数:

参数 是否必选 类型 可选值范围 说明
file file 原文档
password string 原文档密码,没有则为null
format string doc, docx, wordml, wordxml, odt, docm, dotm, dotx, dot, rtf, pdf, xps, epub, pcl, postScript 指定要转换的目标格式

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;

namespace ConvertInRequest
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string inputFilePath = "D:/inputFile/convert.docx";
            string format = "postScript";//postScript, pcl, dot, dotx, dotm, docm, odt, wordxml, wordml, pdf, doc, docx, rtf, epub, xps, html
            string password = null;
            Stream inputfile = new FileStream(inputFilePath, FileMode.Open);
            convertApi.ConvertInRequest(inputfile, format, password);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

import java.io.File;

public class ConvertInRequest {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String inputFilePath = "D:/inputFile/convert.docx";
        String format = "postScript";//postScript, pcl, dot, dotx, dotm, docm, odt, wordxml, wordml, pdf, doc, docx, rtf, epub, xps, html
        String password = null;
        File inputFile = new File(inputFilePath);
        convertApi.convertInRequest(inputFile, format, password);
    }
}

接口方法 2:convert() 转换 Word 到指定格式

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/convert

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录
format string doc, docx, wordml, wordxml, odt, docm, dotm, dotx, dot, rtf, pdf, xps, epub, pcl, postScript 指定要转换的目标格式

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace Convert
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "convert.docx";
            string format = "xps";//postScript, pcl, dot, dotx, dotm, docm, odt, wordxml, wordml, pdf, doc, docx, rtf, epub, xps, html
            string password = null;
            string folder = "input";
            string storage = null;
            string destFilePath = "output/convert_output.xps";
            convertApi.Convert(name, format, destFilePath, password, folder, storage);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

public class Convert {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "convert.docx";
        String format = "xps";//postScript, pcl, dot, dotx, dotm, docm, odt, wordxml, wordml, pdf, doc, docx, rtf, epub, xps, html
        String password = null;
        String folder = "input";
        String storage = null;
        String destFilePath = "output/convert_output.xps";
        convertApi.convert(name, format, destFilePath, password, folder, storage);
    }
}

接口方法 3:convertToHmtlInRequest() 转换 Word 到 Html

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/convertToHtmlInRequest

请求参数:

参数 是否必选 类型 可选值范围 说明
file file 原文档
password string 原文档密码,没有则为null

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;

namespace ConvertToHtmlInRequest
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            Stream inputFile = new FileStream("D:/inputFile/convertInRequest.docx", FileMode.Open);
            string password = null;
            var response = convertApi.ConvertToHtmlInRequest(inputFile, password);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

import java.io.File;

public class ConvertToHtmlInRequest {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        File inputFile = new File("D:/inputFile/convertInRequest.docx");
        String password = null;
        File reponse = convertApi.convertToHtmlInRequest(inputFile, password);
    }
}

接口方法 4:convertToHmtl() 转换 Word 到 Html

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/convertToHtml

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
password string 原文档密码,没有则为null
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace ConvertToHtml
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "convertToHtml.docx";
            string password = null;
            string folder = "input";
            string storage = null;
            string destFolder = "output/convertToHtml";
            convertApi.ConvertToHtml(name, destFolder, password, folder, storage);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

public class ConvertToHtml {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "convertToHtml.docx";
        String password = null;
        String folder = "input";
        String storage = null;
        String destFolder = "output/convertToHtml";
        convertApi.convertToHtml(name, destFolder, password, folder, storage);
    }
}

接口方法 5:ConvertToPdf() 转换 Word 到 Pdf

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/convertToPdf

请求参数:

参数

是否必选

类型

可选值范围

说明

name

string

 

源文档名称

password

string

 

源文档密码,没有则为null

folder

string

 

存放源文档的文件夹,没有则为null

storage

string

 

文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null

destFilePath

string

 

结果文档的存贮路径,如果省略该参数,则默认存到根目录

privateFonts

array[object]

 

私有字体列表信息

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
using System.Collections.Generic;

namespace ConvertToPdf
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "convertToPdf.docx";
            string password = null;
            string folder = "input";
            string storage = null;
            string destFilePath = "output/convertToPdf_out.pdf"; ;
            var privateFonts = new List<PrivateFont>();
            privateFonts.Add(new PrivateFont("黑体", "input/simhei.ttf", true));
            privateFonts.Add(new PrivateFont("consola", "input/consola.ttf", true));
            convertApi.ConvertToPdf(name, destFilePath, password, folder, storage, privateFonts);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;
import spire.cloud.word.sdk.client.model.PrivateFont;

import java.util.ArrayList;
import java.util.List;

public class test {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "convertToPdf.docx";
        String password = null;
        String folder = "input";
        String storage = null;
        String destFilePath = "output/convertToPdf_out.pdf";
        List privateFonts = new ArrayList<PrivateFont>();
        privateFonts.add(new PrivateFont("黑体", "input/simhei.ttf"));
        privateFonts.add(new PrivateFont("consola", "input/consola.ttf"));
        convertApi.convertToPdf(name, destFilePath, password, folder, storage, privateFonts);
    }
}

接口方法 6:ConvertToVectorgraphInRequest() 转换 Word 到矢量图形

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/convertToVectorgraphInRequest

请求参数:

参数

是否必选

类型

可选值范围

说明

inputFile

file

 

源文档

password

string

 

源文档密码,没有则为null

startPage

integer

 

起始页索引,从0开始计数,如果改参数被省略,则默认为0

pageCount

integer

 

页数,如果改参数被省略,则默认为文档的总页数

imageType

string

wmf, svg

矢量图类型

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;

namespace ConvertToVectorgraphInRequest
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            Stream inputFile = new FileStream("D:/inputFile/convertToVectorgraphInRequest.docx", FileMode.Open);
            string imageType = "wmf";//wmf, svg
            string password = null;
            int? startPage = null;
            int? pageCount = null;
            convertApi.ConvertToVectorgraphInRequest(inputFile, imageType, password, startPage, pageCount);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

import java.io.File;

public class ConvertToVectorgraphInRequest {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        File inputFile = new File("D:/inputFile/convertToVectorgraphInRequest.docx");
        String imageType = "wmf";//wmf, svg
        String password = null;
        Integer startPage = null;
        Integer pageCount = null;
        convertApi.convertToVectorgraphInRequest(inputFile, imageType, password, startPage, pageCount);
    }
}

接口方法 7:ConvertToVectorgraph() 转换 Word 到矢量图形

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/convertToVectorgraph

请求参数:

参数

是否必选

类型

可选值范围

说明

name

string

 

源文档名称

password

string

 

源文档密码,没有则为null

folder

string

 

存放源文档的文件夹,没有则为null

storage

string

 

文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null

startPage

integer

 

起始页索引,从0开始计数,如果改参数被省略,则默认为0

pageCount

integer

 

页数,如果改参数被省略,则默认为文档的总页数

imageType

string

wmf, svg

矢量图类型

destFolder

string

 

结果文档的存贮文件夹,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace ConvertToVectorgraph
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "convertToVectorgraph.docx";
            string imageType = "wmf";//wmf, svg
            string password = null;
            string folder = "input";
            string storage = null;
            int? startPage = null;
            int? pageCount = null;
            string destFolder = "output/vectorgraph/";
            convertApi.ConvertToVectorgraph(name, imageType, destFolder, password, folder, storage, startPage, pageCount);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

public class ConvertToVectorgraph {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "convertToVectorgraph.docx";
        String imageType = "wmf";//wmf, svg
        String password = null;
        String folder = "input";
        String storage = null;
        Integer startPage = null;
        Integer pageCount = null;
        String destFolder = "output/vectorgraph/";
        convertApi.convertToVectorgraph(name, imageType, destFolder, password, folder, storage, startPage, pageCount);
    }
}

接口方法 8:ConvertToBitmapInRequest() 转换 Word 到 Bitmap 图形

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/convertToBitmapInRequest

请求参数:

参数

是否必选

类型

可选值范围

说明

inputFile

file

 

源文档

password

string

 

源文档密码,没有则为null

startPage

integer

 

起始页索引,从0开始计数,如果改参数被省略,则默认为0

pageCount

integer

 

页数,如果改参数被省略,则默认为文档的总页数

imageType

string

jpeg, bmp, png

图片格式

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;

namespace ConvertToBitmapInRequest
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            Stream inputFile = new FileStream("D:/inputFile/convertToBitmapInRequest.docx", FileMode.Open);
            string imageFormat = "jpeg";//jpeg, bmp, png
            string password = null;
            int? startPage = null;
            int? pageCount = null;
            var response = convertApi.ConvertToBitmapInRequest(inputFile, imageFormat, password, startPage, pageCount);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

import java.io.File;

public class ConvertToBitmapInRequest {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        File inputFile = new File("D:/inputFile/convertToBitmapInRequest.docx");
        String imageFormat = "jpeg";//jpeg, bmp, png
        String password = null;
        Integer startPage = null;
        Integer pageCount = null;
        File response = convertApi.convertToBitmapInRequest(inputFile, imageFormat, password, startPage, pageCount);
    }
}

接口方法 9:ConvertToBitmap() 转换 Word 到 Bitmap 图形

HTTP 请求方法:PUT

请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/convertToBitmap

请求参数:

参数

是否必选

类型

可选值范围

说明

name

string

 

源文档名称

password

string

 

源文档密码,没有则为null

folder

string

 

存放源文档的文件夹,没有则为null

storage

string

 

文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null

startPage

integer

 

起始页索引,从0开始计数,如果改参数被省略,则默认为0

pageCount

integer

 

页数,如果改参数被省略,则默认为文档的总页数

imageType

string

jpeg, bmp, png

图片格式

destFolder

string

 

结果文档的存贮文件夹,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace ConvertToBitmap
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static ConvertApi convertApi = new ConvertApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "convertToBitmap.docx";
            string imageFormat = "jpeg";//jpeg, bmp, png
            string password = null;
            string folder = "input";
            string storage = null;
            int? startPage = null;
            int? pageCount = null;
            string destFolder = "output/bitmap/";
            convertApi.ConvertToBitmap(name, imageFormat, destFolder, password, folder, storage, startPage, pageCount);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.ConvertApi;

public class test {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static ConvertApi convertApi = new ConvertApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "convertToBitmap.docx";
        String imageFormat = "jpeg";//jpeg, bmp, png
        String password = null;
        String folder = "input";
        String storage = null;
        Integer startPage = null;
        Integer pageCount = null;
        String destFolder = "output/ConvertToBitmap_jpeg/";
        convertApi.convertToBitmap(name, imageFormat, destFolder, password, folder, storage, startPage, pageCount);
    }
}