Bug 422118 - Inline HTML Images parsed as XML data source failed to display in PDF rendered output.
Summary: Inline HTML Images parsed as XML data source failed to display in PDF rendere...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 3.7.2   Edit
Hardware: Sun Unix All
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Birt-ReportEngine-inbox@eclipse.org CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2013-11-20 04:36 EST by Kian Keong Tan CLA
Modified: 2013-11-22 03:53 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kian Keong Tan CLA 2013-11-20 04:36:32 EST
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.
Comment 1 vlad dev CLA 2013-11-22 03:53:51 EST
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.