JasperStudio 6 Base64 image

1

Hi.  I am quite new to jasper studio.  I searched the forum, studio help docs and googled - and was unable to find a trail I could follow. I have some base64 images that I want to show on a report.  The html equivalent is <img src=""data:image/png;base64,iVBORw0KGgo.."">.  I tried through the tool adding the image element and inputting the string in different ways but no luck.  Don't mind editing the jrxml directly either if need be.  Would appreciate any direction.

 

jim_jones2000's picture
Joined: May 6 2012 - 2:49pm
Last seen: 4 years 9 months ago

Hi user, Could you resolve it? Could you show an example for running in my pc ? Thanks for all,

dcdacd - 2 years 9 months ago

 6I had a report on an earlier version of Jasper, this report include image base64 jpg and it worked fine. I update the JasperServer and JasperSoft Studio versions and this report i can´t export to pdf. Note: With png (base64->"IVBOR")  images works fine but jpg (base64->"/9J/4") images gives the following exception:

 
2017-03-21 12:34:36,625 ERROR EngineServiceImpl,pool-5-thread-2:598 - Error while exporting report to PDF
net.sf.jasperreports.engine.JRException: java.io.IOException: Premature EOF while reading JPG.
        at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.processImageRetainShape(JRPdfExporter.java:1750)
        at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.process(JRPdfExporter.java:1607)
        at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.access$300(JRPdfExporter.java:1535)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportImage(JRPdfExporter.java:1475)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:1093)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:1056)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:920)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:537)
        at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.exportToPdf(EngineServiceImpl.java:593)
        at com.jaspersoft.jasperserver.remote.exporters.PdfExporter.exportReport(PdfExporter.java:98)
        at com.jaspersoft.jasperserver.remote.services.impl.ReportExecutorImpl.exportReport(ReportExecutorImpl.java:178)
        at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl.generateReportOutput(RunReportServiceImpl.java:572)
        at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl.executeExport(RunReportServiceImpl.java:479)
        at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl$2.run(RunReportServiceImpl.java:379)
        at com.jaspersoft.jasperserver.api.logging.util.LoggableExecutorService$1.run(LoggableExecutorService.java:53)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Premature EOF while reading JPG.
        at com.lowagie.text.Jpeg.processParameters(Unknown Source)
        at com.lowagie.text.Jpeg.<init>(Unknown Source)
        at com.lowagie.text.Image.getInstance(Unknown Source)
        at net.sf.jasperreports.engine.export.JRPdfExporter$InternalImageProcessor.processImageRetainShape(JRPdfExporter.java:1745)
        ... 17 more
edtegomez - 2 years 8 months ago

1 Answer:

1

You will need to import the the commons library:

 

<import value="org.apache.commons.codec.binary.*"/>
 
<image>
 
 <reportElement " x="52" y="33" width="204" height="71"/>
 
<imageExpression><![CDATA[new ByteArrayInputStream(Base64.decodeBase64($F{Signature}.getBytes()))
 
]]></imageExpression>
 
 </image>
ernestoo's picture
8924
Joined: Nov 29 2010 - 11:59am
Last seen: 2 years 1 month ago
Feedback
randomness