从Xamarin Android webview / MVC FileContentResult下载PDF

时间:2017-03-09 18:30:04

标签: android asp.net-mvc pdf webview xamarin.android

我从第三方工具获取PDF,然后返回FileContentResult。从我的笔记本电脑浏览器中,可以完美地下载PDF。

如果我访问该页面,其上有下载按钮,当它在Xamarin webview中时,它什么都不做。如果我做一个view.Context.StartActivity(intent);要从Xamarin应用程序外部弹出pdf,它会将我发送到我的应用程序登录页面。

    public FileContentResult DownloadPDF(decimal? id, decimal? id2)
    {
        // getting the pdf from third party tool
        var token = new Token(id.ToString(), UserInfo.Branch.ToString());
        token.GetToken();
        var download = new PDFDownload();
        var response = download.DownloadPDF(token.Token);
        var bytesArray = response.RawBytes;

        var ms = new MemoryStream(bytesArray);
        var result = new FileContentResult(bytesArray, "application/pdf")
        {
            FileDownloadName = id.ToString().Trim() + ".pdf"
        };

        return result;
    }

我尝试将PDF放在iframe中,它可以在本地浏览器上运行,但不能在webview中运行。

我也尝试使用https://docs.google.com/gview?embedded=true&url=,但显然当视图返回FileContentResult时这不起作用。

有没有人成功地让这个工作?

0 个答案:

没有答案
相关问题