2

I have a web application hosted on server 'A' (SA) and a web service for printing hosted on server 'B' (SB). SA creates and image that needs printing and sends it to SB. When doing this, printing is fairly slow, around fifteen seconds. However, if I log into SB using remote desktop as the user from the webconfig of the app hosted on SA, then it will print in less than two seconds. It seems as if SB is starting something up when I log into it that is making it print faster. Any idea what this could be and if there's a way that I could keep this printing fast even if I'm not logged in?

Edit: Size of the image being printed is about 20 KB.

Here's the code from of the service that is hosted on 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();
    }

Thanks for taking time to read through this :)

JSprang
  • 12,481
  • 7
  • 30
  • 32
  • 1
    Is there any authentication occurring being it not localhost accessing the web service? – CR41G14 Jan 08 '13 at 17:14
  • No, the image makes it to SB from SA extremely fast. It's sitting on the Print() method. – JSprang Jan 08 '13 at 17:15
  • When you are on SB do you print using the stream or from file? – CR41G14 Jan 08 '13 at 17:18
  • Not sure if I understand exactly what you're asking @CR41G14, but the code that is shown is on SB. Image comes in as a Stream, creates an image, then draws it to the printer. – JSprang Jan 08 '13 at 17:24

2 Answers2

1

We found that if we created a printer mapping on SB, it would execute just as fast without a remote desktop connection.

JSprang
  • 12,481
  • 7
  • 30
  • 32
0

Note that printing from a web app (or a service) is generally unsupported. see msdn and this SO post.

Community
  • 1
  • 1
Elroy Flynn
  • 3,032
  • 1
  • 24
  • 33