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

Page size and resolution not compatible on Windows NT Printing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.5
    • client-libs
    • x86
    • windows_nt



      Name: ccC48265 Date: 01/07/98

      Oracle Bug #603536 :

      1. The page size and page resolution provided by the PrintJob object do not
      correspond with each other, making it impossible to do page layout.
      Under Oracle Help for Java, the page size returned is 792x612; the resolution
      given is 400 pixels per inch, giving a logical paper size of 2 inches by
      1.5 inches.
                                                                     
      2. This test class prints the size and resolution of the page to stdout,
      then draws a rectangle that should be indented 1/2" on the paper.
      Results:
      Solaris:
      Page width is 612 pixels.
      Page height is 792 pixels.
      Page resolution is 72 pixels per inch.
      MSW:
      Page width is 612 pixels.
      Page height is 792 pixels.
      Page resolution is 400 pixels per inch.

      Her is the Java source code:
      //
      // PrintTest.java
      //
      import java.awt.Button;
      import java.awt.Dimension;
      import java.awt.Frame;
      import java.awt.Graphics;
      import java.awt.PrintJob;
      import java.awt.Toolkit;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      /**
       * This class tests the printer's page size and resolution.
       * It prints the size and resolution to standard output, then prints a
       * rectangle to the printer that should be indented 1/2" from the edge of the
       * paper on all sides.
       */
      public class PrintTest extends Frame
        implements ActionListener
      {
        public PrintTest()
        {
          super("Printing Test Window");
          Button button = new Button("Print");
          add(button);
          button.addActionListener(this);
          pack();
          show();
        }
        public void actionPerformed(ActionEvent e)
        {
          PrintJob job = getToolkit().getPrintJob(this, "Printing Test", null);
          int resolution = job.getPageResolution();
          Dimension pageSize = job.getPageDimension();
          System.out.println("Page width is " + pageSize.width + " pixels.");
          System.out.println("Page height is " + pageSize.height + " pixels.");
          System.out.println("Page resolution is " + resolution +
             " pixels per inch.");
          Graphics page = job.getGraphics();
          int offset = resolution / 2;
          page.drawRect(offset, offset, pageSize.width - resolution,
        pageSize.height - resolution);
          page.dispose();
          job.end();
          System.exit(0);
        }
        public static void main(String[] args)
        {
          _sTest = new PrintTest();
        }
        private static PrintTest _sTest;
      }

      3. None.
      4. N/A
      5. Platform: Windows NT
         JDK1.1.5K
      ===================================================================
      ###@###.### (Jan 7, 1998):
      I was able to exactly reproduce this bug as described.
      (Review ID: 22468)
      ======================================================================

            dmendenhsunw David Mendenhall (Inactive)
            ccresswesunw Claudette Cresswell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: