Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Printing a JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Printing a JTextPane" Watch "Printing a JTextPane" New topic

Printing a JTextPane

Frank Hale
Ranch Hand

Joined: Mar 25, 2000
Posts: 230
Can someone point me to a code snippet which demonstrates how to print a JTextPane? Basically what I want to do is load an HTML page into a JTextPane and then print it off.
Frank Hale
Ranch Hand

Joined: Mar 25, 2000
Posts: 230
Surely someone has to know how to use the print API. Lots of you guys are certified too.
Janny Tima

Joined: May 05, 2004
Posts: 2
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.

Lok at the online demo:

About Smart JPrint?

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.
I agree. Here's the link:
subject: Printing a JTextPane
It's not a secret anymore!