First of all I'm very new to Java and programming generally, so apologies if my question or attempts at solving it are naive.
I'm trying to create a program which displays images, stored in an Open Document Text (.odt) document, in a Javax.Swing interface. To that end I am trying to extract an image from an odt using Odf Toolkit. I'm sure there must be a way to do this as Odf Toolkit can insert images so surely it should be able to extract them too?
Here is one of the ways I have tried to get the image out of the odt:
package odftoolkittrial;
import java.util.Iterator;
import org.odftoolkit.simple.TextDocument;
import org.odftoolkit.simple.draw.Image;
/**
*
* @author ------
*/
public class odftrial {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String filePath = "/Users/...../imagetest6";
Image allImages;
try {
TextDocument odt = TextDocument.loadDocument(filePath);
Iterator<Image> ii = odt.getImageIterator();
while (ii.hasNext()) {
Image image = ip.next();
allImages = image.getImageContent;
System.out.println(allImages);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
This was adapted from code I have used successfully to extract text from an odt. I can see two problems in that the methods I am trying to use do not exist in the classes to which their variables belong, but I've spent days trying to find suitable methods or other ways of extracting the images and have drawn a blank.
If anyone can offer any example code or even pointers I'd be very grateful. If I can get the images and save them to disc as jpegs or pngs, that would be fine, as I already have code which will take such an image, display it on a jlabel, and then delete it from the disc.
Regards and thanks in advance