Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6730467

PrinterService for network printer via UNC name

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
      2d
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      A DESCRIPTION OF THE REQUEST :
      It should be possible to obtain a PrinterService for printing to a network printer via its UNC name, for example \\myserver\myprinter, without having to install the printer locally.

      JUSTIFICATION :
      We have a web server based application from which users can print to their local printers by specifying the unc name of the printer. It is not acceptable to have to install some hundreds of local printers on the server.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      PrintServiceLookup.lookupPrintServices() should search for a network printer when called with a PrinterName attribute that contains a network printer name.
      ACTUAL -
      PrintServiceLookup.lookupPrintServices() returns only printers that are installed locally

      ---------- BEGIN SOURCE ----------
      import javax.print.DocFlavor;
      import javax.print.PrintService;
      import javax.print.PrintServiceLookup;
      import javax.print.attribute.AttributeSet;
      import javax.print.attribute.HashPrintServiceAttributeSet;
      import javax.print.attribute.standard.PrinterName;

      public class Printer
      { /**
      * Call with network printer name like \\myserver\myprinter as first argument
      */
      public static void main( String args[] )
      {
      AttributeSet searchAttributes = new HashPrintServiceAttributeSet();
      searchAttributes.add( new PrinterName( args[0], null ));

      PrintService services[] =
      PrintServiceLookup.lookupPrintServices( DocFlavor.SERVICE_FORMATTED.PAGEABLE, searchAttributes );

      if(( services != null ) && ( services.length > 0 ))
      {
      System.out.println( "Found PrintService: " + services[0] );
      }
      }
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psadhukhan Prasanta Sadhukhan
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: