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

[macosx] PrinterJob's native Print Dialog does not reflect specified Copies or Page Ranges

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b116

      Backports

        Description

        JDK 7u11 and JDK 9 b34 both have the same issue that attempts to pre-populate the native
        dialog with copies and page ranges fail.
        Test below :-
        import javax.print.*;
        import javax.print.attribute.*;
        import javax.print.attribute.standard.*;
        import java.awt.*;
        import java.awt.print.*;

        public class DlgAttrsBug implements Printable {

            public static void main(String args[]) throws Exception {
                PrinterJob job = PrinterJob.getPrinterJob();
                if (job.getPrintService() == null) {
                   System.out.println("No printers. Test cannot continue.");
                   return;
                }
                job.setPrintable(new DlgAttrsBug());
                job.setCopies(2);
                PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                aset.add(new Copies(2));
                aset.add(new PageRanges(3,4));
                aset.add(DialogTypeSelection.NATIVE);
                if (job.printDialog(aset)) {
                   job.print(aset);
                }
            }

            public int print(Graphics g, PageFormat pf, int pi)
                             throws PrinterException {

                System.out.println("pi="+pi);
                if (pi >= 5) {
                    return NO_SUCH_PAGE;
                }

                g.drawString("Page : " + (pi+1), 200, 200);

                return PAGE_EXISTS;
            }
        }

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  psadhukhan Prasanta Sadhukhan
                  Reporter:
                  prr Philip Race
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: