Print contents of JavaFx TableView

前端 未结 4 1411
野性不改
野性不改 2020-12-09 06:55

I am looking for a way to print the contents of a JavaFX TableView. I understand that JavaFX doesn\'t have Printing capabillities just yet (what a disapointment). I have fou

4条回答
  •  臣服心动
    2020-12-09 07:25

    Printing API appeared in fx8.0. And it can print nodes. You can create printer job with javafx.print.PrinterJob class. But it prints only region that fits to a printed page, and not the one that you on a screen. So you need to make your node fit page(scale, translate, etc) by hands. Here is simple printing example:

       PrinterJob printerJob = PrinterJob.createPrinterJob();
       if(printerJob.showPrintDialog(primaryStage.getOwner()) && printerJob.printPage(yourNode))
           printerJob.endJob();
    

提交回复
热议问题