我们如何在WPF中将.rtf或.doc显示为flowdocument?

时间:2009-10-26 04:22:08

标签: wpf flowdocument

这是应用程序的帮助部分。我想把flowdocumentReader放到显示帮助文档。但是有可能在Flowdocument中显示.rtf或任何.doc。或者在Xaml中创建流文档是必要的。请帮忙。

谢谢,

1 个答案:

答案 0 :(得分:13)

这些行上的某些内容将为您完成任务,其中documentPath是您的rtf文件路径:

FileStream fileStream = File.Open(documentPath, FileMode.Open, FileAccess.Read, FileShare.Read);

FlowDocument flowDocument = new FlowDocument();

TextRange textRange = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);

textRange.Load(fileStream , DataFormats.Rtf);

请添加错误检查代码。

相关问题