How can we show .rtf or .doc as flowdocument in WP

2020-07-08 08:08发布

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条回答
姐就是有狂的资本
2楼-- · 2020-07-08 08:12

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.

查看更多
登录 后发表回答