Friday, July 06, 2007

Printing API of Java 2D

Printing is an area where Java has changed a lot since its first version. First printing resources arose in JDK 1.1, with AWT Printing API. When JDK 1.2 has arrived, Java Printing API came along, giving support to graphic bidimensional printing (texts, images, etc). More recently, Java Print Service (JPS) was introduced. It offers a set of new features, such as dynamic knowledge of available printers. But this article will focus on Printing API of Java 2D.



Printing system of Printing API is very similar to that used to render Java 2D graphics on monitor. We must provide a paint( ) method with rendering code in order to render the screen. But in order to use printing features, we must implement a paint( ) method.



The application only needs to provide the document content to be printed and let printing system to determine when each page must be generated. This system makes possible for JVM to implement the necessary optimizations to printing process.



You need to accomplish two tasks in order to accomplish printing with Java 2D: to render pages and to manage the printing job.

No comments: