Jump to content
We've recently updated our Privacy Statement, available here ×

mathias.gorf

Members
  • Posts

    3
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by mathias.gorf

  1. I want to post my solution, because this answered question is dated, but it is the first hit on google if you search for "jaspersoft base64 image". With Jaspersoft 5.6.1 this works: Assuming that you have a String field within your JSON file (Datasource) named "image" add the field: <field name="image" class="java.lang.String"> <fieldDescription><![CDATA[image]]></fieldDescription> </field>[/code]Just embed your image wherever you want: <imageExpression><![CDATA[net.sf.jasperreports.engine.util.JRImageLoader.getInstance(new SimpleJasperReportsContext()).loadAwtImageFromBytes(javax.xml.bind.DatatypeConverter.parseBase64Binary($F{image}))]]></imageExpression>[/code]Note that the image string within the JSON file has to be plain BASE64 code, omit any Data-URL header data "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAho..." is wrong. "iVBORw0KGgoAAAANSUhEUgAAAho..." is the base64 code and works.
  2. The solution: sections(id == sectionId)[0].fields(id == field-Id-One) The explanation: the filtering expression sections(id == sectionId) does not necessarily return ONE object, in fact it returns an array of objects, which contains only one element in this case. Using this one object in an array has the same effect in jasper then if it would be a single object. For example, the array could contain all objects/sections which do not have this id: sections(id != sectionId) If one tries to access the array with the "." operator, it will fail anyhow. So if you know that the array only contains that ONE object, you can get it directly with "array[0]"
×
×
  • Create New...