JDK-8101135 : Webview and HTMLEditor should support printing their content
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2011-10-27
  • Updated: 2015-06-16
  • Resolved: 2013-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Description
Webview and HtmlEditor are good candidates to directly support a print() method which
will create, or partake in, a print job and send their output to the printer.

This would make it easier for apps which just want to print a web page from their FX app
to do so without writing complex code or buying a separate package.

The same is requested of several UI controls in http://javafx-jira.kenai.com/browse/RT-17665

Comments
Fixed in changeset http://jfxsrc.us.oracle.com/javafx/8.0/scrum/graphics/rt/rev/17fa39d79a6f
11-06-2013

Below is a modification of patch by Andrew Brygin. WebEngine.print() works by creating a special Node and submitting it to PrinterJob.printPage(). From its renderContent() method, the Node creates a rendering queue and passes it to Webkit to fill, then flushes it onto the printer graphics context. On the native side, I'm adding WebPage::m_printContext field. Its value persists between calls to beginPrinting() and endPrinting(), and is used for layout and actual printing of the page. http://javaweb.us.oracle.com/jcg/fx-webrevs/RT-17666/1
07-06-2013

Please be sure to add the @since JavaFX 8.0 tag
06-06-2013

and print preview?
01-06-2013

I propose adding two new printing methods to WebEngine and HTMLEditor. The new methods print components' content as a document. For WebEngine, the new methods is: /** * Prints the current Web page using the given printer job. * <p>This method does not modify the state of the job, nor does it call * {@link PrinterJob#endJob}, so the job may be safely reused afterwards. * * @param job printer job used for printing */ public void print(PrinterJob job); and a similar one for HTMLEditor: /** * Prints the content of the editor using the given printer job. * <p>This method does not modify the state of the job, nor does it call * {@link PrinterJob#endJob}, so the job may be safely reused afterwards. * * @param job printer job used for printing */ public void print(PrinterJob job);
29-05-2013

I forgot to mention that I intend to use this for printing a receipt, and wouldn't necessarily want to display the same thing to the user on screen. I might just tell the user that the receipt is being printed and display a video of the paper coming out of a slot. I figured I'd have a WebView that is not visible, but I could tell it to print.
19-02-2013

To print WebView as a Node we would need to: - Introduce a new method in WebPage that will send a repaint request to Webkit (on event thread) and decode the resulting rendering queue, bypassing back buffer completely. This method will then need to schedule a complete repaint of the visible area to make sure any dirty regions cleared by printing will be repainted on screen. - Make images and canvases J2D-aware. Currently those are using accelerated textures that don't fit J2D. When printing we need to copy those textures into J2DTextures suitable for printing. - Be able to distinguish between Render and Printer threads. In particular runOnRenderThread() will need to know whether to block the calling thread. I've filed RT-28481.
19-02-2013

+1, this is a very important feature (including CSS @page rules and page breaks.) Please include this in the roadmap ASAP
18-02-2013

Webview should support CSS @page rules, and page-break properties for proper printing results
08-10-2012