Document support (rtf, doc, docx) for UWP/Windows 10 Mobile

孤街醉人 提交于 2019-12-05 19:47:15

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.

This is the code:

XAML:

<WebView x:Name="MyWebView"/>

Code behind:

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 can actually handle RTF files with RichEditBox - for more info about that see here in the official documentation (I don't know about RichTextBlock). For Docx support I can recommend a third-party library by Syncfusion, which you can get for free if you meet certain requirements.

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