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

Ers*_*had 8 wpf flowdocument

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

谢谢,

Yog*_*esh 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);
Run Code Online (Sandbox Code Playgroud)

请添加错误检查代码.