Community
Participate
Working Groups
BIRT failed to decode and display the following HTML formatted string parsed in as a set of data stream rendered as PDF: - <p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia....Armstrong">Neil Armstrong</ a> and <a href="http://en.wikipedia....zz_Aldrin">Buzz Aldrin</a>, on th e Moon on July 20, 1969, at 20:18 UTC. Armstrong became <img src="data:image/gif ;base64,R0lGODdhgACAAIcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADMAAGYAAJkA AMwAAP8AAAAzADMzAGYzAJkzAMwzAP8zAABmADNmAGZmAJlmAMxmAP9mAACZADOZAGaZAJmZAMyZAP+Z 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> Details as follows: - 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: - task = birtEngine.createRunAndRenderTask(design); if (task!=null) { Map<String, Object> appContext = task.getAppContext(); XMLInputSource source = new XMLInputSource(null, null, null, xmlDataStream, null); source.setEncoding("UTF-8"); appContext.put("org.eclipse.datatools.enablement.oda.xml.inputStream", source.getByteStream()); appContext.put("org.eclipse.datatools.enablement.oda.xml.closeInputXmlStream", "true"); xmlDataStream.close(); PDFRenderOption options = new PDFRenderOption(); options.setOutputFormat("pdf"); options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF"); options.closeOutputStreamOnExit(true); ByteArrayOutputStream baos = new ByteArrayOutputStream(); options.setOutputStream(baos); task.setRenderOption(options); task.run(); if (logger.isDebugEnabled()) logger.debug("Task ran and rendered."); content = baos.toByteArray(); baos.flush(); baos.close(); } 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 had tried rendering them in HTML and outputted them into a browser, the effect was fine and the image could be extracted correctly but when I rendered it in PDF, the image did not display.
As far as I know, BIRT (4.3.1) doesn't export images embedded in HTML when exporting to PDF, and probably other formats besides HTML. To add that feature you would have to extend org.eclipse.birt.report.engine.util.ResourceLocatorWrapper class and sub-class engine tasks to make them returning your version of ResourceLocatorWrapper. Unfortunately I don't see any easier way to make BIRT understanding embedded image contents. Otherwise you have to alter your HTML to make it referencing images on a file system.