I have an application that matters jrxml files to a database. In doing so, I would change the path of the report images to a default directory informed in the application. What I have so far is that
JasperReport jr = ...;[/code]
for (JRBand band : jr.getAllBands()) {[/code]
for (JRElement el : band.getElements()) {[/code]
if (el instanceof JRImage) {[/code]
File oldPath = new File(((JRImage) el).getExpression().getText());[/code]
String newPath = new Preference("imgDir").getValue() + "/" + oldPath.getName();[/code]
try {[/code]
byte[] img = Tools.fileToByteArray(oldPath);[/code]
[/code]
try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(newPath))) {[/code]
dos.write(img);[/code]
dos.flush();[/code]
}[/code]
} catch (Exception ex) {[/code]
Logger.getLogger(RelatorioC.class.getName()).log(Level.SEVERE, null, ex);[/code]
}[/code]
[/code]
((JRImage) el).setOnErrorType(OnErrorTypeEnum.BLANK);[/code]
}[/code]
}[/code]
}[/code]
Sorry for any error or discrepancy in the text, translated by google translate. Also unable to format the source code appropriately.
I appreciate any help.