Class Printer
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.
- Since:
- JavaFX 8.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The MarginType is used to determine the printable area of a PageLayout. -
Property Summary
TypePropertyDescriptionstatic ReadOnlyObjectProperty
<Printer> A read only object property representing the current default printer. -
Method Summary
Modifier and TypeMethodDescriptioncreatePageLayout
(Paper paper, PageOrientation orient, double lMargin, double rMargin, double tMargin, double bMargin) Obtain a new PageLayout for this printer using the specified parameters.createPageLayout
(Paper paper, PageOrientation orient, Printer.MarginType mType) Obtain a new PageLayout instance for this printer using the specified parameters.static ReadOnlyObjectProperty
<Printer> A read only object property representing the current default printer.static ObservableSet
<Printer> Retrieve the installed printers.Return the default page layout for this printer.static Printer
Retrieve the default printer.getName()
Return the name used by the underlying system to identify the printer to users and/or applications.Retrieves the delegate object encapsulating the printer attributes and capabilities.
-
Property Details
-
defaultPrinter
A read only object property representing the current default printer. If there are no installed printers, the wrapped value will be null.- See Also:
-
-
Method Details
-
getAllPrinters
Retrieve the installed printers. The set of 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.Note: since printers may be installed, but offline, then the application may want to query the status of a printer before using it.
- Returns:
- may be null if there are no printers.
-
defaultPrinterProperty
A read only object property representing the current default printer. If there are no installed printers, the wrapped value will be null.- Returns:
- the current default printer
- See Also:
-
getDefaultPrinter
Retrieve the default printer. May return null if no printers are installed.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.
- Returns:
- default printer or null.
-
getName
Return the name used by the underlying system to identify the printer to users and/or applications.- Returns:
- printer name.
-
getPrinterAttributes
Retrieves the delegate object encapsulating the printer attributes and capabilities.- Returns:
- printer attributes.
-
getDefaultPageLayout
Return the default page layout for this printer.- Returns:
- default page layout.
-
createPageLayout
Obtain a new PageLayout instance for this printer using the specified parameters. The paper should be one of the supported papers and the orientation should be a supported orientation. If the printer cannot support the layout as specified, it will adjust the returned layout to a supported configuration- Parameters:
paper
- The paper to useorient
- The orientation to usemType
- the margin type to use- Returns:
- PageLayout based on the specified parameters.
- Throws:
NullPointerException
- if any of the parameters are null.
-
createPageLayout
public 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. The paper should be one of the supported papers and the orientation should be a supported orientation.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
- Parameters:
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.- Returns:
- PageLayout based on the specified parameters.
- Throws:
NullPointerException
- if paper or orient are null.IllegalArgumentException
- if any of the margins values are less than zero.
-