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

Printing LinearGradientPaint with transparency does not work on Mac

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8u221, openjfx13
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      ADDITIONAL SYSTEM INFORMATION :
      macOS High Sierra 10.13.6

      A DESCRIPTION OF THE PROBLEM :
      When filling shapes with gradients using transparent colors, printing on Mac will not work. Used JavaFX 13.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start test case.
      Press "Print" button.
      Print to PDF.
      Open PDF with any PDF viewer.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The printed shape has a gradient from the upper left corner to the center.
      ACTUAL -
      The printed shape is white in the upper left area.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.print.PrinterJob;
      import javafx.scene.Group;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ToolBar;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.StackPane;
      import javafx.scene.paint.Color;
      import javafx.scene.paint.CycleMethod;
      import javafx.scene.paint.LinearGradient;
      import javafx.scene.paint.Stop;
      import javafx.scene.shape.ClosePath;
      import javafx.scene.shape.LineTo;
      import javafx.scene.shape.MoveTo;
      import javafx.scene.shape.Path;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;

      public class PrintTest extends Application {
        @Override
        public void start(Stage stage) throws Exception {
          Node node = createNode();

          Button printButton = new Button("Print");
          printButton.setOnAction(event -> {
            PrinterJob job = PrinterJob.createPrinterJob();
            if (job != null && job.showPrintDialog(stage.getOwner()) && job.printPage(node)) {
              job.endJob();
            }
          });
          BorderPane root = new BorderPane(new StackPane(node));
          root.setTop(new ToolBar(printButton));
          Scene scene = new Scene(root, 300, 300);
          stage.setScene(scene);
          stage.setTitle("PrintTest");
          stage.show();

        }

        private Node createNode() {
          double x = 0;
          double y = 0;
          double w = 100;
          double h = 100;

          Rectangle rect = new Rectangle(x, y, w, h);
          rect.setFill(Color.ORANGE);

          Path path = new Path(
          new MoveTo(x, y),
          new LineTo(x + w, y),
          new LineTo(x, y + h),
          new ClosePath());

          Stop[] stops = {
              new Stop(0, Color.rgb(255, 255, 255, 200 / 255d)),
              new Stop(0.8, Color.rgb(255, 255, 255, 20 / 255d))
          };
          LinearGradient gradient = new LinearGradient(0, 0, 50, 50, false, CycleMethod.NO_CYCLE, stops);
          path.setFill(gradient);
          path.setStroke(null);

          return new Group(rect, path);
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: