How can we show .rtf or .doc as flowdocument in WPF?

不想你离开。 提交于 2019-12-21 11:32:12

问题


It is for the help section of the application. I am thinking to put flowdocumentReader to show the help document. But is it possible to show .rtf or any .doc to show in Flowdocument.Or is it neccesary to create a flow document in Xaml. Please help.

Thanks,


回答1:


Something on these lines will do the job for you where documentPath is your rtf file path:

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);

Do add the error checking code though.



来源:https://stackoverflow.com/questions/1623054/how-can-we-show-rtf-or-doc-as-flowdocument-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!