清理RTF文本 [英] Cleaning up RTF text

查看:210
本文介绍了清理RTF文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想采取一些RTF格式输入,并进行清洁,以清除所有的RTF格式除了\ UL \ B \我将其粘贴到Word轻微格式的信息。

I'd like to take some RTF input and clean it to remove all RTF formatting except \ul \b \i to paste it into Word with minor format information.

用于粘贴到Word中的命令是这样的: oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0)(有一些RTF在剪贴板中已经文本)

The command used to paste into Word will be something like: oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) (with some RTF text already in the Clipboard)

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\colortbl ;\red255\green255\blue140;}
\viewkind4\uc1\pard\highlight1\lang3084\f0\fs18 The company is a global leader in responsible tourism and was \ul the first major hotel chain in North America\ulnone  to embrace environmental stewardship within its daily operations\highlight0\par

你对我怎么可以放心地清理RTF一些常规的前pressions什么的任何想法?我使用VB.NET做了处理,但任何.NET语言的样本就可以了。

Do you have any idea on how I can clean up the RTF safely with some regular expressions or something? I am using VB.NET to do the processing but any .NET language sample will do.

推荐答案

我会用一个隐藏的RichTextBox,设置RTF成员,则检索文本成员消毒RTF在良好的支持方式。然后,我会用手动之后注入所需的格式。

I would use a hidden RichTextBox, set the Rtf member, then retrieve the Text member to sanitize the RTF in a well-supported way. Then I would use manually inject the desired formatting afterwards.

这篇关于清理RTF文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆