适用于UWP/Windows 10 Mobile的文档支持(rtf,doc,docx) [英] Document support (rtf, doc, docx) for UWP/Windows 10 Mobile

查看:87
本文介绍了适用于UWP/Windows 10 Mobile的文档支持(rtf,doc,docx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在UWP应用中显示文档(doc,docx,rtf)? WebView 无法执行此操作.

How can I display documents (doc, docx, rtf) in an UWP app? The WebView isn't able to do this.

其他选项是使用 Windows.System.Launcher.LaunchUriAsync (例如Word)或使用第三方库调用外部应用程序.要求是将数据存储在应用程序中,因为如果将数据处理给另一个应用程序,则您将无法对其进行控制.另一种选择是将其转换为UWP可以处理(不是真的)的另一种格式(例如PDF).

Other options would be calling an external application with Windows.System.Launcher.LaunchUriAsync (e.g. Word) or using a 3rd party library. The requirement is to have the data in the app, because you don't have control over it, if it's handled to another one. Another option would be to convert it to another format (e.g. PDF) which UWP can handle (not really).

有什么想法吗?

推荐答案

如果您想在UWP应用中显示word或pdf文件,则可以将WebView控件与Google Docs Viewer一起使用-我正在将其用于在线文档.

If you would like to display word or pdf files in the UWP app you can use WebView control with Google Docs Viewer - I was using it for the online documents.

这是代码:

XAML:

<WebView x:Name="MyWebView"/>

后面的代码:

public WebViewPage()
    {
        this.InitializeComponent();
        loadWebView();
    }

    void loadWebView()
    {
        var googleDocsViewer = "http://drive.google.com/viewerng/viewer?embedded=true&url=";
        var pdf = "http://www.uma.es/precarios/images/pdfs/wd-spectools-word-sample-04.doc";
        MyWebView.Navigate(new Uri(googleDocsViewer + pdf));
    }

我没有使用本地文件对其进行测试,但是我认为这也应该起作用.请尝试让我知道.

I did not test it with local files, but I think that should also work. Please try and let me know.

这篇关于适用于UWP/Windows 10 Mobile的文档支持(rtf,doc,docx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆