[UWP]如何在UWP应用程序中执行静默打印? [英] [UWP]How to perform silent printing in UWP application?

查看:78
本文介绍了[UWP]如何在UWP应用程序中执行静默打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我们的要求是执行静默打印(当给出打印请求时,不应该弹出打印对话框等任何用户交互)。我们尝试使用PrintManager进行打印。工作流程如下,

Our requirement is to perform silent printing (When print request given there should not be any user interaction like print dialog pop up). We tried to print using PrintManager. Work flow is as follows,

- 使用PrintManager

- use PrintManager

- 访问默认打印机

- to access the default printer

- 用户交互,需要在UWP应用程序中打印给定的打印请求。

- without user interactions, need to print the given print request in UWP application.

async 私有 void printButton_Click 对象 发件人,
RoutedEventArgs e

asyncprivatevoidprintButton_Click(objectsender, RoutedEventArgs e)

{

    尝试

    try

    {

        //
显示打印UI

        // Show print UI

        等待
Windows.Graphics.Printing.PrintManager.ShowPrintUIAsync();

   }

    捕获

    catch

    {

        //
此时无法进行打印

        // Printing cannot proceed at this time

        ContentDialog noPrintingDialog =
ContentDialog()

        {

            Title =
"打印错误"

            Content =
" \ n对不起,此时打印无法继续。" ,PrimaryButtonText
=
" OK"

            Content = "\nSorry, printing can't proceed at this time.", PrimaryButtonText = "OK"

       };

        等待
noPrintingDialog.ShowAsync();

   }

}

我们引用了各种参考来实现我们的要求。

We referred various references to achieve our requirement.

https://docs.microsoft.com/en -us / uwp / api / windows.graphics.printing.printmanager

通过上述链接的引用,我们试图在没有UI中断的情况下静默打印。但我们不能在UWP应用程序中实现静默打印。

With the reference of the above link, we tried to print silently without UI interruptions. But we could not achieve silent printing in UWP application.

请提供建议继续我们的要求吗?

Kindly provide us suggestion to proceed our requirement?

问候,

Ayswarya Kumar

Ayswarya Kumar

推荐答案

嗨Meenamayi,

Hi Meenamayi,

如果使用PrintManager API进行打印,则打印对话框必须为s用于指导用户完成打印操作。

If you used the PrintManager APIs to print, the print dialog would must be shown to guide user complete the printing operation.

您可以在
上提交"功能请求" WP Uservoice

此外,还有一个特定的场景: 
POS打印机
API。您可以在没有打印对话框的情况下打印。此POS打印机API可用于支持
的所有打印机
ESC / POS
。你可以打电话给
PrintLine(string)
方法及其内容并使用
ExecuteAsync
方法。

Besides, there's a specific scenario: The POS printer API. You could print without a Print Dialog. This POS printer API can be used for all the printers which support ESC/POS. You could call the PrintLine(string) method with the content and execute it with ExecuteAsync method.

  POS打印机样本 供您参考。我刚才提到这个API适用于特定情况。

The POS Printer sample is for your reference. I just mentioned this API is for the specific scenario.

最好的问候,

Xavier Eoro

Xavier Eoro


这篇关于[UWP]如何在UWP应用程序中执行静默打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆