I try to print the content of a WebView with the following code:
private void handlePrintButtonAction(ActionEvent event) {
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null) {
Window window = webView.getScene() != null ? webView.getScene().getWindow() : null;
if (job.showPageSetupDialog(window)) {
if (job.showPrintDialog(window)) {
webView.getEngine().print(job);
job.endJob();
}
}
}
}
The page-setup dialog offers the option to define a scale factor at which the page should be printed. This setting is consistently ignored by the JavaFX WebView. When I print the same page via Firefox, which provides exactly the same dialog for setting the scale factor, it works as expected and a scaled version of the page content is printed. I expect JavaFX to do the same.
private void handlePrintButtonAction(ActionEvent event) {
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null) {
Window window = webView.getScene() != null ? webView.getScene().getWindow() : null;
if (job.showPageSetupDialog(window)) {
if (job.showPrintDialog(window)) {
webView.getEngine().print(job);
job.endJob();
}
}
}
}
The page-setup dialog offers the option to define a scale factor at which the page should be printed. This setting is consistently ignored by the JavaFX WebView. When I print the same page via Firefox, which provides exactly the same dialog for setting the scale factor, it works as expected and a scaled version of the page content is printed. I expect JavaFX to do the same.