Creating dynamic images from BLOBs in database
Options
<p>Hello everyone! I'm brand new to BIRT and was hoping someone could help me with a problem I'm having.</p>
<p> </p>
<p>I'm trying to display a dynamic image in my report, but I'm hitting some issues. I'm querying the image data from our database, converting the Byte array to Base 64, and writing that Base 64 into an XML file. So, our XML data source is using Base 64 as the image data. Below is an excerpt of what it looks like in the XML file.</p>
<p> </p>
<p><strong><cImage>/9j/4AAQSkZJRgABAAEAYABgAAD/2wCEAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQ...</cImage></strong></p>
<p> </p>
<p>I tell BIRT that "cImage" is the column that I want to use and that it is a BLOB. However, whenever I run my report, I get the following error:</p>
<p> </p>
<p><strong>"</strong><b><span>org.eclipse.birt.report.engine.api.EngineException: A BIRT exception occurred. See next exception for more information. Can not convert the value of /9j/4AAQSkZJRgABAAEAYABgAAD/2wCEAAMCAgIC... to Binary type."</span></b></p>
<p> </p>
<p>Should I be using something other than Base 64?</p>
<p> </p>
<p>I feel as if I'm missing a very simple step and could really use some guidance since I'm a newbie. Any help would be greatly appreciated. Thank you!! </p>
<p> </p>
<p>I'm trying to display a dynamic image in my report, but I'm hitting some issues. I'm querying the image data from our database, converting the Byte array to Base 64, and writing that Base 64 into an XML file. So, our XML data source is using Base 64 as the image data. Below is an excerpt of what it looks like in the XML file.</p>
<p> </p>
<p><strong><cImage>/9j/4AAQSkZJRgABAAEAYABgAAD/2wCEAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQ...</cImage></strong></p>
<p> </p>
<p>I tell BIRT that "cImage" is the column that I want to use and that it is a BLOB. However, whenever I run my report, I get the following error:</p>
<p> </p>
<p><strong>"</strong><b><span>org.eclipse.birt.report.engine.api.EngineException: A BIRT exception occurred. See next exception for more information. Can not convert the value of /9j/4AAQSkZJRgABAAEAYABgAAD/2wCEAAMCAgIC... to Binary type."</span></b></p>
<p> </p>
<p>Should I be using something other than Base 64?</p>
<p> </p>
<p>I feel as if I'm missing a very simple step and could really use some guidance since I'm a newbie. Any help would be greatly appreciated. Thank you!! </p>
0
Comments
-
<p><em>I'm trying to display a dynamic image in my report, but I'm hitting some issues. I'm querying the image data from our database, converting the Byte array to Base 64, and writing that Base 64 into an XML file</em></p>
<p> </p>
<p>Why do you need to do all these conversions? It would much easiier if you read the Byte array from the database in the report design, and display the image using the Image Report Item.</p>
<p> </p>
<p>If you still need to do these conversions, Base64 is correct. But the Image Report Item is expecting a BLOB data type.</p>
<p> </p>
<p>You have two options...</p>
<p> </p>
<p>1. Use a Text Report Item and display the image with your Base64 string.</p>
<pre class="_prettyXprint">
<img src='data:image/png;base64,<VALUE-OF>row["cImage"]</VALUE-OF>'></pre>
<p>2. Use a Image Report Item with the image selected as "Dynamic Image". It's expecting a BLOB here. You will need to convert the Base64 String into a BLOB in the binding.</p>Warning No formatter is installed for the format ipb0 -
Hi,
Use the following code on image render.
Example:-
importPackage(Packages.java.io);
importPackage(Packages.java.lang);
importPackage(Packages.java.net);
importPackage(Packages.javax.imageio);
var myfile = new Packages.java.io.File(row["GDS_DOC_CONTENT"]);
var img = ImageIO.read(myfile);
bas = new ByteArrayOutputStream();
ImageIO.write(img, "jpeg", bas);
this.data = bas.toByteArray();0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 122 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management