使用此代码加载qpf
中的数据时public static void LoadRTF(string rtf, RichTextBox richTextBox)
{
if (string.IsNullOrEmpty(rtf))
{
throw new ArgumentNullException();
}
TextRange textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
//Create a MemoryStream of the Rtf content
using (MemoryStream rtfMemoryStream = new MemoryStream())
{
using (StreamWriter rtfStreamWriter = new StreamWriter(rtfMemoryStream))
{
rtfStreamWriter.Write(rtf);
rtfStreamWriter.Flush();
rtfMemoryStream.Seek(0, SeekOrigin.Begin);
//Load the MemoryStream into TextRange ranging from start to end of RichTextBox.
try
{
textRange.Load(rtfMemoryStream, DataFormats.Rtf);
}
catch { Exception ex; }
}
}
}
应用程序引发一个名为
的异常数据格式无法识别的结构'富文本格式'。\ r \ n参数名称:流
数据是
<span dir="LTR" style="font-size: 9pt; background: none repeat scroll 0% 0% transparent; font-family: "verdana","sans-serif"; color: #444444;">Abu Dhabi Retirement Pensions & Benefits Fund has announced that the Fund has fully enabled 37 electronic services provided via its online portal that was launched on June 2012. This is an indication of the Fund’s concern to convoy Abu Dhabi’s Government Vision and the Fund’s strategy. There are 17 services which are allocated for entities. 775 governmental, semi-governmental and private entities are using these services and 2716 transactions have been accomplished last July. 13 other electronic services were categorized as general services targeted the active members, pensioners, and entities in which these services were used 2056 times since they were launched. </span><span dir="LTR" style="font-size: 9pt; font-family: "verdana","sans-serif"; color: #444444;"><br /> <span style="background: none repeat scroll 0% 0% transparent;">Moreover, there are seven electronic services presented to the partners from governmental and semi-governmental entities in order to ease the exchanging of information and transactions among the entities and the Fund and to support Abu Dhabi’s government strategy to develop services. </span><br /> <span style="background: none repeat scroll 0% 0% transparent;">12 electronic services are expected to be launched for pensioners and beneficiaries and active members in 2014 which will enhance the level of the provided services.</span></span>
这是rtf格式是什么错误{\ rtf1 \ ansi \ ansicpg1252 \ uc1 \ htmautsp \ deff2 {\ fonttbl {\ f0 \ fcharset0 Times New Roman;} {\ f2 \ fcharset0 Segoe UI;} {\ f3 \ fcharset0 verdana“;}} {\ colortbl \ red0 \ green0 \ blue0; \ red255 \ green255 \ blue255; \ red68 \ green68 \ blue68;} \ loch \ hich \ dbch \ pard \ plain \ ltrpar \ itap0 {\ lang1033 \ fs18 \ f2 \ cf0 \ cf0 \ ql {\ f2 {\ loch \ f3 \ cf2 \ ltrch阿布扎比退休养老金和福利基金宣布,该基金已通过其6月推出的在线门户网站完全启用了37项电子服务这表明了基金组织对阿布扎比政府愿景和基金组织战略的关注,为实体分配了17项服务,775个政府,半政府和私营实体使用这些服务并在去年7月完成了2716项交易。其他13项电子服务被归类为针对活跃成员,养老金领取者和这些服务的实体的一般服务。自推出以来已经使用了2056次。 } \ line {\ loch \ f3 \ cf2 \ ltrch此外,政府和半政府实体向合作伙伴提供了七种电子服务,以便于实体和基金之间交流信息和交易,并支持阿布Dhabi \ rquote的政府发展服务战略。预计2014年将为养老金领取者和受益人及活跃成员推出12项电子服务,这将提高所提供服务的水平。} \ li0 \ ri0 \ sa0 \ sb0 \ fi0 \ ql \ par} } }
答案 0 :(得分:1)
span不是rtf标签,它是html,因此是“无法识别的结构”异常消息
尝试使用代码,或者将html源代码放入html&gt;首先是RTF转换器。
修改强>
好吧,所以Span不是一个有效的rtf标签,但是它是一个有效的wpf类,可以很好地进入一个flowdocument,所以我想它可以在这种情况下工作。
您的代码存在一个问题:span类似乎没有任何“dir”属性:http://msdn.microsoft.com/en-us/library/system.windows.documents.span%28v=vs.110%29.aspx
所以我建议删除dir =“ltr”(如果我没记错的话,在这种情况下无论如何都是无用的)