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

[macosx] Print dialog does not update attribute set with page range

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • client-libs
    • 2d
    • b116

    Backports

      Description

        The OS X platform print dialog has an option to set the page ranges.
        If this is done it ought to be reported back in the AttributeSet.
        The following program can be used to illustrate this does not happen

        import java.awt.*;
        import java.awt.event.*;
        import java.awt.font.*;
        import java.awt.geom.*;
        import java.awt.print.*;
        import javax.print.*;
        import javax.print.attribute.*;
        import javax.print.attribute.standard.*;

        public class PP implements Pageable, Printable {

         public static void main(String args[]) throws Exception {

            HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
            PrinterJob j = PrinterJob.getPrinterJob();
            j.setPageable(new PP());
            as.add(DialogTypeSelection.NATIVE);
            j.printDialog(as);
            Attribute attrs[] = as.toArray();
            for (int i=0; i<attrs.length; i++) System.out.println(attrs[i]);
            j.print(as);
            //Thread.sleep(10000);

        }
            public int getNumberOfPages() {
                return UNKNOWN_NUMBER_OF_PAGES;
            }

            public PageFormat getPageFormat(int pageIndex) {
        Thread.dumpStack();
               //if (pageIndex > 2) throw new IndexOutOfBoundsException();
               PageFormat pf = new PageFormat();
               Paper p = pf.getPaper();
               p.setImageableArea(36, 36, p.getWidth()-72, p.getHeight()-72);
               pf.setPaper(p);
               return pf;
            }

            public Printable getPrintable(int pageIndex) {
               //if (pageIndex > 2) throw new IndexOutOfBoundsException();
               return this;
            }

            public int print(Graphics g, PageFormat pgFmt, int pgIndex) {
        System.out.println("****"+pgIndex);
               if (pgIndex > 2) return Printable.NO_SUCH_PAGE;
                double iw = pgFmt.getImageableWidth();
                double ih = pgFmt.getImageableHeight();
                Graphics2D g2d = (Graphics2D)g;
                g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY());
                g2d.drawString("top left of page format",20,20 );
                return Printable.PAGE_EXISTS;
            }

        }

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: