By: Alejandro Alliana - aalliana
PDF report and images.
2003-04-14 17:22
I'm trying to modify the webapp sample report this way.
I have already made an HTML report to the way I wan't it to. But I have a multiple page report so I have to modify it to work as an PDF report. The webapp example has a PDF example to , so I modified my code to something like:
File reportFile = new File(application.getRealPath("/reports/ConsolidadoTotal.jasper"));
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put("ReportTitle", "Registro Anecdó´©£o");
parameters.put("BaseDir", reportFile.getParentFile());
byte[] bytes =
JasperRunManager.runReportToPdf(
reportFile.getPath(),
parameters,
new ConsolidadoTotal()
);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
but then I get the following error:
java.io.IOException: java.awt.Image fetch aborted or errored
at com.lowagie.text.Image.getInstance(Unknown Source)
at com.lowagie.text.Image.getInstance(Unknown Source)
I saved the logo images in the same directory as the html report does, ie: ../images
I run linux (rh 80) jdk 1.4.1_02, tomcat, any ideas?
aa
PDF report and images.
2003-04-14 17:22
I'm trying to modify the webapp sample report this way.
I have already made an HTML report to the way I wan't it to. But I have a multiple page report so I have to modify it to work as an PDF report. The webapp example has a PDF example to , so I modified my code to something like:
File reportFile = new File(application.getRealPath("/reports/ConsolidadoTotal.jasper"));
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
Map parameters = new HashMap();
parameters.put("ReportTitle", "Registro Anecdó´©£o");
parameters.put("BaseDir", reportFile.getParentFile());
byte[] bytes =
JasperRunManager.runReportToPdf(
reportFile.getPath(),
parameters,
new ConsolidadoTotal()
);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
but then I get the following error:
java.io.IOException: java.awt.Image fetch aborted or errored
at com.lowagie.text.Image.getInstance(Unknown Source)
at com.lowagie.text.Image.getInstance(Unknown Source)
I saved the logo images in the same directory as the html report does, ie: ../images
I run linux (rh 80) jdk 1.4.1_02, tomcat, any ideas?
aa
0 Answers:
No answers yet