aspose file tools*
The moose likes Beginning Java and the fly likes Does JPG Java Class Exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does JPG Java Class Exist" Watch "Does JPG Java Class Exist" New topic
Author

Does JPG Java Class Exist

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Is there a java class to convert from rtf to jpg?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
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.


Ping & DNS - my free Android networking tools app
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
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
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
How can I use JEditorPane in a JSP - Servlet type of application?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
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...
 
wood burning stoves
 
subject: Does JPG Java Class Exist