如何指示我必须使用JavaFX打印哪一页?

时间:2019-05-02 16:37:38

标签: java javafx

我想用下面的JavaFX代码打印一个FXML页面,但是我不知道如何指示我要打印的页面。

@FXML
private void btnimprimerAction(ActionEvent event) {

    final PrinterJob printerJob = PrinterJob.createPrinterJob();

    if (printerJob.showPrintDialog(btnimprimer.getScene().getWindow())) {

        final JobSettings settings = printerJob.getJobSettings();

        final PageLayout pageLayout = settings.getPageLayout();

        final double pageWidth = pageLayout.getPrintableWidth();

        final double pageHeight = pageLayout.getPrintableHeight();

        double pageLeftMargin = pageLayout.getLeftMargin();

        double pageRightMargin = pageLayout.getRightMargin();

        double pageTopMargin = pageLayout.getTopMargin();

        double pageBottomMargin = pageLayout.getBottomMargin();

        if (printerJob.printPage(btnimprimer)) {
            printerJob.endJob();
        }
    }
}

我该如何解决?

0 个答案:

没有答案