云端Office处理工具Spire.Cloud.Word基础教程:将Word文档转换为PDF/XPS等其他格式

Spire.Cloud提供了四种语言的SDK(包括.NET、Java、python、PHP),你可以Spire.Cloud Web SDK

步骤1:dll文件获取及引用。下载获取Spire.Cloud.Word.SDK package,并将Spire.Cloud.Word.Sdk.dll及其依赖项的dll添加引用至程序(如下图)

步骤2:ID及Key获取。在冰蓝云 页注册账 并登陆,在“我的应用”板块创建应用程序,获得 App ID 及 App Key。

云端Office处理工具Spire.Cloud.Word基础教程:添加 Word 水印添加、修改、删除Word段落

步骤4:在.NET程序中编写代码操作input文件夹下的文档。

具体代码操作方法,请参考以下内容。

示例1:转换Word到PDF

using Spire.Cloud.Word.Sdk.Api;using Spire.Cloud.Word.Sdk.Client;using System;namespace ConvertWordToPdf{    class Program    {        static String appId = "App ID";        static String appKey = "App Key";        static void Main(string[] args)        {            //配置App ID和App Key            Configuration configuration = new Configuration(appId, appKey);            //初始化ConvertApi对象            ConvertApi convertApi = new ConvertApi(configuration);            //现有文档名称            string name = "示例文档.docx";            //转换的目标格式            string format = "pdf";            //文档的打开密码            string password = null;            //存放现有文档的文件夹,如果没有文件夹则为null            string folder = "input";            //存放现有文档的文件夹,如果没有文件夹则为null            string storage = null;            //设置生成文档的路径及名称            string destFilePath = "output/ToPDF.pdf";            //将Word转为PDF            convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);        }    }}

云端Office处理工具Spire.Cloud.Word基础教程:将Word文档转换为PDF/XPS等其他格式

示例2:转换Word到XPS

using Spire.Cloud.Word.Sdk.Api;using Spire.Cloud.Word.Sdk.Client;using System;namespace ConvertWordToXPS{    class Program    {        static String appId = "App ID";        static String appKey = "App Key";        static void Main(string[] args)        {            //配置App ID和App Key            Configuration configuration = new Configuration(appId, appKey);            //初始化ConvertApi对象            ConvertApi convertApi = new ConvertApi(configuration);            //现有文档名称            string name = "示例文档.docx";            //转换的目标格式            string format = "xps";            //文档的打开密码            string password = null;            //存放现有文档的文件夹,如果没有文件夹则为null            string folder = "input";            //存放现有文档的文件夹,如果没有文件夹则为null            string storage = null;            //设置生成文档的路径及名称            string destFilePath = "output/ToXPS.xps";            //将Word转为XPS            convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);        }    }}

云端Office处理工具Spire.Cloud.Word基础教程:将Word文档转换为PDF/XPS等其他格式

是E-iceblue官方友好合作伙伴,如果您对Spire

.Cloud感兴趣或需要临时License,可以联系在线客服了解具体授权价格和使用机制。

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年4月15日
下一篇 2020年4月15日

相关推荐

发表回复

登录后才能评论