How can I print a form, where I want to control the position and appearance of text anywhere on a printed page? For example, say I have a Java program that prints nicely formatted invoices, or perhaps bank statements, where I want to use different fonts and place everything just right. Is anything built into the standard Java API that will help? How about 3rd party packages? Can I somehow use AWT to create the image and then direct it to the printer? I could even write the data out as xml and then use xsl to format it, although that sure seems like the long way around. I figure there must be a simple way, because doing this is fundamental to a lot of business applications. It's just not obvious to me what the best way is. Ron
It's a little much to go into a lot of detail here but there is a PrinterJob class and a Printable interface that allow you to do what you want. You use methods of the Graphics class to print to the printer just as you would use these methods to draw on the screen. Core Java Volume 2 by Horstmann has some good examples in Chapter 7, Advanced AWT.