File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing in "html/text" format

 
kyle johnson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm working on a project and I want to print off a customer order. I want to be able to easily add sub headings wherever I want. It's also best to state here that I am quite new to Java.





My current solution is to add the generated text to a JEditorPane and print that using the following:


I'm just curious, am I using a ridiculous long winded method to get my intended result?

Thanks
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's my attempt to print JEditorPane content paginated
http://java-sl.com/JEditorPanePrinter.html

if you need really WYSIWYG try also this
http://java-sl.com/Pagination_In_JEditorPane.html
Hope this helps.

Regards,
Stas
 
kyle johnson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, those are two really good examples.


In regards to those, is it possible to print a JEditorPane without it being added to a JFrame?

Later in my program I want to be able to print a JEditorPane without displaying it in a UI, however I found that it would only print once it had been added to a JFrame and the pack() method had been called.


Best regards,
Kyle
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should set size for the JEditorPane to let it layout. Also some changes of content layout are done only during paint (e.g. components of HTML location).

You can try to use invisible frame. Just create it and pack() but set location out of screen.

Regards,
Stas
 
kyle johnson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,

Yeah that's what iv ended up doing. Thanks for your help
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic