Use the Smart JPrint APIs that is available for free. In about a minue you should be able to print, preview, optionally PDF generate your Java programs and Swing component (JTextArea, JTextPane, JEditorPane, any JTextComponent , JTable) content and and J2EE program outout.
Smart JPrint is a pure Java class library used for the following: . Creates PDF documents from your J2EE and Java Swing GUI programs . Prints the output to a printer </li> . Allows your users to preview the output pages in a GUI window
. 100% pure Java classes . Generate PDF automatically (automatically breaks text lines, images, rows, columns into pages). . Print the output to a printer. . Preview output pages in a wanderful UI (this feature is normally used for Java Swing GUI applications). . Only few lines of code to Print or generate PDF. . Only 2 lines of code to generate PDF and Print swing components. . Print and generate PDF from Swing components such as JTable, JTextArea, JTextPane, JEditorPane etc. . Write J2EE program output as text, icons, 2D graphics to generate PDF automatically. . Print and generate PDF for multiple Swing components next to each other.