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

Does JPG Java Class Exist

 
Steve Dyke
Ranch Hand
Posts: 1602
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a java class to convert from rtf to jpg?
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See AccessingFileFormats for information on accessing file formats from Java.

I believe that Java's own ImageIO class knows about creating JPEGs, so that should not be too difficult.

I don't think there's built-in RTF support in Java, but the above FAQ has some stuff about RTF.

By the way, RTF and JPG have rather dissimilar applications. JPG is for a single picture, whereas RTF can be for a big multi-page document. What do you expect to happen?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could render the RTF to a Swing component (see the javax.swing.JEditorPane and javax.swing.text.rtf.RTFEditorKit classes for details), and then render that component into a BufferedImage. Which -as Peter pointed out- is easy to store as JPEG using javax.imageio.ImageIO.
 
Steve Dyke
Ranch Hand
Posts: 1602
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My end goal is to generate a JasperReport that contains field text ouput in combination with the contents of a rtf. I have tried several things and posted many request for help but to no avail. I thought that maybe I could convert the rtf into a jpg and have an image control on the JasperReport to handle the display. This needs to be done in browser envionment.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you can get it to render in a JEditorPane, then the approach I outlined above is a real possibility.
 
Steve Dyke
Ranch Hand
Posts: 1602
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I use JEditorPane in a JSP - Servlet type of application?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many Swing components can be constructed and used without being realized (i.e., visualized). You may need to set the java.awt.headless property in that case to prevent strange things from happening on the server.

I would first write a little application that visualizes it, though - just to make sure its output is what you'd expect it to be...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic