3

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?

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
azelix
  • 1,257
  • 4
  • 26
  • 50
  • @Krumb I solved this by using BIRT eclipse.org/birt/ you can do pretty much anything with it , you can use data sources from database or JSON, and you can have as an output ODT PDF etc..., it uses JAVA and rhinoscript . – azelix Jan 04 '16 at 11:44
  • @Jens were you able to resolve the issue? I am having the same problem – Ranjan Mar 02 '17 at 20:23
  • @Ranjan: we currently use XDocReport for odt / docx processing. – Jens Piegsa Mar 02 '17 at 21:09

0 Answers0