|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.numdata.printer.PrintTools
public class PrintTools
This class provides functionality for printing.
| Field Summary | |
|---|---|
static double |
INCH_IN_MILLIMETERS
Length of an inch expressed in millimeters. |
static int |
LPD_PORT
The default LPD port number. |
static double |
POINT_IN_INCHES
Size of a PostScript point (1/72 inch) expressed in inches. |
static double |
POINT_IN_MILLIMETERS
Size of a PostScript point (1/72 inch) expressed in millimeters. |
| Method Summary | |
|---|---|
static PrintService |
getPrintService(String printerName,
DocFlavor docFlavor)
Get PrintService for printer that has the given name and supports
the given document flavor, if either is specified. |
static Map<String,PrintService> |
getPrintServices(DocFlavor docFlavor)
Get map of print services by (printer) name. |
static PrintService |
printDialogForDoc(Doc doc)
Show print dialog for the given document. |
static void |
printDoc(Doc doc)
Print a document. |
static void |
printRaw(PrinterSettings settings,
String documentName,
byte[] documentData,
boolean raw)
Print a document by using the specified PrinterSettings. |
static void |
printRawFileToJPS(PrintService printService,
File file)
Send raw file to print service. |
static void |
printRawFileToJPS(String printerName,
File file)
Send raw file to print service. |
static void |
printTable(JTable table,
String header,
String footer)
Print a JTable. |
static void |
printText(String text)
Print a plain text document. |
static BufferedImage |
printToImage(PageFormat pageFormat,
double resolution,
Printable document)
Renders the given printable document to an image matching the given page format and resolution. |
static void |
printToJPS(PrintService printService,
Doc doc,
boolean waitUntilDone)
Print a document to the given print service. |
static void |
printToJPS(String queueName,
String documentName,
Printable document,
PageFormat pageFormat)
Prints the given document to a local printer using the Java Print API. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double INCH_IN_MILLIMETERS
public static final double POINT_IN_INCHES
public static final double POINT_IN_MILLIMETERS
public static final int LPD_PORT
| Method Detail |
|---|
public static void printDoc(Doc doc)
doc - Document to print.
public static void printTable(JTable table,
String header,
String footer)
JTable. The table is scaled to fit the page. A print dialog
is displayed before the actual print job is executed.
table - Table to print.header - Header text (null => none).footer - Footer text (null => none).public static void printText(String text)
text - Content of text document to print.public static PrintService printDialogForDoc(Doc doc)
doc - Document to print.
PrintService that was selected; null if dialog was
cancelled.
public static void printRaw(PrinterSettings settings,
String documentName,
byte[] documentData,
boolean raw)
throws PrinterException
PrinterSettings.
settings - Printer settings to use.documentName - Name of document to display in queue.documentData - Document data to print.raw - Document data is raw vs. cooked (from printer's
perspective).
PrinterException - if the document could not be printed.
public static BufferedImage printToImage(PageFormat pageFormat,
double resolution,
Printable document)
throws PrinterException
pageFormat - Page format to be used.resolution - Resolution of the image, in dots per inch.document - Document to be rendered to an image.
PrinterException - if an error occurs while rendering the image.
IllegalArgumentException - if the document doesn't contain any pages
to be rendered, or if the given resolution and/or page size are too small to
render an image of the page.
public static void printToJPS(@Nullable
String queueName,
@Nullable
String documentName,
@NotNull
Printable document,
@Nullable
PageFormat pageFormat)
throws PrinterException
queueName - Name of the printer; null to use the default
printer.documentName - Name of the document.document - Document to be printed.pageFormat - Optional page format for document.
PrinterException - if an error occurs while printing.
public static void printToJPS(PrintService printService,
Doc doc,
boolean waitUntilDone)
throws PrinterException
printService - Print service to use.doc - Document to print.waitUntilDone - Wait until the print job is done.
PrinterException - if the document could not be printed.
public static void printRawFileToJPS(@Nullable
String printerName,
@NotNull
File file)
throws PrinterException
printerName - Name of printer (null to use default/any).file - Raw file.
PrinterException - if the document could not be printed.
public static void printRawFileToJPS(@NotNull
PrintService printService,
@NotNull
File file)
throws PrinterException
printService - Print service to use.file - Raw file.
PrinterException - if the document could not be printed.
@NotNull
public static PrintService getPrintService(@Nullable
String printerName,
@Nullable
DocFlavor docFlavor)
throws PrinterException
PrintService for printer that has the given name and supports
the given document flavor, if either is specified.
printerName - Printer name (if null, use default).docFlavor - Required document flavor (null = any).
PrintService.
PrinterException - if the printer service is not available.
@NotNull
public static Map<String,PrintService> getPrintServices(@Nullable
DocFlavor docFlavor)
docFlavor - Document flavor to get service for (null = any).
PrintService by (printer) name.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||