2
votes

I am working on an ASP.NET application and need to send documents to a network printer. I have utilized the PrintServer and PrintQueue to achieve the purpose as follows:

using System.Printing;

private void PrintTicket
{
  var server = "Network Server Name";
  var filePath = "File to Print";
  var printer = "Network Printer Name";

  var printerServer = new PrintServer(String.Format(@"\\{0}", server));
  var printQueue = printerServer.GetPrintQueue(printer);

  printQueue.AddJob("New Printing Job", filePath, false);
}

The network printer can be found and the print job is executed.

However, the performance is very slow. It took 5-10 seconds to start printing when method printQueue.AddJob() is executed.If the printer is connected to my local machine, there is no performance issue at all.

Any suggestions? Thanks in advance.

1

1 Answers

0
votes

Instead of using PrintQueue class you can simply use File.Copy(filePath, printerDestination, true); I have tried both the options i.e. using printqueue as well as file copy and file copy is much faster compare to using printqueue class.

Thanks, Arnab