none
Not able to print from WCF Service RRS feed

  • Question

  • Hi All,

    My requirement is that my service method will have to print on a certain printer based on certain criteria.

    e.g., If Item category is X then print on printer X else print on printer Y.

    The problem I am facing is, I am not able to retrieve the printer.

    I am using LocalPrintServer.GetPrintQueue() method. 

    I tried giving full rights to the service but no help.

    Any help in this will be appreciated. Thanks in advance.

    Regards,

    Javed

    Tuesday, October 1, 2013 8:19 AM

Answers

  • Hi Javed,

    As I said above, PrinterSettings.InstalledPrinters returns all printers installed on the local computer, instead try return both local and network printers with PrintServer.GetPrintQueues. So I mean if you want to use the printers installed from the user's perspective(on the local computer), using PrinterSettings.InstalledPrinters; if you want to use network printers, you can use the solution provide in this thread to return all printers.

    Thanks.

    Best Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 3, 2013 12:13 PM
    Moderator

All replies

  • Hi Javed,

    >>The problem I am facing is, I am not able to retrieve the printer.I am using LocalPrintServer.GetPrintQueue() method. 

    Is there any error message? Or do you check if the printer works when print from the service client(or from a simple console app)?

    And there are some notes, GetPrintQueues doesn't return all printers installed from the user's perspective, just those owned by the local server, you can use System.Drawing.Printing.PrinterSettings.InstalledPrinters which is a string[] you'll get a list of all printers installed from the user's perspective; or get the network printers by passing an array of EnumeratedPrintQueueTypes to GetPrintQueues(), details you can see at 

    http://stackoverflow.com/questions/5645892/how-do-i-use-localprintserver-to-target-a-specific-printer

    Best Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, October 2, 2013 12:44 AM
    Moderator
  • Hi Haixia,

    I tried System.Drawing.Printing.PrinterSettings.InstalledPrinters but it still returns only XPS and Fax. It doesn't return me the network printers.
    Thursday, October 3, 2013 7:27 AM
  • Hi Javed,

    As I said above, PrinterSettings.InstalledPrinters returns all printers installed on the local computer, instead try return both local and network printers with PrintServer.GetPrintQueues. So I mean if you want to use the printers installed from the user's perspective(on the local computer), using PrinterSettings.InstalledPrinters; if you want to use network printers, you can use the solution provide in this thread to return all printers.

    Thanks.

    Best Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 3, 2013 12:13 PM
    Moderator