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

[macosx] Cross platform print dialog won't select printer

XMLWordPrintable

    • 7u4
    • os_x

      FULL PRODUCT VERSION :
      java version " 1.7.0_09 "
      Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin archer 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      requires 2 printers.

      A DESCRIPTION OF THE PROBLEM :
      printJob ignores the printer selected in cross platform print dialog

      my speculation is, all attributes passed to printJob.print are ignored, but that's just a guess.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the program, select the non-default printer.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      print to the selected printer
      ACTUAL -
      prints to the default printer

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Graphics;
      import java.awt.print.PageFormat;
      import java.awt.print.Printable;
      import java.awt.print.PrinterException;
      import java.awt.print.PrinterJob;

      import javax.print.attribute.HashPrintRequestAttributeSet;
      import javax.print.attribute.PrintRequestAttributeSet;

      public class OsxDefaultPrinterTest implements Printable
      {

          /**
           * @param args
           * @throws PrinterException
           */
          public static void main(String[] args) throws PrinterException
          {
              OsxDefaultPrinterTest test = new OsxDefaultPrinterTest();
              PrinterJob p = PrinterJob.getPrinterJob();
              p.setPrintable(test);
              
              PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
              // change the printer from the default using the dialog
              if(p.printDialog(set))
              {
                  p.print();
                  p.print(set);

              }
          }

          @Override
          public int print(Graphics graphics,
                           PageFormat pageFormat,
                           int pageIndex) throws PrinterException
          {
              if(pageIndex > 0)
                  return Printable.NO_SUCH_PAGE;
              graphics.drawString( " print test " , 50, 50);
                  
              return Printable.PAGE_EXISTS;
          }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      use the native dialog, not the cross platform dialog.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: