Top Description Inners Fields Constructors Methods
javafx.print

public final Class Printer

extends Object
Class Inheritance
Imports
com.sun.javafx.print.PrintHelper, .PrinterImpl, .Units, javafx.beans.property.ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, javafx.collections.ObservableSet, javafx.geometry.Rectangle2D, com.sun.javafx.tk.PrintPipeline

A Printer instance represents the destination for a print job.

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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Printer.MarginType

The MarginType is used to determine the printable area of a PageLayout.

Field Summary

Modifier and TypeField and Description
private PrinterAttributes
private static ReadOnlyObjectWrapper<Printer>
private PageLayout
private PrinterImpl

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public PageLayout

Returns:

PageLayout based on the specified parameters.
createPageLayout
(Paper
The paper to use
paper
,
PageOrientation
The orientation to use
orient
,
Printer.MarginType
the margin type to use
mType
)

Obtain a new PageLayout instance for this printer using the specified parameters.

public PageLayout

Returns:

PageLayout based on the specified parameters.
createPageLayout
(Paper
The paper to use
paper
,
PageOrientation
The orientation to use
orient
,
double
the left margin to use in pts.
lMargin
,
double
the right margin to use in pts.
rMargin
,
double
the top margin to use in pts.
tMargin
,
double
the bottom margin to use in pts.
bMargin
)

Obtain a new PageLayout for this printer using the specified parameters.

private static ReadOnlyObjectWrapper<Printer>
public static ReadOnlyObjectProperty<Printer>

Returns:

the current default printer
defaultPrinterProperty
()

A read only object property representing the current default printer.

public static ObservableSet<Printer>

Returns:

may be null if there are no printers.
getAllPrinters
()

Retrieve the installed printers.

pack-priv JobSettings
getDefaultJobSettings()

Returns the default settings for this printer as would be used in setting up a job for this printer.

public PageLayout

Returns:

default page layout.
getDefaultPageLayout
()

Return the default page layout for this printer.

public static Printer

Returns:

default printer or null.
getDefaultPrinter
()

Retrieve the default printer.

public String

Returns:

printer name.
getName
()

Return the name used by the underlying system to identify the printer to users and/or applications.

public PrinterAttributes

Returns:

printer attributes.
getPrinterAttributes
()

Retrieves the delegate object encapsulating the printer attributes and capabilities.

pack-priv PrinterImpl
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributesback to summary
private PrinterAttributes attributes
defaultPrinterback to summary
private static ReadOnlyObjectWrapper<Printer> defaultPrinter
defPageLayoutback to summary
private PageLayout defPageLayout
implback to summary
private PrinterImpl impl

Constructor Detail

Printerback to summary
pack-priv Printer(PrinterImpl impl)

Method Detail

createPageLayoutback to summary
public PageLayout createPageLayout(Paper paper, PageOrientation orient, Printer.MarginType mType)

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:Paper

The paper to use

orient:PageOrientation

The orientation to use

mType:Printer.MarginType

the margin type to use

Returns:PageLayout

PageLayout based on the specified parameters.

Exceptions
NullPointerException:
if any of the parameters are null.
createPageLayoutback to summary
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:Paper

The paper to use

orient:PageOrientation

The orientation to use

lMargin:double

the left margin to use in pts.

rMargin:double

the right margin to use in pts.

tMargin:double

the top margin to use in pts.

bMargin:double

the bottom margin to use in pts.

Returns:PageLayout

PageLayout based on the specified parameters.

Exceptions
NullPointerException:
if paper or orient are null.
IllegalArgumentException:
if any of the margins values are less than zero.
defaultPrinterImplback to summary
private static ReadOnlyObjectWrapper<Printer> defaultPrinterImpl()
defaultPrinterPropertyback to summary
public static ReadOnlyObjectProperty<Printer> defaultPrinterProperty()

A read only object property representing the current default printer. If there are no installed printers, the wrapped value will be null.

Returns:ReadOnlyObjectProperty<Printer>

the current default printer

getAllPrintersback to summary
public static ObservableSet<Printer> 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:ObservableSet<Printer>

may be null if there are no printers.

getDefaultJobSettingsback to summary
pack-priv JobSettings getDefaultJobSettings()

Returns the default settings for this printer as would be used in setting up a job for this printer.

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.

getDefaultPageLayoutback to summary
public PageLayout getDefaultPageLayout()

Return the default page layout for this printer.

Returns:PageLayout

default page layout.

getDefaultPrinterback to summary
public static Printer 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:Printer

default printer or null.

getNameback to summary
public String getName()

Return the name used by the underlying system to identify the printer to users and/or applications.

Returns:String

printer name.

getPrinterAttributesback to summary
public PrinterAttributes getPrinterAttributes()

Retrieves the delegate object encapsulating the printer attributes and capabilities.

Returns:PrinterAttributes

printer attributes.

getPrinterImplback to summary
pack-priv PrinterImpl getPrinterImpl()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
javafx.print back to summary

public final Enum Printer.MarginType

extends Enum<Printer.MarginType>
Class Inheritance

The MarginType is used to determine the printable area of a PageLayout.
Since
JavaFX 8.0

Field Summary

Modifier and TypeField and Description
public static final Printer.MarginType
DEFAULT

This requests a default 0.75 inch margin on all sides.

public static final Printer.MarginType
EQUAL

Choose the largest of the four hardware margins, and use that for all for margins, so that the margins are equal on all sides.

public static final Printer.MarginType
EQUAL_OPPOSITES

Similar to EQUAL, but it chooses the larger of the left/right hardware margins and top/bottom hardware margins separately, so that the top and bottom margins are equal, and the left and right margins are equal.

public static final Printer.MarginType
HARDWARE_MINIMUM

Request margins are set to be the smallest on each side that the hardware allows.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Printer.MarginType
public static Printer.MarginType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DEFAULTback to summary
public static final Printer.MarginType DEFAULT

This requests a default 0.75 inch margin on all sides. This is considered to be a common default and is supported by all known printers. However this may be adjusted if the paper is too small, to ensure that the margins are not more than 50% of the smaller dimension. Applications that do expect to deal with such small media should likely be specifying the required margins explicitly. In the unlikely event the hardware margin is larger than 0.75" it will be adjusted to that same hardware minimum on all sides.

EQUALback to summary
public static final Printer.MarginType EQUAL

Choose the largest of the four hardware margins, and use that for all for margins, so that the margins are equal on all sides.

EQUAL_OPPOSITESback to summary
public static final Printer.MarginType EQUAL_OPPOSITES

Similar to EQUAL, but it chooses the larger of the left/right hardware margins and top/bottom hardware margins separately, so that the top and bottom margins are equal, and the left and right margins are equal.

HARDWARE_MINIMUMback to summary
public static final Printer.MarginType HARDWARE_MINIMUM

Request margins are set to be the smallest on each side that the hardware allows. This creates the greatest printable area but the margins may not be aesthetic if they are too small, or there is significant variation on the different sides of the paper.

This is is also useful for an application that wants to know this so it can construct a new PageLayout that fits within these margins.

Constructor Detail

MarginTypeback to summary
private MarginType()

Method Detail

valueOfback to summary
public static Printer.MarginType valueOf(String name)
valuesback to summary
public static Printer.MarginType[] values()