Class DocumentRenderer

java.lang.Object
com.iamsoft.util.ui.swing.DocumentRenderer
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.
  • Constructor Details

    • DocumentRenderer

      public DocumentRenderer()
  • Method Details

    • getDocument

      public Document getDocument()
    • getScaleWidthToFit

      public boolean getScaleWidthToFit()
    • pageDialog

      public void pageDialog()
    • print

      public int print(Graphics pGraphics, PageFormat pPageFormat, int pPageIndex)
      Specified by:
      print in interface Printable
    • print

      public void print(HTMLDocument pHtmlDocument)
    • print

      public void print(JEditorPane pJedPane)
    • print

      public void print(PlainDocument pPlainDocument)
    • printDialog

      protected void printDialog()
    • printView

      protected boolean printView(Graphics2D pGraphics2D, Shape pAllocation, View pView)
    • setContentType

      protected void setContentType(String pType)
    • setDocument

      public void setDocument(HTMLDocument pHtmlDocument)
    • setDocument

      public void setDocument(JEditorPane pJedPane)
    • setDocument

      public void setDocument(PlainDocument pPlainDocument)
    • setDocument

      protected void setDocument(String pType, Document pDocument)
    • setScaleWidthToFit

      public void setScaleWidthToFit(boolean pScaleWidth)