Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
841 views
in Technique[技术] by (71.8m points)

printing - Print contents of JavaFx TableView

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 found some information about taking a screenshot of a WebView for example and print it as an image.

Is it possible to do something like that with a Table view. How to go about to handle multiple pages on tables with many data.

Thanks for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...