The code below does not print the Label after the WebView. Usually (not always) when a WebView is rendered any further rendering to the printer ends up empty.
If you comment out the WebView line and uncomment the first Label row then both labels will be printed.
VBox box = new VBox();
box.getChildren().add(new WebView());
// box.getChildren().add(new Label("Uncomment this and comment WebView to make it work"));
box.getChildren().add(new Label("Hello"));
Printer pr = Printer.getDefaultPrinter();
PrinterJob pj = PrinterJob.createPrinterJob(pr);
pj.getJobSettings().setPageRanges(new PageRange(1, 1));
pj.printPage(box);
pj.endJob();
The WebView is empty in the example but it's the same no matter what the content in it is.
If you comment out the WebView line and uncomment the first Label row then both labels will be printed.
VBox box = new VBox();
box.getChildren().add(new WebView());
// box.getChildren().add(new Label("Uncomment this and comment WebView to make it work"));
box.getChildren().add(new Label("Hello"));
Printer pr = Printer.getDefaultPrinter();
PrinterJob pj = PrinterJob.createPrinterJob(pr);
pj.getJobSettings().setPageRanges(new PageRange(1, 1));
pj.printPage(box);
pj.endJob();
The WebView is empty in the example but it's the same no matter what the content in it is.
- duplicates
-
JDK-8091167 Automatic preferred sizing of WebView
- Open