1

I have a text field in my table that has a value of base64image like this:

iVBORw0KGgoAAAANSUhEUgAAAKAAAABQCAYAAACeXX40AAAAAXNSR0IArs4c6QAAABxpRE9UAAAAAgAAAAAAAAAoAAAAKAAAACgAAAAoAAABm0Xg9YIAAAFnSURBVHgB7NQ/S4VQGMfxe9N7FTEh8M+kIoI2NDdLNATqIthYBwIHx6C5qaGhXkWTryR6Ib0Ne25g3MXbJnf4HvghBx

How can I display an image reading this field in iReport 4.0.1? I used the guideline in this but didn't work. it throws following error:

SimpleJasperReportsContext cannot be resolved to a type

even if I import the required classes to xml file as:

<import value="org.apache.commons.codec.binary.Base64"/>

and add this to my ImageExpression value:

 new ByteArrayInputStream(Base64.decodeBase64($F{out_sign_in}.getBytes()))

I get the following error:

Base64 cannot be resolved

This link solved my problem

Ms workaholic
  • 373
  • 2
  • 8
  • 21
  • non of the solutions in that link works for me. I have text field that contains byte[] and wanna display as image in a java.lang.string field – Ms workaholic Nov 01 '17 at 18:25
  • Take a look at the `asPNG` method. You can apply the same technique. Instead of using an SVG stream, you have a Base64 sequence that must be decoded into a `ByteArrayInputStream`. It's the same problem, just dressed up a bit differently. – Dave Jarvis Nov 01 '17 at 19:34
  • I just noticed that when I compile my jrxml file, it removes the import line that I have added to the raw JRXML – Ms workaholic Nov 01 '17 at 20:14
  • Do you have any idea why this happens – Ms workaholic Nov 01 '17 at 20:50
  • What do you mean the "cannot be resolved" error?, there is something wrong in your import, specify full classpath in call, if you still get error check your classpath – Petter Friberg Nov 01 '17 at 20:51

0 Answers0