org.gerhardb.lib.print
Class PrintJobUtils

java.lang.Object
  extended by org.gerhardb.lib.print.PrintJobUtils

public class PrintJobUtils
extends java.lang.Object

Isolates the dreaded PrinterJob which only knows how to print at 72dpi. Note that Java uses 72dpi for screen and printer resolution as does the Mac. Windows and Linux use 96dpi. So fonts can seem small on Windws (72/96 to be exact). Most printers go to at least 300dpi. But, I can't find any way to tell java to print at 300dpi.


Constructor Summary
PrintJobUtils()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static java.awt.print.PageFormat maxMargins()
           
static java.awt.print.PageFormat maxMargins(java.awt.print.PrinterJob printJob, int orientation)
          Create a PageFormat with a Paper that has the margin set to zero.
static java.awt.print.PageFormat orientPageToImage(java.awt.image.BufferedImage image)
           
static java.awt.print.PageFormat pageFormatDialog(java.awt.print.PageFormat pf)
           
static java.lang.String showPageFormat(java.awt.print.PageFormat pf)
           
static void threadedDefaultPrint(java.awt.print.Pageable pageable, java.awt.Component comp)
           
static void unthreadedPrint(java.awt.print.PrinterJob printJob, java.awt.Component comp)
          Prints a printable with an hour glass, validating the margins and brining up the printer dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintJobUtils

public PrintJobUtils()
Method Detail

showPageFormat

public static java.lang.String showPageFormat(java.awt.print.PageFormat pf)

pageFormatDialog

public static java.awt.print.PageFormat pageFormatDialog(java.awt.print.PageFormat pf)

orientPageToImage

public static java.awt.print.PageFormat orientPageToImage(java.awt.image.BufferedImage image)

maxMargins

public static java.awt.print.PageFormat maxMargins()

maxMargins

public static java.awt.print.PageFormat maxMargins(java.awt.print.PrinterJob printJob,
                                                   int orientation)
Create a PageFormat with a Paper that has the margin set to zero. Call the PrinterJob.validatePage(PageFormat) method, which returns a PageFormat that has a Paper with the minimum printable margins for that paper size. Note that not all printing services support finding the actual margins. In this case, use the default 1-inch margins.

Parameters:
printJob - PrinterJob
orientation - int
Returns:
PageFormat

threadedDefaultPrint

public static void threadedDefaultPrint(java.awt.print.Pageable pageable,
                                        java.awt.Component comp)

unthreadedPrint

public static void unthreadedPrint(java.awt.print.PrinterJob printJob,
                                   java.awt.Component comp)
Prints a printable with an hour glass, validating the margins and brining up the printer dialog.

Parameters:
printable - Printable
comp - Component

main

public static void main(java.lang.String[] args)


Copyright ? 2007 Gerhard Beck. All rights reserved. Subject to GPL.