CuteEditor显示rtf

    最近asp.net的项目里需要在网页中对数据库中存储的rtf数据进行显示和编辑。上网查找可用插件,找到功能强大的CuteEditor,遂上网查找到其安装使用方法(http://www.cnblogs.com/luluping/archive/2010/10/06/1844753.html)。然而装好了后却不知如何转化rtf显示为HTML,上网搜索很久未果。后来突然想到安装包里有帮助文件,查看果然有转化的详细方法如下:


1. RTF to HTML

In order to convert RTF to HTML, you would use LoadRTF Method: 

LoadRTF Method
Loads the contents of an RTF into the CuteEditor control


// Load RTF string

string t = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 Hello\par } "; 
Editor1.LoadRTF(t);
// Load RTF file
Editor1.LoadRTF("document.rtf");


2. HTML to RTF

In order to convert HTML to RTF, you would use SaveRTF Method: 

SaveRTF Method
Saves the contents of the Cute Editor to a RTF file.  The SaveRTF method enables you to save the entire contents of the control to a RTF file. If the file name that is passed to the path parameter already exists at the specified directory, the file will be overwritten without notice. You can use the LoadFile, LoadWord, LoadRTF, LoadText method to load the contents of a file into the CuteEditor

// Saves the contents of the Cute Editor to a RTF file

Editor1.SaveRTF("document.rtf");

3. Convert HTML to RTF directly
//Convert HTML to RTF directly

string t="<b>Hello world</b>"; 
CuteEditor.Convertor.RTF.HTML2RTF html2rtf = new CuteEditor.Convertor.RTF.HTML2RTF(t); 
textbox1.Text = html2rtf.RTF; // Get the RTF string using the RTF property


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值