本文介绍通过调用Spire.Cloud.Word.SDK提供的ConvertApi接口将Word转换为PDF、XPS、Epub、RTF以及将Docx转为Doc格式等。调用接口方法及步骤参考以下内容:

步骤一:dll文件获取及导入。通过官网本地下载SDK文件包。(须在e-iceblue中国官网在线编辑板块中注册账号并登录)

下载后,解压文件,将Spire.Cloud.Word.Sdk.dll文件及其他三个dll添加引用至VS程序;或者在程序中通过Nuget搜索下载,直接导入所有dll。dll引用结果如下图所示:

步骤二:App ID及Key获取。在“我的应用”板块中创建应用以获得App ID及App Key。

步骤三:源文档上传。在“文档管理”板块,上传源文档。这里可以建文件夹,将文档存放在文件夹下。不建文件夹时,源文档及结果文档直接保存在根目录。本文示例中,建了两个文件夹,分别用于存放源文档及结果文档。(云平台提供免费1 万次调用次数和 2G 文档内存)

C# 代码示例

1. WordPDF

using System;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Api; namespace WordToPDF
{
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 = "Sample.docx";//源文档
string format = "pdf";//转换的目标文档格式
string password = null;//源文档
string folder = "input";//源文档所在文件夹,如果没有文件夹则为null
string storage = null;//使用冰蓝云配置的2G空间存贮文档,可设置为null
string destFilePath = "output/WordToPDF.pdf";//结果文档路径(结果文档保存在output文件夹下) //调用方法将Word转为PDF
convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);
}
}
}

2. WordXPS

using System;
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client; namespace WordToXPS
{
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 = "Sample.docx"; //源文档
string format = "xps";//转换的目标文档格式
string password = null;//源文档密码
string folder = "input";//源文档的文件夹,如果没有文件夹则为null
string storage = null;//使用冰蓝云配置的2G空间存贮文档,可设置为null
string destFilePath = "output/WordToXPS.xps";//结果文档路径及名称(结果文档保存在output文件夹下) //调用方法将Word转为XPS
convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);
}
}
}

3. WordEpub

using System;
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client; namespace WordToEpub
{
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 = "Sample.docx"; //源文档
string format = "epub";//转换的目标文档格式
string password = null;//源文档密码
string folder = "input";//源文档的文件夹,如果没有文件夹则为null
string storage = null;//使用冰蓝云配置的2G空间存贮文档,可设置为null
string destFilePath = "output/WordToEpub.epub";//结果文档路径及名称(结果文档保存在output文件夹下) //调用方法将Word转为Epub
convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);
}
}
}

4. WordRTF

using System;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Api; namespace WordToRTF
{
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 = "Sample.docx"; //源文档
string format = "rtf";//转换的目标文档格式
string password = null;//源文档密码
string folder = "input";//源文档的文件夹,如果没有文件夹则为null
string storage = null;//使用冰蓝云配置的2G空间存贮文档,可设置为null
string destFilePath = "output/WordToRTF.rtf";//结果文档路径及名称(结果文档保存在output文件夹下) //调用方法将Word转为RTF
convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);
}
}
}

5. DocxDoc

using System;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Api; namespace DocxToDoc
{
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 = "Sample.docx"; //源文档
string format = "doc";//转换的目标文档格式
string password = null;//源文档密码
string folder = "input";//源文档的文件夹,如果没有文件夹则为null
string storage = null;//使用冰蓝云配置的2G空间存贮文档,可设置为null
string destFilePath = "output/DocxToDoc.doc";//结果文档路径及名称(结果文档保存在output文件夹下) //调用方法将Docx转为Doc
convertApi.ConvertDocument(name, format, password, folder, storage, destFilePath);
}
}
}

(本文完)

C# 将Word转为PDF、XPS、Epub、RTF(基于Spire.Cloud.Word.SDK)的更多相关文章

  1. C# 添加、删除、读取Word形状(基于Spire.Cloud.Word.SDK)

    本文介绍调用Spire.Cloud.Word.SDK提供的接口shapesApi来操作Word形状,包括添加形状AddShape(),添加形状时,可设置形状类型.颜色.大小.位置.倾斜.轮廓.文本环绕 ...

  2. C# 设置、删除、读取Word文档背景——基于Spire.Cloud.Word

    Spire.Cloud.Word.Sdk提供了接口SetBackgroudColor().SetBackgroudImage().DeleteBackground().GetBackgroudColo ...

  3. Java 添加、下载、读取PDF附件信息(基于Spire.Cloud.SDK for Java)

    Spire.Cloud.SDK for Java提供了PdfAttachmentsApi接口添加附件addAttachment().下载附件downloadAttachment().获取附件信息get ...

  4. C# 添加文本、图片到PDF文档(基于Spire.Cloud.PDF.SDK)

    Spire.Cloud.PDF.SDK提供了接口PdfTextApi及PdfImagesApi用于添加文本和图片到PDF文档,添加文本时,可格式化文本样式,包括文本字体类型.字号.字体样式.文本颜色. ...

  5. C# 加密、解密PDF文档(基于Spire.Cloud.SDK for .NET)

    Spire.Cloud.SDK for .NET提供了接口PdfSecurityApi可用于加密.解密PDF文档.本文将通过C#代码演示具体加密及解密方法. 使用工具: Spire.Cloud.SDK ...

  6. Java 将Word转为PDF、PNG、SVG、RTF、XPS、TXT、XML

    同一文档在不同的编译或阅读环境中,需要使用特定的文档格式来打开,通常需要通过转换文档格式的方式来实现.下面将介绍在Java程序中如何来转换Word文档为其他几种常见文档格式,如PDF.图片png.sv ...

  7. C# 将PDF转为Word、Html、XPS、SVG、PCL、PS——基于Spire.Cloud.PDF

    Spire.Cloud.PDF提供了接口PdfConvertApi可用于将PDF文档转换为其他格式文档,如Word(docx/doc).Html.XPS.SVG.PCL.PS.Png以及XPS转成PD ...

  8. ASP.NET Word转为PDF

    1.首先安装 Microsoft Office 2007加载项:Microsoft Save as PDF-简体中文版:下载地址: http://download.microsoft.com/down ...

  9. Java 基于Spire.Cloud.Excel 将Excel转为PDF

    Spire.Cloud.Excel Sdk 提供GeneralApi接口和WorkbookApi接口,支持将本地Excel和云端Excel文档转换为ODS, PDF, XPS, PCL, PS等格式. ...

随机推荐

  1. MVC插件式开发平台

    ---恢复内容开始--- 经过DyOS.BraveOS1.0再到BraveOS2.0,系统现在已经开发了下载. 我们的目标是,网页版操作系统,可以在线安装更新软件,并提供二次开发平台,提供基础的逻辑和 ...

  2. git 删除时报 the branch is not fully merged 这是什么意思

    今天删除本地分支 git branch -d XX 提示: the branch XXX is not fully merged原因:XXX分支有没有合并到当前分支的内容 解决方法:使用大写的D 强制 ...

  3. [转]爬虫 selenium + phantomjs / chrome

    目录 selenium 模块 安装 phantomjs 浏览器 安装 chromedriver 接口 安装 对比两个接口 整合使用 基本实例 常用属性方法 定位节点 节点操作 其他操作 实例解析 - ...

  4. TSLint-Angular 配置

    代码风格和语义的检查工具,帮助规范 TS 和 Angular 代码书写: 安装: => cnpm install // 安装相关依赖 全局安装 cnpm install -g tslint ty ...

  5. laravel的Eloquent关联关系

    1.简介: 1>Eloquent 关联关系以Eloquent模型类方法的形式被定义(是模型类的一个方法). 2>同 Eloquent 模型本身一样,关联关系也是强大的查询构建器,定义关联关 ...

  6. C++的价值

    In May 2010, the GCC steering committee decided to allow use of a C++ compiler to compile GCC. The c ...

  7. H3C 单区域OSPF配置示例二

  8. 面试题 —— Ajax的基本原理总结

    Ajax 的全称是Asynchronous JavaScript and XML(异步的JavaScript 和 XML),其中,Asynchronous 是 异步 的意思,它有别于传统web开发中采 ...

  9. [POJ2528]Mayor's posters(离散化+线段树)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 70365   Accepted: 20306 ...

  10. P1919 FFT加速高精度乘法

    P1919 FFT加速高精度乘法 传送门:https://www.luogu.org/problemnew/show/P1919 题意: 给出两个n位10进制整数x和y,你需要计算x*y. 题解: 对 ...