Holger's Java API

## com.antelmann.util
Class PrintUtilities

    java.lang.Object
      com.antelmann.util.PrintUtilities

    public class PrintUtilities

extends Object

some ease-of-use-functions for printing.

Author:
  Holger Antelmann
See Also:
  `JPrinterSelect`

Nested Class Summary
`static interface` `PrintUtilities.Printer` allows to plug in a printing service into PrintUtilities

Field Summary
`static MediaName` `mediaName` currently uses ISO_A4_WHITE by default

Method Summary
`static String` `getInfoOn(PrintService service)`
`static PrintUtilities.Printer` `getPrinter()` returns the printer to be used
`static String[]` `getPrinterNames()`
`static PrintService` `getPrintServiceByName(String name)`
`static Color` `getTextColor()`
`static Font` `getTextFont()` returns the special font to be used when printing text; may be null
`static ArrayList<Media>` `listMedia(PrintService ps, Filter<Media> filter)`
`static void` `print(Component c, boolean scaleToPageWidth)` prints the given component after selecting the desired printer
`static void` `print(JEditorPane jeditorPane, boolean scaleToPageWidth)` supports to properly print the JEditorPane to multiple pages with 'smart' page breaks.
`static void` `print(PrinterJob printJob, Component c, boolean scaleToPageSize)`
`static void` `print(PrinterJob printJob, JEditorPane jeditorPane, boolean scaleToPageWidth)` supports to properly print the JEditorPane to multiple pages with 'smart' page breaks.
`static DocPrintJob` `print(PrintService service, InputStream stream)`
`static void` `printASCIIText(PrintService service, String text, boolean formFeed)` prints the given text to the given print service (adding a formFeed if desired)
`static void` `printASCIIText(String text)` calls `text(text, true)`
`static void` `printASCIIText(String text, boolean formFeed)` prints the given text to the default printer (adding a formFeed if desired)
`static void` `printFrame(PrinterJob job)` prints a page with a frame to see the printable area (for debugging)
`static void` `printOnePage(PrinterJob printJob, Component c)`
`static void` `printText(String text)` uses a TextPrinter and utilizes text color and font if set
`static void` `printText(String text, PrinterJob job, boolean showDialog)` uses a TextPrinter and utilizes text color and font if set
`static void` `printTextFile(File asciiFile)`
`static void` `printTextFile(PrintService service, File asciiFile)`
`static void` `printToService(Object... obj)` uses the currently configured Printer object to print the given object.
`static void` `setPrinter(PrintUtilities.Printer printer)` sets the printer to be used
`static void` `setTextColor(Color color)`
`static void` `setTextFont(Font font)` sets a special font to be used when printing text; may be null
`static void` `useA4()`
`static void` `useLetter()`
`static void` `winPrintASCII(File file, String device)` Deprecated.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### mediaName

    public static MediaName mediaName

  currently uses ISO_A4_WHITE by default

Method Detail

### getPrinterNames

    public static String[] getPrinterNames()

### getPrintServiceByName

    public static PrintService getPrintServiceByName(String name)

### setPrinter

    public static void setPrinter(PrintUtilities.Printer printer)

  sets the printer to be used

  See Also:
    `printToService(Object...)`, `getPrinter()`

### getPrinter

    public static PrintUtilities.Printer getPrinter()

  returns the printer to be used

  See Also:
    `printToService(Object...)`, `setPrinter(Printer)`

### printToService

    public static void printToService(Object... obj)
                               throws PrintException,
                                      IOException,
                                      IllegalArgumentException,
                                      NullPointerException

  uses the currently configured Printer object to print the given object.

  Throws:
    `NullPointerException` - if the embedded printing service is null
    `PrintException`
    `IOException`
    `IllegalArgumentException`
  See Also:
    `getPrinter()`, `setPrinter(Printer)`, `PrintUtilities.Printer`

### useA4

    public static void useA4()

### useLetter

    public static void useLetter()

### printFrame

    public static void printFrame(PrinterJob job)
                           throws PrinterException

  prints a page with a frame to see the printable area (for debugging)

  Throws:
    `PrinterException`

### listMedia

    public static ArrayList<Media> listMedia(PrintService ps,
                                             Filter<Media> filter)

### print

    public static void print(Component c,
                             boolean scaleToPageWidth)
                      throws PrinterException

  prints the given component after selecting the desired printer

  Throws:
    `PrinterException`

### print

    public static void print(PrinterJob printJob,
                             Component c,
                             boolean scaleToPageSize)
                      throws PrinterException

  Throws:
    `PrinterException`

### print

    public static void print(JEditorPane jeditorPane,
                             boolean scaleToPageWidth)
                      throws PrinterException

  supports to properly print the JEditorPane to multiple pages with 'smart' page breaks.

  Throws:
    `PrinterException`

### print

    public static void print(PrinterJob printJob,
                             JEditorPane jeditorPane,
                             boolean scaleToPageWidth)
                      throws PrinterException

  supports to properly print the JEditorPane to multiple pages with 'smart' page breaks.

  Throws:
    `PrinterException`

### printOnePage

    public static void printOnePage(PrinterJob printJob,
                                    Component c)
                             throws PrinterException

  Throws:
    `PrinterException`

### setTextColor

    public static void setTextColor(Color color)

### getTextColor

    public static Color getTextColor()

### setTextFont

    public static void setTextFont(Font font)

  sets a special font to be used when printing text; may be null

### getTextFont

    public static Font getTextFont()

  returns the special font to be used when printing text; may be null

### printText

    public static void printText(String text)
                          throws PrintException

  uses a TextPrinter and utilizes text color and font if set

  Throws:
    `PrintException`
  See Also:
    `TextPrinter`

### printText

    public static void printText(String text,
                                 PrinterJob job,
                                 boolean showDialog)
                          throws PrintException

  uses a TextPrinter and utilizes text color and font if set

  Throws:
    `PrintException`
  See Also:
    `TextPrinter`

### printASCIIText

    public static void printASCIIText(String text)
                               throws PrintException

  calls `text(text, true)`

  Throws:
    `PrintException`
  See Also:
    `printASCIIText(String, boolean)`

### printASCIIText

    public static void printASCIIText(String text,
                                      boolean formFeed)
                               throws PrintException

  prints the given text to the default printer (adding a formFeed if desired)

  Throws:
    `PrintException`

### printASCIIText

    public static void printASCIIText(PrintService service,
                                      String text,
                                      boolean formFeed)
                               throws PrintException

  prints the given text to the given print service (adding a formFeed if desired)

  Throws:
    `PrintException`

### winPrintASCII

    @Deprecated
    public static void winPrintASCII(File file,
                                                String device)
                              throws IOException

  Deprecated.

  directly sends a file to the specified device using the `print` command. This method is platform dependent.

  Throws:
    `IOException`
  See Also:
    `Misc.start(String...)`

### printTextFile

    public static void printTextFile(File asciiFile)
                              throws IOException,
                                     PrintException

  Throws:
    `IOException`
    `PrintException`

### printTextFile

    public static void printTextFile(PrintService service,
                                     File asciiFile)
                              throws IOException,
                                     PrintException

  Throws:
    `IOException`
    `PrintException`

### print

    public static DocPrintJob print(PrintService service,
                                    InputStream stream)
                             throws IOException,
                                    PrintException

  Throws:
    `IOException`
    `PrintException`

### getInfoOn

    public static String getInfoOn(PrintService service)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads