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

JavaFX: poor printing quality for Region nodes

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_101"
      Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Using the Adobe pdf printer different printers.

      A DESCRIPTION OF THE PROBLEM :
      Trying to print a javafx node with a specified quality, does not react as expected. It scales the image.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In case of printing without dialog and trying to use one of the supported resolutions there is no chance to improve the default low quality.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An image with the same size as would have in the default resolution but with higher quality.
      ACTUAL -
      The image is scaled depending on the resolution. The higher resolution, the bigger image.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class PrintTest extends Application {

          public static void print(final Node node) {
              PrinterJob job = PrinterJob.createPrinterJob();
              if (job != null) {
                  final Set<PrintResolution> supportedPrintResolutions = job.getPrinter().getPrinterAttributes().getSupportedPrintResolutions();
                  for (PrintResolution supportedPrintResolution : supportedPrintResolutions) {
                      job.getJobSettings().setPrintResolution(supportedPrintResolution);
                  }
                      boolean success = job.printPage(node);
                      if (success) {
                          job.endJob();
                      }
              }
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              Button print = new Button("Print");
              HBox hBox = new HBox(print);
              print.setOnAction(event -> PrintTest.print(hBox));
              primaryStage.setScene(new Scene(hBox));
              primaryStage.show();
          }

      }
      ---------- END SOURCE ----------

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: