C# Xamarin表单在浏览器中打开PDF

C# Xamarin表单在浏览器中打开PDF,c#,pdf,xamarin,xamarin.forms,base64,C#,Pdf,Xamarin,Xamarin.forms,Base64,我想得到一个PDF文件,它是Base64编码的,以字符串的形式显示。 首先,我通过此方法将文件本地保存在手机上,并返回文件的路径: byte[] byteBuffer = Encoding.UTF8.GetBytes(pdfString); public string SaveBinary(string filename, byte[] bytes) { string filepath = GetFilePath(filename);

我想得到一个PDF文件,它是Base64编码的,以字符串的形式显示。 首先,我通过此方法将文件本地保存在手机上,并返回文件的路径:

 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));
string filename=DependencyService.Get().SaveBinary($“name.pdf”,byteBuffer);
尝试
{
OpenUri(新的Uri(文件名));

您只需使用webview即可完成此操作(例如:)


示例:

示例是404。最好是发布示例