清理RTF文本文本、RTF

2023-09-03 00:31:58 作者:陪你复习!

我想采取一些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.

 
精彩推荐
图片推荐