- All Implemented Interfaces:
- Printable
public class DocumentRenderer
extends Object
implements Printable
DocumentRenderer prints objects of type Document. Text attributes, including
fonts, color, and small icons, will be rendered to a printed page.
DocumentRenderer computes line breaks, paginates, and performs other
formatting.
An HTMLDocument is printed by sending it as an argument to the
print(HTMLDocument) method. A PlainDocument is printed the same way. Other
types of documents must be sent in a JEditorPane as an argument to the
print(JEditorPane) method. Printing Documents in this way will automatically
display a print dialog.
As objects which implement the Printable Interface, instances of the
DocumentRenderer class can also be used as the argument in the setPrintable
method of the PrinterJob class. Instead of using the print() methods
detailed above, a programmer may gain access to the formatting capabilities
of this class without using its print dialog by creating an instance of
DocumentRenderer and setting the document to be printed with the
setDocument() or setJEditorPane(). The Document may then be printed by
setting the instance of DocumentRenderer in any PrinterJob.