public class XHTMLPrintable
extends java.lang.Object
implements java.awt.print.Printable
XHTMLPrintable allows you to print XHTML content to a printer instead of rendering it to screen. It is an implementation of @see java.awt.print.Printable so you can use it any where you would use any other Printable object. The constructor requires an XHTMLPanel, so it's easiest to prepare an XHTMLPanel as normal, and then wrap a printable around it.ex:
import org.xhtmlrenderer.simple.*; import java.awt.print.*; // . . . . // xhtml_panel created earlier PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintable(new XHTMLPrintable(xhtml_panel)); if(printJob.printDialog()) { printJob.print(); }
Constructor and Description |
---|
XHTMLPrintable(XHTMLPanel panel)
Creates a new XHTMLPrintable that will print
the current contents of the passed in XHTMLPanel.
|
Modifier and Type | Method and Description |
---|---|
int |
print(java.awt.Graphics g,
java.awt.print.PageFormat pf,
int page)
The implementation of the print method
from the @see java.awt.print.Printable interface.
|
public XHTMLPrintable(XHTMLPanel panel)
panel
- the XHTMLPanel to print