Search code examples
printingjavafxscene

Printing in JavaFX using lookup


I try to print a treetableview, and i am now landed by using lookup like bellow. The problem is although the lookup id refers to the hole of treetableview, but it prints just part of it. How can I split my treetableview in more nodes and print them over multiple pages? I have tried

printerJob.getJobSettings().setPageRanges(new PageRange(1,5)); 

but i did not work. In swing it happened automatically if treetable was bigger to fit on a page. I do not want to make cells smaller.

@FXML
private void doPrint(){
 PrinterJob job = PrinterJob.createPrinterJob();
   PrinterJob printerJob = PrinterJob.createPrinterJob();
   if(printerJob.showPrintDialog(main.getPrimaryStage().getOwner()) && printerJob.printPage(main.getPrimaryStage().getScene().lookup("#treeTable")))
       printerJob.endJob();

}

Solution

  • You currently cannot do it.

    There is a feature request for this. Feel free to Vote for it.

    Though, if you do not want the TreeTableView node, you can segregate the data and print it using some other node.