0

I have project in asp.net which prints bill. I have made my own Printing class inherited form PrintDocument form System.Drawing.Printing and it works fine in the visual studio development server. However it doesn't work after deploying in IIS. After a quite bit of research I found that System.Drawing.Printing doesn't work with asp.net. Is there any way I could use the same class for printing with some tweaks.... or What might be the possible options (besides javascript)? The printing is to be done in the local computer which itself hosts the IIS server.

1 Answers1

1

I believe you can do that using System.Printing.PrintQueue.

System.Printing.PrintServer("PrintServerName").PrintQueueCollection will give you all available PrintQueues. Here's some sample code from MSDN:

// Create a PrintServer 
// "theServer" must be a print server to which the user has full print access.
PrintServer myPrintServer = new PrintServer(@"\\theServer");

// List the print server's queues
PrintQueueCollection myPrintQueues = myPrintServer.GetPrintQueues();
String printQueueNames = "My Print Queues:\n\n";
foreach (PrintQueue pq in myPrintQueues)
{
    printQueueNames += "\t" + pq.Name + "\n";
}
Console.WriteLine(printQueueNames);

Here's a good reference on the concepts behind PrintQueues

G. Stoynev
  • 7,389
  • 6
  • 38
  • 49
  • Could you please suggestion what needs to be added here https://stackoverflow.com/questions/52412890/not-able-to-use-printdocument-in-iis ..Thanks – Lara Sep 19 '18 at 19:50