public final class Printer extends 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 ReadOnlyObjectProperty<Printer> |
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 | 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.
|
static ReadOnlyObjectProperty<Printer> |
defaultPrinterProperty()
A read only object property representing the current default printer.
|
static ObservableSet<Printer> |
getAllPrinters()
Retrieve the installed printers.
|
PageLayout |
getDefaultPageLayout()
Return the default page layout for this printer.
|
static Printer |
getDefaultPrinter()
Retrieve the default printer.
|
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.
|
String |
toString() |
public static ReadOnlyObjectProperty<Printer> defaultPrinterProperty
getDefaultPrinter()
public static ObservableSet<Printer> getAllPrinters()
Note: since printers may be installed, but offline, then the application may want to query the status of a printer before using it.
SecurityException
- if the application does not
have permission to browse printers.public static ReadOnlyObjectProperty<Printer> 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.
SecurityException
- if the application does not
have permission to browse printers.public String getName()
public PrinterAttributes getPrinterAttributes()
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 useNullPointerException
- 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.NullPointerException
- if paper or orient are null.IllegalArgumentException
- if any of the margins values are
less than zero.Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.