PrintDocument.打印很慢,除非用户登录到打印计算机

本文关键字:打印 用户 登录 计算机 PrintDocument | 更新日期: 2023-09-27 17:51:04

我有一个托管在服务器' a ' (SA)上的web应用程序和托管在服务器'B' (SB)上的打印web服务。SA创建一个需要打印的图像并将其发送给SB。在此过程中,打印相当慢,大约需要15秒。但是,如果我从SA上托管的应用程序的webconfig用户使用远程桌面登录到SB,那么它将在不到两秒钟的时间内打印。当我登录它时,似乎SB正在启动一些东西,这使它打印得更快。你知道这是什么吗,有没有办法让我在没有登录的情况下也能保持打印速度?

编辑:正在打印的图像大小约为20kb。

下面是托管在SB上的服务的代码:

public void PrintImage(Stream printImage, string printServer, string printer)
    {
        string printerName = String.Format(@"''{0}'{1}", printServer, printer);
        Image image = Image.FromStream(printImage);
        PrintDocument printDocument = new PrintDocument();
        PrinterSettings settings = new PrinterSettings();
        settings.PrinterName = printerName;
        printDocument.PrinterSettings = settings;
        printDocument.PrintPage += (s, e) =>
        {
            e.Graphics.DrawImage(image, 0, 0);
        };
        printDocument.Print();
    }

感谢您花时间看完这篇文章:)

PrintDocument.打印很慢,除非用户登录到打印计算机

我们发现,如果我们在SB上创建一个打印机映射,它将在没有远程桌面连接的情况下执行得一样快。

请注意,通常不支持从web应用程序(或服务)打印。请参阅msdn和这篇文章。