Print image (relative path) Jasper Report

Asked

Viewed 665 times

0

Good morning to you all! I’m trying to print a logo in the Jasper Reports report if I put the address "http://meuservidor.com.br/imagens/logo.png" works,

but I wanted to put the image path that is within my application (ex: ".. /images/logo.png")

goes down structure

inserir a descrição da imagem aqui

  • I will reverse the edition, it is not a forum in which we indicate that it was solved in the title, but in marking a response as accepted

2 answers

0

Good morning, everyone! I managed to solve by doing the following:

created a parameter in the report named LOGO_DIR which matches my system’s image folder

and filled in the report call

Classerelatorio.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);  

inside the report, in Jasper, I created a String field that receives the parameter LOGO_DIR + "nameImage.png"

0

Hello friend I do as follows for Desktop Applications in Jar

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

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.