public final class PrintHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
adjustGraphics2D(Graphics2D g,
PageFormat format)
Adjusts the graphics context according to the given format.
The job can be printed in two ways: by job.print() and by job.print(aset). |
static MediaSizeName |
getMediaSizeName()
Gets the media size name.
|
static PageFormat |
getPageFormat(PrintRequestAttributeSet aset)
Builds a pageformat from an attribute set.
This is the "missing" link between printDialog(aset) and setting the pageFormat without calling pageDialog(). |
static Runnable |
getRunAfterPrint()
Gets the Runnable to be invoked after job.print(aset).
|
static Runnable |
getRunBeforePrint()
Gets the Runnable to be invoked before job.print(aset).
|
static boolean |
print(Printable printable,
String jobName)
Asks the user for a printer and settings and prints a printable.
|
static PageFormat |
print(PrinterJob job,
String jobName,
PrintRequestAttributeSet aset)
Asks the user for a printer and settings and return the pageformat.
Does not print! Use printJob(java.awt.print.PrinterJob, javax.print.attribute.PrintRequestAttributeSet, boolean) to print. |
static WorkerThread |
printJob(PrinterJob job,
PrintRequestAttributeSet aset)
Prints a job in separate thread in a modal dialog.
|
static WorkerThread |
printJob(PrinterJob job,
PrintRequestAttributeSet aset,
boolean modal)
Prints a job in separate worker thread while displaying a printing worker dialog.
Requests are automatically queued in background if jobs are not finished yet. |
static void |
setMediaSizeName(MediaSizeName name)
Sets the media size.
|
static void |
setRunAfterPrint(Runnable run)
Sets a Runnable to be invoked after job.print(aset).
|
static void |
setRunBeforePrint(Runnable run)
Sets a Runnable to be invoked before job.print(aset).
|
public static boolean print(Printable printable, String jobName)
printable - the printablejobName - the name of the jobpublic static PageFormat print(PrinterJob job, String jobName, PrintRequestAttributeSet aset)
printJob(java.awt.print.PrinterJob, javax.print.attribute.PrintRequestAttributeSet, boolean) to print.job - is the new printerjobjobName - is the jobname, null = noneaset - is an initialized (and possibly empty) attribute set, must not be null, because its returned!public static boolean adjustGraphics2D(Graphics2D g, PageFormat format)
g - the graphics contextformat - the pageformatpublic static PageFormat getPageFormat(PrintRequestAttributeSet aset)
aset - the attribute setpublic static WorkerThread printJob(PrinterJob job, PrintRequestAttributeSet aset, boolean modal)
job - the printer jobaset - the printing attributesmodal - true if modal dialogpublic static WorkerThread printJob(PrinterJob job, PrintRequestAttributeSet aset)
job - the printer jobaset - the printing attributesprintJob(java.awt.print.PrinterJob, javax.print.attribute.PrintRequestAttributeSet, boolean)public static void setMediaSizeName(MediaSizeName name)
name - the MediaSizeNamepublic static MediaSizeName getMediaSizeName()
public static void setRunBeforePrint(Runnable run)
run - the runnablepublic static Runnable getRunBeforePrint()
public static void setRunAfterPrint(Runnable run)
run - the runnablepublic static Runnable getRunAfterPrint()
Copyright © 2016 Krake Softwaretechnik. All rights reserved.