c 把rtf 转换成 html,如何把rtf、doc文件转换为HTML文件

//retText是路径

1 public string ExtractHtml(string rtfText)

{

try

{

//Create word object

Word.Application applicationObject = new Word.Application();

Type wordType = applicationObject.GetType();

//define path for save your temporary file.

string userTemp = @"F:\Code\DisplayPrintfile\DisplayPrintfile\file\";

//Open and save your rtf as HTML in your temp path.

object missing = Type.Missing;

object fileName = rtfText;

object False = false;

object rtfFileFormt = Word.WdSaveFormat.wdFormatRTF;

applicationObject.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;

Word.Document documentObject =applicationObject.Documents.Open(ref fileName, ref missing, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing,

ref missing, ref missing, ref False, ref missing, ref missing,

ref missing, ref missing);

object tempFileName =@"F:\Code\DisplayPrintfile\DisplayPrintfile\file\tempHtm.html";

object fileFormt = Word.WdSaveFormat.wdFormatHTML;

object makeFalse = false;

object makeTrue = true;

string absolutePath = tempFileName.ToString();

if (File.Exists(absolutePath))

{

try

{

File.Delete(absolutePath);

}

catch { }

}

documentObject.SaveAs(ref tempFileName, ref fileFormt,

ref makeFalse, ref missing, ref makeFalse,

ref missing, ref missing, ref missing, ref makeFalse, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref missing);

GC.Collect();

GC.WaitForPendingFinalizers();

documentObject.Close(ref makeFalse, ref missing, ref missing);

GC.Collect();

GC.WaitForPendingFinalizers();

//File.Delete(rtfText);

String htmlCode = "";

//Extract html source from the temporary html file.

if (File.Exists(absolutePath))

{

WebClient client = new WebClient();

htmlCode = client.DownloadString(absolutePath);

GC.Collect();

GC.WaitForPendingFinalizers();

try

{

File.Delete(absolutePath);

}

catch { }

}

else

{

htmlCode = "";

}

return htmlCode;

}

catch

{

return "";

}

}

Python如何实现doc文件转换为docx文件?

Python如何实现doc文件转换为docx文件? 在开发过程中遇到一个关于读写doc和docx的问题: 一个文件夹中有两种文件, 一种为doc结尾, 一种为docx结尾, 需要将这些文件全部重命名. ...

使用VirtualBox把IMG文件转换为VDI文件

使用VirtualBox把IMG文件转换为VDI文件 首先确保已安装VirtualBox. 需要使用的命令: 语法:$ VBoxManage convertdd input.img output.vd ...

python之模块py_compile用法(将py文件转换为pyc文件)

# -*- coding: cp936 -*- #python 27 #xiaodeng #python之模块py_compile用法(将py文件转换为pyc文件):二进制文件,是由py文件经过编译后 ...

APNS .p12文件转换为 .pem文件

1:先用mac的钥匙串工具,把APN的推送证书转换为 .p12文件: 2:在mac的终端下 把.p12文件转换为 .pem文件 openssl pkcs12 -in apns-dev-cert.p12 ...

TensorFlow的checkpoint文件转换为pb文件

由于项目需要,需要将TensorFlow保存的模型从ckpt文件转换为pb文件. import os from tensorflow.python import pywrap_tensorflow f ...

GIF文件转换为头文件工具

目的: GIF文件转为头文件 举例: 用UE打开GIF文件,如下图所示:图1 test.gif文件将上面文件内容转化为头文件,放到一个数组里面,内容如下:图2 test.h文件 思路: 从上面可知,将 ...

bat文件转换为exe文件

批处理文件转换为exe文件(简单的处理文件),点击下载 使用超简单的了,不多说.

实战FFmpeg--iOS平台使用FFmpeg将视频文件转换为YUV文件

做播放器的开发这里面涉及的东西太多,我只能一步步往前走,慢慢深入.播放器播放视频采用的是渲染yuv文件.首先,要知道yuv文件是怎么转换得来的,其次,要知道怎么把视频文件保存为yuv文件.雷神的文章1 ...

将图片文件转换为.py文件

最近用wxpython写了一个脚本,其中要给窗体设置图标文件,需要单独的一个ico文件,这样就比较影响美观,另外打包的时候还要将图标文件一起打包很繁琐.这时候看到wxpython文件有一个工具img2 ...

php如何将base64数据流文件转换为图片文件?

2017-03-07 在开发中,自己遇到一个前端在上传图片的时候,使用的base64数据流文件显示的图片. 也就是说

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值