C# 打印pdf文件而不进行文件预览

C# 打印pdf文件而不进行文件预览,c#,android,xamarin.forms,xamarin.android,C#,Android,Xamarin.forms,Xamarin.android,我很难找到如何制作一个android应用程序,只需点击一个按钮即可打印特定的PDF文件,而无需预览或选择打印机 public void Print(Stream inputStream, string fileName) { if (inputStream.CanSeek) //Reset the position of PDF document stream to be printed inputStream.Positi

我很难找到如何制作一个android应用程序,只需点击一个按钮即可打印特定的PDF文件,而无需预览或选择打印机

public void Print(Stream inputStream, string fileName)
    {
        if (inputStream.CanSeek)
            //Reset the position of PDF document stream to be printed
            inputStream.Position = 0;
        //Create a new file in the Personal folder with the given name
        string createdFilePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName);
        //Save the stream to the created file
        using (var dest = System.IO.File.OpenWrite(createdFilePath))
            inputStream.CopyTo(dest);
        string filePath = createdFilePath;
        PrintManager printManager = (PrintManager)CrossCurrentActivity.Current.Activity.GetSystemService(Context.PrintService);
        PrintDocumentAdapter pda = new CustomPrintDocumentAdapter(filePath);
        //Print with null PrintAttributes

        printManager.Print(fileName, pda, null);
    }

添加您迄今为止尝试过的内容将有助于回答您的问题检查五月帮助中的答案。还有一个关于在Xamarin.Forms中打印PDF和图像的链接。