Печать PDF-файла без предварительного просмотра - PullRequest
0 голосов
/ 03 марта 2020

У меня возникли проблемы с поиском приложения 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);
    }
...