Print picture (relative path) Jasper Report

0

Good morning everyone! I'm trying to print a logo in the Jasper Reports report if I put the address " link " works,

But I wanted to put the path of the image that is inside my application (eg "../images/logo.png")

follow below structure

    
asked by anonymous 08.11.2017 / 13:49

2 answers

0

Hello friend, I do the following for Desktop Applications in Jar

getClass().getClassLoader().getResourceAsStream("br/com/blogspot/denisbenjamim/iReport/Imagens/logotp.png")

    
09.11.2017 / 15:25
0

Good morning everyone! I was able to resolve it by doing the following:

I created a parameter in the report called LOGO_DIR which corresponds to the folder of images of my system

and filled in the report call

ClassReport.java ...

FacesContext fc = FacesContext.getCurrentInstance();
ServletContext context = (ServletContext)fc.getExternalContext().getContext();
String path = context.getRealPath(File.separator) + "resources/jasper" + File.separator;
String logo = context.getRealPath(File.separator) + "resources/images" + File.separator;
params.put("SUBREPORT_DIR", path);
params.put("LOGO_DIR", logo);  

Within the report, in jasper, I created a String field that receives the LOGO_DIR + "image_name.png"

    
22.11.2017 / 14:29