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

Printer.createPageLayout() returns 0.75" margins instead of hardware margins

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      NetBeans 8.0.2 / JDK 1.08 / JFX 8.03. I made test projects with JFX13, 12, and 11 linked and they all have the problem. Cannot print forms with 3/4 inch margins! I am running Apache 12.0 building "Simple JFX Maven" projects. Im running on MacOS 10 but your dropdown only shows Windows??!!!??

      A DESCRIPTION OF THE PROBLEM :
      I have a program that prints forms and works correctly on NetBeans 8.0.2 / JDK 1.08 / JFX 8.03. It reports a page size of 8.33" x 10.83", Lmargin=0.16,Rmargin=0, Tmargin=0.16,Bmargin=0. It prints Avery label forms correctly. I installed ApacheNetbeans (whew!!) and ported (copied) the files to a new JFX project and it runs great but printing is off. Investigation shows I cannot set margins smaller than 0.75" and this is a bug on this printer. The App sets margins to .5" all around and this JFX cannot do it.



      REGRESSION : Last worked in version 8u251

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Make a simple app that makes a pagelayout layout with margins < .75" and print that layout parameters to see the discrepancy. You can set margins > 1" but that's not enough??
      I checked the bugdatabase and apparently JFX 8 had a similar problem with this method (JDK-809580 and others)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Whatever margin you set that's legal, meaning it is GREATER than the HARDWARE_MAXIMUM limits given by the printer.
      ACTUAL -
      Cannot set margins < .75". My printer almost prints to the paper's edge so this is wrong. Besides , it works with the old JFX 8!!

      ---------- BEGIN SOURCE ----------
      package main.mavenproject2;

      import javafx.application.Application;
      import javafx.print.PageLayout;
      import javafx.print.PageOrientation;
      import javafx.print.Paper;
      import javafx.print.Printer;
      import static javafx.print.Printer.MarginType.HARDWARE_MINIMUM;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.StackPane;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      /**
       * JavaFX App
       */
      public class App extends Application {

          @Override
          public void start(Stage stage) {
              var javaVersion = SystemInfo.javaVersion();
              var javafxVersion = SystemInfo.javafxVersion();

              var stack = new StackPane();
              var scene = new Scene(stack, 640, 480);
              stage.setScene(scene);
              stage.show();

              System.out.println("Hello World!");

              Printer p = Printer.getDefaultPrinter();
              PageLayout pj = p.createPageLayout(Paper.NA_LETTER, PageOrientation.PORTRAIT, HARDWARE_MINIMUM);
              String st = ("Page Width=" + pj.getPrintableWidth() / 72
                      + " Page Height=" + pj.getPrintableHeight() / 72
                      + "\nLmargin=" + pj.getLeftMargin() / 72
                      + " Rmargin=" + pj.getRightMargin() / 72
                      + " Tmargin=" + pj.getTopMargin() / 72
                      + " Bmargin=" + pj.getBottomMargin() / 72);
              Text tx = new Text(st);
              tx.setStyle("-fx-font: 14pt Arial;");
              stack.getChildren().add(tx);
              System.out.println(st);

          }

          public static void main(String[] args) {
              launch();
          }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Unfortunately NONE. For now, use old development tools that work correctly.

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                prr Philip Race
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: