Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Java matured very quickly in most respects after it was first introduced, but for a long time, printing was one of Java's
weakest points. In fact, Java 1.0 didn't offer any support for printing at all. Java 1.1 included a class called
PrintJob in the
java.awt package, but the printing capabilities supported by that class were somewhat crude and unreliable. When Java 1.2 (or "Java 2") was
introduced, it included a completely separate mechanism (called the Java 2D printing API) for printing designed around
PrinterJob and other classes and interfaces defined in the new
java.awt.print package. This rendered the
PrintJob-based printing mechanism (also known as AWT printing) largely obsolete, although
PrintJob has never been deprecated and, at least of this writing, is still technically a supported class.
Additional changes were made in J2SE 1.3 when
PrintJob's capabilities expanded to allow the setting of job and page attributes using the appropriately named
PageAttributes classes within the
java.awt package. With the release of J2SE 1.3, the printing capabilities were reasonably robust, but some problems still existed
aside from the confusion associated with having two completely separate printing facilities. For one thing, both facilities
used an implementation of the
java.awt.Graphics class for rendering the content to be printed, which meant anything that needed to be printed had to be rendered as a graphical
image. In addition, the newer and generally more robust
PrinterJob facility provided only limited support for setting attributes associated with the job. Finally, neither facility provided
a way to programmatically select the target printer.
The biggest change in Java's printing capabilities to date came with the release of J2SE 1.4, when the Java print service
API was introduced. This third implementation of printing support in Java addressed the limitations that were just described
using an implementation of the
DocPrintJob interfaces defined in the
javax.print package. Because this new API represents a superset of the functionality defined by the two older printing facilities, it's
the one you should normally use and will be the focus of this article.
At a high level, the steps involved in using the Java print service API are straightforward:
createPrintJob()method defined in the
PrintServiceinterface. The print job is represented by an instance of
Docinterface that describes the data you want to print. You also have the option of creating an instance of
PrintRequestAttributeSetthat describes the printing options you want.
print()method defined in the
DocPrintJobinterface, specifying the
Docyou created in the previous step and the
PrintRequestAttributeSetor a null value.
You'll now examine each of these steps and see how to achieve them.
|Forum migration complete By Athen|
|Forum migration update By Athen|
|Q: When am I going to get paid? A: Never. By Brett Spell|
|Java Pro Programming: Printing By JavaWorld|