0
I’m trying to insert an image into Ireport 3.7.5.
When I drag the Image field to the page and place the static url with the image address, it works, but when I put it on Image Expression
that way :
System.getProperty("user.dir") + "\\fotos" + "\\"+$F{FOTO}
The above code generate the same address I used in the static url that works
But it makes a mistake:
Error filling print... Byte data not found at Location : C: Program Files (x86) Jaspersoft iReport-3.7.5 photos clob46: 'ICONE3.png' net.sf.jasperreports.engine.Jrexception: Byte data not found at Location : C: Program Files (x86) Jaspersoft iReport-3.7.5 photos clob46: 'ICONE3.png'
[EDIT 1]
My method was like this:
public void relatorio ( String codigo ){
String arquivo = null;
try{
conn = ConnectionFactory.getConnection();
arquivo = System.getProperty("user.dir") + "/src/relatorio/rel_cadastro.jrxml";
//System.out.println("Caminho do arquivo jrml: "+arquivo);
JasperDesign design = JRXmlLoader.load(arquivo);
// InputStream path1 = classLoader.getResourceAsStream("/images/logo.jpg");
String foto = System.getProperty("user.dir") + "\\fotos\\ICONE3.png";
InputStream path = ClassLoader.getSystemResourceAsStream( foto );
JasperReport jr = JasperCompileManager.compileReport( design );
HashMap valores = new HashMap();
valores.put("CODIGO", codigo );
valores.put("imagem", path);
JasperPrint impressao = JasperFillManager.fillReport(jr,valores,conn);
JasperViewer jrViewer = new JasperViewer(impressao, false);
jrViewer.setVisible(true);
jrViewer.setDefaultCloseOperation(JasperViewer.DISPOSE_ON_CLOSE);
}
catch(JRException e){
System.out.println("Erro no relatorio: \n"+e.getMessage());
}
}
If you can edit the answer so I can mark as solved
– adventistaam
Edit as ? Yes I can!
– LR10
Instead of putting Inputstream, just put the
System.getProperty("user.dir") + "\\fotos\\ICONE3.png" )
as you did– adventistaam
I have already explained why in your case it worked!!
– LR10