I'm trying to print my webEngine with print method, and an issue I have is an extra empty page after all the content is printed. I wonder what it could be or how to troubleshoot that issue?
public class JSPrintHook {
public void print() {
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null && job.showPrintDialog(webView.getScene().getWindow())) {
webView.getEngine().print(job);
job.endJob();
}
}
}
It can be a thread handling problem, if you use WebEngine without javafx.application.Application (eg. integrate JavaFX to Swing UI). In this case you should use Platform.runLater(). For example: