打印JavaFx TableView的内容 [英] Print contents of JavaFx TableView

查看:207
本文介绍了打印JavaFx TableView的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种打印JavaFX TableView内容的方法。据我所知,JavaFX还没有打印功能(多么令人失望)。我找到了一些关于获取WebView屏幕截图的信息,并将其打印为图像。

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.

是否可以使用Table视图执行类似的操作。如何在包含大量数据的表格上处理多个页面。

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.

感谢您的帮助

推荐答案

打印API出现在fx8.0中。它可以打印节点。您可以使用javafx.print.PrinterJob类创建打印机作业。但它只打印适合打印页面的区域,而不是打印在屏幕上的区域。因此,您需要手动使节点适合页面(缩放,翻译等)。这是一个简单的打印示例:

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

这篇关于打印JavaFx TableView的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆