custom controls: printing

Phil Race philip.race at oracle.com
Wed Jan 28 01:43:41 UTC 2015


On 1/27/15 4:08 PM, Tom Eugelink wrote:
> Do I need to do something special to support printing of custom 
> controls? The use case is that on screen a spreadsheet can be shown in 
> a scrollpane, but when printing the whole spreadsheet should be printed. 
Being a 'custom' control doesn't really make a difference here.
The same would apply if you wanted to print one of the built-in controls
that is in a scroll pane or otherwise not likely to fit on a page.
Spreadsheets, like TableView, TextArea and the like will need
to have their data laid out for the printer by the application.
In practice this means starting with the data contained in
the spreadsheet and iterating over it printing as much as fits
on each page in what ever way you want.
I am sure that something that can handle this this would
make a nice add-on to to the core API but it was not something
that was considered appropriate to be part of FX core.
We expected reporting packages to pop up from 3rd parties
The exception to this is HtmlEditor / WebEngine where you
cannot reasonably expect the application or such a package
to know how to properly print the data (HTML and other web content)
Hence that has a method to print its content to a PrinterJob
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebEngine.html#print-javafx.print.PrinterJob-
So one possibility for you is to throw your data into HTML table syntax, 
load
it into a web node and print that.

-phil.


More information about the openjfx-dev mailing list