BIRT failed to capture images parsed using XML datasource

system_migrated
edited February 11, 2022 in Analytics #1
<p>Hi all,</p><p> </p><p>I have a BIRT report designed to take in some fields in HTML, one of which is shown below: - </p><p> </p><p><p><strong>Apollo 11</strong> was the spaceflight that landed the first humans,<br />
Americans <a href="<a data-ipb='nomediaparse' href='http://en.wikipedia.org/wiki/Neil_Armstrong'>http://en.wikipedia.org/wiki/Neil_Armstrong">Neil</a&gt; Armstrong</<br />
a> and <a href="<a data-ipb='nomediaparse' href='http://en.wikipedia.org/wiki/Buzz_Aldrin'>http://en.wikipedia.org/wiki/Buzz_Aldrin">Buzz</a&gt; Aldrin</a>, on th<br />
e Moon on July 20, 1969, at 20:18 UTC. Armstrong became <img src="data:image/gif<br />
;base64,R0lGODdhgACAAIcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMAAGYAAJkA<br />
AMwAAP8AAAAzADMzAGYzAJkzAMwzAP8zAABmADNmAGZmAJlmAMxmAP9mAACZADOZAGaZAJmZAMyZAP+Z<br />
AADMADPMAGbMAJnMAMzMAP/MAAD/ADP/AGb/AJn/AMz/AP//AAAAMzMAM2YAM5kAM8wAM/8..........................FBAAOw==" alt="" />the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p></p><p> </p><p> </p><p>The data source is XML data source parsing in as stream and I use PDFRenderOption to render the report out as PDF file. Below is the code snippet I used for the generating of PDF: -</p><p> </p><p>task = birtEngine.createRunAndRenderTask(design);</p><p><strong class='bbc'>if</strong> (task!=<strong class='bbc'>null</strong>) {</p><p>Map<String, Object> appContext = task.getAppContext();</p><p>XMLInputSource source = <strong class='bbc'>new</strong> XMLInputSource(<strong class='bbc'>null</strong>, <strong class='bbc'>null</strong>, <strong class='bbc'>null</strong>, xmlDataStream, <strong class='bbc'>null</strong>); </p><p>source.setEncoding("UTF-8");</p><p> </p><p>appContext.put("org.eclipse.datatools.enablement.oda.xml.inputStream", source.getByteStream()); </p><p>appContext.put("org.eclipse.datatools.enablement.oda.xml.closeInputXmlStream", "true");</p><p>xmlDataStream.close();</p><p> </p><p>// We set up the options for rendering for PDF</p><p>PDFRenderOption options = <strong class='bbc'>new</strong> PDFRenderOption();</p><p>options.setOutputFormat("pdf");</p><p>options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF");</p><p>options.closeOutputStreamOnExit(<strong class='bbc'>true</strong>);</p><p> </p><p>ByteArrayOutputStream baos = <strong class='bbc'>new</strong> ByteArrayOutputStream();</p><p>options.setOutputStream(baos);</p><p> </p><p>// We bind the options to the task</p><p>task.setRenderOption(options);</p><p>task.run();</p><p><strong class='bbc'>if</strong> (<em class='bbc'>logger</em>.isDebugEnabled())</p><p><em class='bbc'>logger</em>.debug("Task ran and rendered.");</p><p> </p><p>content = baos.toByteArray();</p><p>baos.flush();</p><p>baos.close();</p><p>}</p><p> </p><p>All other HTML elements within the HTML tags were generated successfully in the PDF format but not the image embedded in the <img> tag. I have tried rendering them in HTML and output them into a browser, the effect is fine and the image could be extracted correctly.</p><p> </p><p>Am I missing something along the way? Any help will be appreciated. Thank you!</p><p> </p><p>Regards,</p><p>KK</p><p> </p>

Comments