<p>Hi all,</p><p> </p><p>I recently sent a message on the Eclipse Birt forum that remained unanswered.</p><p>As I'm stucked, I try again on this forum...

</p><p> </p><p><span>I defined a report design to generate an open office document with a title and a dynamic image.<br />
I found several posts on how to render an image read from a file by providing the corresponding code in the image script 'onRender' event.</span></p><pre>importPackage(Packages.java.io);importPackage(Packages.java.lang); var file = new File("D:/mypath/test.png");var ist = new FileInputStream(file);var lengthi = file.length(); bytesa = new ByteArrayOutputStream( lengthi);var c;while((c=ist.read()) != -1){ bytesa.write(c);} ist.close();this.data = bytesa.toByteArray();</pre><p><span><span><span>It works fine but I now want to read my image from my RCP application and pass the corresponding byte array to 'onRender' as follow :</span></span></span></p><pre>this.data = reportContext.getAppContext().get("image");</pre><p><span>On the java side, I have :</span></p><pre>... // Create task to run and render the report: final IRunAndRenderTask task = engine.createRunAndRenderTask(design); // Image example... File file = new File("D:/mypath/test.png"); FileInputStream fis = null; try { fis = new FileInputStream(file); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ByteArrayOutputStream bais = new ByteArrayOutputStream((int) file.length()); int c = -1; try { while ((c=fis.read()) != -1) bais.write(c); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { fis.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Passing the image as byte array to the report task.getAppContext().put("image", bais.toByteArray());...</pre><p><span>Unfortunately, the resulting open office document doesn't contain my test image anymore <img src='
http://www.eclipse.org/forums/images/smiley_icons/icon_sad.gif' alt='Posted Image' class='bbc_img' />.</span></p><p> </p><p><span>Adding some traces on the script side, the byte array seems to be correctly loaded and passed (3655 bytes which is the size of my example image</span>).</p><p> </p><p><span>Could somebody tell me what's wrong ?<br />
<br />
Kind regards,<br />
<br />
Laurent</span></p><p> </p><p> </p>