Reputation: 1277
I'm trying jOpenDocument API and I want to add/insert an Image. Can I do that with this API? I'm interested in jOpenDocument because it enables me to create a template and then process the document afterwards with Java (which I don't think it's possible with ODFDOM from Apache).
The only thing I found is that I can do something like this:
final File outFile = new File("output.odt");
final String bcfile = "image.png";
final JavaScriptFileTemplate template = new JavaScriptFileTemplate("template.odt");
final ODSingleXMLDocument ddoc = template.createDocument();
ddoc.getDescendantByName("draw:frame","pC_LSBarcode").setAttribute("href", "file:///" + bcfile,Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink"));
ddoc.saveAs(outFile);
As you can see this is only an href
and as result my odt file won't be portable as it depends on the path of the image.
Are there any native methods in jOpenDocument API so I can insert images in my odt document?
Upvotes: 3
Views: 1066