JDK-8231512 : Printing LinearGradientPaint with transparency does not work on Mac
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u221,openjfx13
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2019-09-25
  • Updated: 2019-10-04
  • Resolved: 2019-10-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
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



Comments
I am sure it is the same issue.
04-10-2019

May be related to (or caused by) JDK-8212643.
04-10-2019

I can reproduce this on 8u221 and on the latest openjfx14 build.
04-10-2019