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

RFE: convenience API to calculate PageFormat from PrintRequestAttributeSet

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 1.4.0, 1.4.2
    • client-libs
    • 2d
    • b43
    • x86
    • linux, windows_nt


      There is no way how to get PageFormat form page setup card on new cross-platform print dialog in jdk1.4. Since PrinterJob.pageDialog() returns new PageFormat, PrinterJob.printDilaog() returns boolean and new page format seting is hidden for user.

      -------------------------------------------------------------

      I reopened the bug because you misunderstood of the problem. I know about PrinterJob.pageDialog() method but the problem is in printerJob.printDialog().

      PrinterJob.printDialog() method displays a new cross-platform print dialog on jdk1.4. The dialog contains three tabs. The second tab "Page Setup" looks like page setup dialog displayed with PrinterJob.pageDialog(). But there is no way how to acces PageFormat seted up with this tab pane after the print dialog
      is closed.


      ###@###.### 2001-09-10



      Name: rmT116609 Date: 04/17/2003


      A DESCRIPTION OF THE REQUEST :
      Currently it is not possible to create or get a PageFormat instance using a PrintRequestAttributeSet, through the API, without user interaction.


      JUSTIFICATION :
      This problem results in "duplicate code" to setup a PageFormat instance, without user interaction, to match the attributes that have been setup in the PrintRequestAttributeSet.

      One could just drop the PrintRequestAttributeSet, but a side affect of this is that later on you loose the cross-platform dialogs if you should call:
      PrinterJob.pageDialog( PageFormat );
      PrinterJob.printDialog();
      Another problem with this is that the last changes made by a user in pageDialog( PageFormat ) are not reflected in the printDialog().
      This is not the case when using PrintRequestAttributeSet.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      An appropriate method to obtain a PageFormat instance using PrintRequestAttributeSet without user interaction eg:
      PrinterJob.defaultPage( PrintRequestAttributeSet )

      The only way of getting a PageFormat instance using a PrintRequestAttributeSet, through the API, is with: PrinterJob.pageDialog( PrintRequestAttributeSet ) which requires user interaction.

      CUSTOMER SUBMITTED WORKAROUND :
      PrintRequestAttributeSet prnSet;
      prnSet = new HashPrintRequestAttributeSet();
      prnSet.add( new JobName( title, java.util.Locale.ENGLISH ) );
      prnSet.add( MediaSizeName.ISO_A4 );
      prnSet.add( new MediaPrintableArea( 15, 10, 185, 267,
      MediaPrintableArea.MM ) );


      PageFormat pgFrm; // PageFormat Setup
      {
      // Can't get a PageFormat using prnSet without a dialog :-(
      // so PageFormat is setup here as a duplicate of prnSet !
      // this also is not as neat / graceful as the above.

      PrinterJob prnJob = PrinterJob.getPrinterJob();
      pgFrm = prnJob.defaultPage();

      Paper A4 = pgFrm.getPaper();
      final double lpi = 72/25.4; // 72 lpi / 25.4 mm per inch
      A4.setSize( 210 * lpi, 297 * lpi ); // to convert mm to 72 lpi
      A4.setImageableArea( 15 * lpi, 10 * lpi, 185 * lpi, 267 * lpi );
      pgFrm.setPaper( A4 );
      }
      (Review ID: 184284)
      ======================================================================

            prr Philip Race
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: