org.xhtmlrenderer.simple
Class XHTMLPrintable

java.lang.Object
  extended by org.xhtmlrenderer.simple.XHTMLPrintable
All Implemented Interfaces:
Printable

public class XHTMLPrintable
extends Object
implements 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(); }


Field Summary
protected  Graphics2DRenderer g2r
           
protected  XHTMLPanel panel
           
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
XHTMLPrintable(XHTMLPanel panel)
          Creates a new XHTMLPrintable that will print the current contents of the passed in XHTMLPanel.
 
Method Summary
 int print(Graphics g, PageFormat pf, int page)
          The implementation of the print method from the @see java.awt.print.Printable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panel

protected XHTMLPanel panel

g2r

protected Graphics2DRenderer g2r
Constructor Detail

XHTMLPrintable

public XHTMLPrintable(XHTMLPanel panel)
Creates a new XHTMLPrintable that will print the current contents of the passed in XHTMLPanel.

Parameters:
panel - the XHTMLPanel to print
Method Detail

print

public int print(Graphics g,
                 PageFormat pf,
                 int page)

The implementation of the print method from the @see java.awt.print.Printable interface.

Specified by:
print in interface Printable


Copyright © 2013. All Rights Reserved.