paulo_alonso Posted January 8, 2015 Share Posted January 8, 2015 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now