public final class Printer
extends java.lang.Object
Printers may be enumerated and selected for use with a print job.
The configuration of the printer default settings are then used to populate the initial settings for a job.
Since the availability of printers may change during the execution of a program, due to administrative actions, a long running program which has cached a printer which has since been taken off-line, may create a job using that instance, but printing will fail.
Type | Property and Description |
---|---|
static <any> |
defaultPrinter
A read only object property representing the current default printer.
|
Modifier and Type | Class and Description |
---|---|
static class |
Printer.MarginType
The MarginType is used to determine the printable area of a PageLayout.
|
Modifier and Type | Field and Description |
---|---|
private PrinterAttributes |
attributes |
private static <any> |
defaultPrinter |
private PageLayout |
defPageLayout |
private PrinterImpl |
impl |
Constructor and Description |
---|
Printer(PrinterImpl impl) |
Modifier and Type | Method and Description |
---|---|
PageLayout |
createPageLayout(Paper paper,
PageOrientation orient,
double lMargin,
double rMargin,
double tMargin,
double bMargin)
Obtain a new PageLayout for this printer using the specified
parameters.
|
PageLayout |
createPageLayout(Paper paper,
PageOrientation orient,
Printer.MarginType mType)
Obtain a new PageLayout instance for this printer using the specified
parameters.
|
private static <any> |
defaultPrinterImpl() |
static <any> |
defaultPrinterProperty()
A read only object property representing the current default printer.
|
static <any> |
getAllPrinters()
Retrieve the installed printers.
|
(package private) JobSettings |
getDefaultJobSettings()
Returns the default settings for this printer as would be
used in setting up a job for this printer.
|
PageLayout |
getDefaultPageLayout()
Return the default page layout for this printer.
|
static Printer |
getDefaultPrinter()
Retrieve the default printer.
|
java.lang.String |
getName()
Return the name used by the underlying system to identify
the printer to users and/or applications.
|
PrinterAttributes |
getPrinterAttributes()
Retrieves the delegate object encapsulating the printer
attributes and capabilities.
|
(package private) PrinterImpl |
getPrinterImpl() |
java.lang.String |
toString() |
public static <any> defaultPrinterProperty
getDefaultPrinter()
private static <any> defaultPrinter
private PrinterImpl impl
private PrinterAttributes attributes
private PageLayout defPageLayout
public static <any> getAllPrinters()
Note: since printers may be installed, but offline, then the application may want to query the status of a printer before using it.
java.lang.SecurityException
- if the application does not
have permission to browse printers.private static <any> defaultPrinterImpl()
public static <any> defaultPrinterProperty()
getDefaultPrinter()
public static Printer getDefaultPrinter()
The configuration of available printers may be dynamic. Consequently there is no guarantee that the result will be the same from call to call, but should change only as a result of the default changing in the environment of the application.
java.lang.SecurityException
- if the application does not
have permission to browse printers.PrinterImpl getPrinterImpl()
public java.lang.String getName()
public PrinterAttributes getPrinterAttributes()
JobSettings getDefaultJobSettings()
When a job is first created and associated with a printer, (typically the default printer), it acquires these default settings for that printer. This method always returns a new instance.
public PageLayout getDefaultPageLayout()
public PageLayout createPageLayout(Paper paper, PageOrientation orient, Printer.MarginType mType)
paper
- The paper to useorient
- The orientation to usemType
- the margin type to usejava.lang.NullPointerException
- if any of the parameters are null.public PageLayout createPageLayout(Paper paper, PageOrientation orient, double lMargin, double rMargin, double tMargin, double bMargin)
Margin values are specified in 1/72 of an inch points. Margins will be validated against the printer supported margins, and adjusted if necessary. This method is generally useful to a client that wants margins that are different (eg wider) than the default margins, such as 1" at top and bottom and 0.5" to the left and right.
A client that needs to know what margin values are legal should first
obtain a PageLayout using the HARDWARE_MINIMUM
margins.
If the printer cannot support the layout as specified, it will adjust the returned layout to a supported configuration
paper
- The paper to useorient
- The orientation to uselMargin
- the left margin to use in pts.rMargin
- the right margin to use in pts.tMargin
- the top margin to use in pts.bMargin
- the bottom margin to use in pts.java.lang.NullPointerException
- if paper or orient are null.java.lang.IllegalArgumentException
- if any of the margins values are
less than zero.public java.lang.String toString()
toString
in class java.lang.Object