利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。
首先利用 Nuget 获取 Aspose.Words.dll
public ActionResult AsposeWordsDemo()
{
string srcFileName = Server.MapPath("~/Data/a.doc");
Document doc = new Document(srcFileName); string basicDirVirtualPath = "/UploadFiles/"; string tempDir = Server.MapPath(basicDirVirtualPath); HtmlSaveOptions saveOptions = new HtmlSaveOptions();
// Specify folder where images will be saved.
saveOptions.ImagesFolder = tempDir;
// We want the images in the HTML to be referenced in the e-mail as attachments so add the cid prefix to the image file name.
// This replaces what would be the path to the image with the "cid" prefix.
saveOptions.ImagesFolderAlias = basicDirVirtualPath;
// Header footers don't normally export well in HTML format so remove them.
saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.None; // saveOptions.ExportHeadersFooters = false; // 老版本用这个 // Save the document to stream in HTML format.
MemoryStream htmlStream = new MemoryStream();
doc.Save(htmlStream, saveOptions); // Read the HTML from the stream as plain text.
string htmlText = Encoding.UTF8.GetString(htmlStream.ToArray());
htmlStream.Close(); // Save the HTML into the temporary folder. string htmlFileNameWithoutPath = "Message.html"; Stream htmlFile = new FileStream(Path.Combine(tempDir, htmlFileNameWithoutPath), FileMode.Create);
StreamWriter htmlWriter = new StreamWriter(htmlFile);
htmlWriter.Write(htmlText);
htmlWriter.Close();
htmlFile.Close(); return Redirect(basicDirVirtualPath + htmlFileNameWithoutPath);
}
利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。的更多相关文章
- java调用com组件将office文件转换成pdf
在非常多企业级应用中都涉及到将office图片转换成pdf进行保存或者公布的场景,由于pdf格式的文档方便进行加密和权限控制(类似于百度文库).总结起来眼下将office文件转换 成pdf的方法主要有 ...
- 微信小程序中利用时间选择器和js无计算实现定时器(将字符串或秒数转换成倒计时)
转载注明出处 改成了一个单独的js文件,并修改代码增加了通用性,点击这里查看 今天写小程序,有一个需求就是用户选择时间,然后我这边就要开始倒计时. 因为小程序的限制,所以直接选用时间选择器作为选择定时 ...
- win2008在组件服务中未找到office组件服务
在win2003系统,cmd中输入 dcomcnfg ,组件服务里面找到office的组件服务,但win2008 R2 64位操作系统需要输入comexp.msc -32 tks:http://www ...
- nodejs将PDF文件转换成txt文本,并利用python处理转换后的文本文件
目前公司Web服务端的开发是用Nodejs,所以开发功能的话首先使用Nodejs,这也是为什么不直接用python转换的原因. 由于node对文本的处理(提取所需信息)的能力不强,类似于npm上的包: ...
- 解决本地调用office组件成功,但是发布到IIS中出现的错误(检索COM类工厂中CLSID为{00024500-0000-0000-C000-000000000046}的组件时失败)
在C#操作word或者Excel,我们可能会用到微软内置的COM组件,会出现很多问题. 如:在本地调试导出Excel没有问题,发布到IIS就有问题了,检测到的异常: 我们会发现在iis上运行的程序,没 ...
- 【转】 (C#)利用Aspose.Cells组件导入导出excel文件
Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: public static System.Data.DataTable ReadExcel(String strFi ...
- (C#)利用Aspose.Cells组件导入导出excel文件
Aspose.Cells组件可以不依赖excel来导入导出excel文件: 导入: public static System.Data.DataTable ReadExcel(String strFi ...
- 3: 组件间的依赖管理 Managing Dependencies Between Components Using the Prism Library 5.0 for WPF(英汉对照版)
Applications based on the Prism Library are composite applications that potentially consist of many ...
- Prism 文档 第三章 管理组件之间的依赖关系
第3章:管理组件之间的依赖关系 基于Prism库的复合应用程 ...
随机推荐
- phpredis的使用
phpredis的具体使用方法可以参照:https://github.com/phpredis/phpredis
- 三个Telnet链接类----来自网络
声明:下面的三个类都是从网上找到的,具体出处不详,哪个类的好坏性能优劣自己把握,可参考使用.拒绝使用商业用途,如产生版权纠纷和本人无关. 一:Telnet链接网络设备,在网上看到C#Telnet连接网 ...
- linux下修改ip地址
1.more /etc/sysconfig/network-scripts/ifcfg-eth0 2.ifconfig eth0 192.168.1.211 netmask 255.255.255. ...
- SpringMVC集成rabbitMQ
Maven引入相关jar <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-c ...
- FastAdmin 社区 FAQ 帖子收集(F4NNIU 版 2018-08-12)
FastAdmin 社区 FAQ 帖子收集 为什么Selectpage下拉列表在编辑时总是返回第一行的值? https://forum.fastadmin.net/thread/2399 根据条件值判 ...
- RelativeLayout里的gravity不能居中的解决方法
最近在遇到RelativeLayout里的gravity属性给它复制center_horizontal或者center都不能居中它的子组件,后来找到了替代方法,只要在它的每个子组件里加上android ...
- List,ArrayList
List是一个接口,而ListArray是一个类. ListArray继承并实现了List. 所以List不能被构造,但可以向上面那样为List创建一个引用,而ListArray就可以被构造. Lis ...
- LaunchImage添加以及设置无效处理
1.添加LaunchImage 2.添加所需要图片即可,出现un..可以删除,警告也随之而去,并删除LauchImage Assets之后重新添加 3.确定设置是否一样 4.发现启动后加载不了启动图, ...
- hdu 5706 GirlCat(BFS)
As a cute girl, Kotori likes playing ``Hide and Seek'' with cats particularly. Under the influence o ...
- Java-Runoob:Java 基本数据类型
ylbtech-Java-Runoob:Java 基本数据类型 1.返回顶部 1. Java 基本数据类型 变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间. 内存管理系统根 ...