Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在odt文档(writer)中添加带有jOpenDocument的图像_Java_Api_Documentation Generation_Odt_Jopendocument - Fatal编程技术网

Java 在odt文档(writer)中添加带有jOpenDocument的图像

Java 在odt文档(writer)中添加带有jOpenDocument的图像,java,api,documentation-generation,odt,jopendocument,Java,Api,Documentation Generation,Odt,Jopendocument,我正在尝试添加/插入图像。我可以用这个API来做吗?我对jOpenDocument感兴趣,因为它使我能够创建一个模板,然后使用Java处理文档(我认为使用Apache的ODFDOM是不可能的) 我唯一发现的是我可以做这样的事情: final File outFile = new File("output.odt");  final String bcfile = "image.png";  final JavaScriptFileTemplate template = new JavaScrip

我正在尝试添加/插入图像。我可以用这个API来做吗?我对jOpenDocument感兴趣,因为它使我能够创建一个模板,然后使用Java处理文档(我认为使用Apache的ODFDOM是不可能的)

我唯一发现的是我可以做这样的事情:

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);  
正如您所看到的,这只是一个
href
,因此我的odt文件不可移植,因为它取决于图像的路径


jOpenDocument API中是否有任何本机方法可以让我在odt文档中插入图像?

@Krumb我通过使用BIRT eclipse.org/BIRT/解决了这个问题。您可以使用它做几乎任何事情,您可以使用数据库或JSON中的数据源,还可以将其作为odt PDF等的输出。。。,它使用JAVA和rhinoscript。@Jens您能解决这个问题吗?我也吃同样的problem@Ranjan:我们目前使用XDocReport进行odt/docx处理。