【问题标题】:Xamarin Forms open PDF in browserXamarin Forms 在浏览器中打开 PDF
【发布时间】:2017-09-27 15:50:21
【问题描述】:

我想获取经过 Base64 编码并以字符串形式呈现的 PDF 文件。 一开始我是通过这个方法在手机本地保存文件,并返回文件的路径:

 byte[] byteBuffer = Encoding.UTF8.GetBytes(pdfString);

 public string SaveBinary(string filename, byte[] bytes)
        {
            string filepath = GetFilePath(filename);
            if (File.Exists((filepath)))
            {
                File.Delete(filepath);
            }
            File.WriteAllBytes(filepath, bytes);

            return filepath;
        }

string GetFilePath(string filename)
        {
            return Path.Combine(GetDocsPath(), filename);
        }

        string GetDocsPath()
        {
            return System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);

        }

然后我尝试在浏览器中打开 PDF,但没有任何反应。

  string filename = DependencyService.Get<IFileWorker>().SaveBinary($"name.pdf", byteBuffer);
                try
                {
                    Device.OpenUri(new Uri(filename));

【问题讨论】:

    标签: c# pdf xamarin xamarin.forms base64


    【解决方案1】:

    【讨论】:

    • 例子是404。最好把例子贴出来
    猜你喜欢
    • 1970-01-01
    • 2011-06-12
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 2019-08-26
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多