java.lang.Object | ||
↳ | java.awt.print.PrinterJob | |
↳ | sun.print.RasterPrinterJob |
![]() |
A class which rasterizes a printer job.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FILE | ||||||||||
int | PRINTER | ||||||||||
int | STREAM |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
attributes | attributes used by no-args page and print dialog and print method to communicate state | ||||||||||
collateAttReq | |||||||||||
debugPrint | |||||||||||
destinationAttr | |||||||||||
forcePDL | values obtained from System properties in static initialiser block | ||||||||||
forceRaster | |||||||||||
landscapeRotates270 | Device rotation flag, if it support 270, this is set to true; | ||||||||||
mDestType | |||||||||||
mDestination | |||||||||||
myService | Service for this job | ||||||||||
noJobSheet | |||||||||||
shapeTextProp | |||||||||||
sidesAttr |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
If a print job is in progress, print() has been
called but has not returned, then this signals
that the job should be cancelled and the next
chance.
| |||||||||||
User dialogs should disable "File" buttons if this returns false.
| |||||||||||
The passed in PageFormat will be copied and altered to describe
the default page size and orientation of the PrinterJob's
current printer.
| |||||||||||
Get the number of copies to be printed.
| |||||||||||
Get the name of the document to be printed.
| |||||||||||
Returns the service (printer) for this printer job.
| |||||||||||
Get the name of the printing user.
| |||||||||||
Returns true is a print job is ongoing but will
be cancelled and the next opportunity.
| |||||||||||
return a PageFormat corresponding to the updated attributes,
or null if the user cancelled the dialog.
| |||||||||||
Display a dialog to the user allowing the modification of a
PageFormat instance.
| |||||||||||
Prints a set of pages.
| |||||||||||
Prints a set of pages using the settings in the attribute
set.
| |||||||||||
Presents the user a dialog for changing properties of the
print job interactively.
| |||||||||||
Presents the user a dialog for changing properties of the
print job interactively.
| |||||||||||
save graphics state of a PathGraphics for later redrawing
of part of page represented by the region in that state
| |||||||||||
Set the number of copies to be printed.
| |||||||||||
Set the name of the document to be printed.
| |||||||||||
The pages in the document to be printed are held by the
Pageable instance 'document'.
| |||||||||||
Associate this PrinterJob with a new PrintService.
| |||||||||||
The pages in the document to be printed by this PrinterJob
are drawn by the Printable object 'painter'.
| |||||||||||
The pages in the document to be printed by this PrinterJob
are drawn by the Printable object 'painter'.
| |||||||||||
The passed in PageFormat is cloned and altered to be usable on
the PrinterJob's current printer.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Examine the metrics captured by the
PeekGraphics instance and
if capable of directly converting this
print job to the printer's control language
or the native OS's graphics primitives, then
return a PathGraphics to perform
that conversion. | |||||||||||
Create and return an object that will
gather and hold metrics about the print
job.
| |||||||||||
Called by the print() method at the end of
a print job.
| |||||||||||
End a page.
| |||||||||||
Returns how many times the entire book should
be printed by the PrintJob.
| |||||||||||
Return the zero based index of the first page to
be printed in this job.
| |||||||||||
Return the zero based index of the last page to
be printed in this job.
| |||||||||||
Returns how many times each page in the book
should be consecutively printed by PrintJob.
| |||||||||||
Return the Pageable describing the pages to be printed.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Must be obtained from the current printer.
| |||||||||||
Returns the resolution in dots per inch across the width
of the page.
| |||||||||||
Returns the resolution in dots per inch down the height
of the page.
| |||||||||||
Return true if collated copies will be printed as determined
in an attribute set.
| |||||||||||
Prints the contents of the array of ints, 'data'
to the current page.
| |||||||||||
Print a page from the provided document.
| |||||||||||
Set whether copies should be collated or not.
| |||||||||||
Set the range of pages from a Book to be printed.
| |||||||||||
Called by the print() method at the start of
a print job.
| |||||||||||
Begin a new page.
| |||||||||||
updates a Paper object to reflect the current printer's selected
paper size and imageable area for that paper size.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
attributes used by no-args page and print dialog and print method to communicate state
values obtained from System properties in static initialiser block
Device rotation flag, if it support 270, this is set to true;
If a print job is in progress, print() has been called but has not returned, then this signals that the job should be cancelled and the next chance. If there is no print job in progress then this call does nothing.
User dialogs should disable "File" buttons if this returns false.
The passed in PageFormat will be copied and altered to describe the default page size and orientation of the PrinterJob's current printer. Platform subclasses which can access the actual default paper size for a printer may override this method.
page | the PageFormat to be cloned and altered |
---|
page
, altered to describe a default
PageFormat
.
Get the number of copies to be printed.
Get the name of the document to be printed.
Returns the service (printer) for this printer job. Implementations of this class which do not support print services may return null;
Get the name of the printing user. The caller must have security permission to read system properties.
Returns true is a print job is ongoing but will be cancelled and the next opportunity. false is returned otherwise.
true
if the job in progress
is going to be cancelled; false
otherwise.
return a PageFormat corresponding to the updated attributes, or null if the user cancelled the dialog.
attributes | on input is application supplied attributes, on output the contents are updated to reflect user choices. This parameter may not be null. |
---|
null
otherwise.HeadlessException |
---|
Display a dialog to the user allowing the modification of a
PageFormat instance.
The page
argument is used to initialize controls
in the page setup dialog.
If the user cancels the dialog, then the method returns the
original page
object unmodified.
If the user okays the dialog then the method returns a new
PageFormat object with the indicated changes.
In either case the original page
object will
not be modified.
page | the default PageFormat presented to the user for modification |
---|
page
object if the dialog
is cancelled, or a new PageFormat object containing
the format indicated by the user if the dialog is
acknowledgedHeadlessException | if GraphicsEnvironment.isHeadless() returns true. |
---|
Prints a set of pages.
PrinterException | an error in the print system caused the job to be aborted |
---|
Prints a set of pages using the settings in the attribute set. The default implementation ignores the attribute set.
Note that some attributes may be set directly on the PrinterJob
by equivalent method calls, (for example), copies:
setcopies(int)
, job name: setJobName(String)
and specifying media size and orientation though the
PageFormat
object.
If a supported attribute-value is specified in this attribute set,
it will take precedence over the API settings for this print()
operation only.
The following behaviour is specified for PageFormat:
If a client uses the Printable interface, then the
attributes
parameter to this method is examined
for attributes which specify media (by size), orientation, and
imageable area, and those are used to construct a new PageFormat
which is passed to the Printable object's print() method.
See Printable
for an explanation of the required
behaviour of a Printable to ensure optimal printing via PrinterJob.
For clients of the Pageable interface, the PageFormat will always
be as supplied by that interface, on a per page basis.
These behaviours allow an application to directly pass the
user settings returned from
printDialog(PrintRequestAttributeSet attributes
to
this print() method.
attributes | a set of attributes for the job |
---|
PrinterException |
---|
Presents the user a dialog for changing properties of the print job interactively. The services browsable here are determined by the type of service currently installed. If the application installed a StreamPrintService on this PrinterJob, only the available StreamPrintService (factories) are browsable.
attributes | to store changed properties. |
---|
HeadlessException | if GraphicsEnvironment.isHeadless() returns true. |
---|
Presents the user a dialog for changing properties of the print job interactively.
true
if the user does not cancel the dialog;
false
otherwise.HeadlessException | if GraphicsEnvironment.isHeadless() returns true. |
---|
save graphics state of a PathGraphics for later redrawing of part of page represented by the region in that state
Set the number of copies to be printed.
copies | the number of copies to be printed |
---|
Set the name of the document to be printed. The document name can not be null.
jobName | the name of the document to be printed |
---|
The pages in the document to be printed are held by the Pageable instance 'document'. 'document' will be queried for the number of pages as well as the PageFormat and Printable for each page.
document | the pages to be printed. It can not be
null . |
---|
NullPointerException | the Pageable passed in was null. |
---|
Associate this PrinterJob with a new PrintService.
Throws PrinterException
if the specified service
cannot support the Pageable
and
Printable
interfaces necessary to support 2D printing.
service | a print service that supports 2D printing |
---|
PrinterException | if the specified service does not support 2D printing or no longer available. |
---|
The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'. The PageFormat for each page is the default page format.
painter | the Printable that renders each page of
the document.
|
---|
The pages in the document to be printed by this PrinterJob are drawn by the Printable object 'painter'. The PageFormat of each page is 'format'.
painter | the Printable called to render
each page of the document |
---|---|
format | the size and orientation of each page to be printed |
The passed in PageFormat is cloned and altered to be usable on the PrinterJob's current printer.
page | the PageFormat that is cloned and
whose settings are changed to be compatible with
the current printer |
---|
PageFormat
that is cloned from
page
and whose settings are changed
to conform with this PrinterJob
.
Examine the metrics captured by the
PeekGraphics
instance and
if capable of directly converting this
print job to the printer's control language
or the native OS's graphics primitives, then
return a PathGraphics
to perform
that conversion. If there is not an object
capable of the conversion then return
null
. Returning null
causes the print job to be rasterized.
Create and return an object that will
gather and hold metrics about the print
job. This method is passed a Graphics2D
object that can be used as a proxy for the
object gathering the print job matrics. The
method is also supplied with the instance
controlling the print job, printerJob
.
Called by the print() method at the end of a print job.
PrinterException |
---|
End a page.
PrinterException |
---|
Returns how many times the entire book should be printed by the PrintJob. If the printer itself supports collation then this method should return 1 indicating that the entire book need only be printed once and the copies will be collated and made in the printer.
Return the zero based index of the first page to be printed in this job.
Return the zero based index of the last page to be printed in this job.
Returns how many times each page in the book should be consecutively printed by PrintJob. If the printer makes copies itself then this method should return 1.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Must be obtained from the current printer. Value is in device pixels. Not adjusted for orientation of the paper.
Returns the resolution in dots per inch across the width of the page.
Returns the resolution in dots per inch down the height of the page.
Return true if collated copies will be printed as determined in an attribute set.
Prints the contents of the array of ints, 'data' to the current page. The band is placed at the location (x, y) in device coordinates on the page. The width and height of the band is specified by the caller.
PrinterException |
---|
Print a page from the provided document.
PrinterException |
---|
Set whether copies should be collated or not. Two collated copies of a three page document print in this order: 1, 2, 3, 1, 2, 3 while uncollated copies print in this order: 1, 1, 2, 2, 3, 3. This is set when request is using an attribute set.
Set the range of pages from a Book to be printed. Both 'firstPage' and 'lastPage' are zero based page indices. If either parameter is less than zero then the page range is set to be from the first page to the last.
Called by the print() method at the start of a print job.
PrinterException |
---|
Begin a new page.
PrinterException |
---|
updates a Paper object to reflect the current printer's selected paper size and imageable area for that paper size. Default implementation copies settings from the original, applies applies some validity checks, changes them only if they are clearly unreasonable, then sets them into the new Paper. Subclasses are expected to override this method to make more informed decisons.