1

I'm using jasper report 6.0 with jsp/servlets to get some reports from the database, you know, everything goes well, the servlet catches the request and realizes the file extension to export, then gives the response.getOutputStream() to the JasperExportManager as an outputStream in order to send the file to the client, But the problem is on exporting pdf file, the language of the reports are in persian, even I've set all the character encodings to UTF-8 but there is still not any persian characters in the exported pdf file, all the other formats of files are okay except pdf, here is my code:

Class.forName("com.mysql.jdbc.Driver");
Connection  cn = DriverManager.getConnection("jdbc:mysql://localhost:3306 /Informations?useUnicode=true&characterEncoding=UTF-8&user=root&password=");
JasperDesign jasperDesign = JRXmlLoader.load("C:\\TempReports\\discountgivenstudents.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
Map <String, Object> parameters = new HashMap<String, Object>();
parameters.put("discount",10);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters, cn);
response.setContentType("application/ms-excel");
response.setHeader("Expires:", "0");
response.setHeader("Content-Disposition", "attachment; filename=discountgiven.pdf");
JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
response.getOutputStream().flush();

I will be happy if you help me solve this problem ,thanks so much for paying time dears.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mohsen
  • 63
  • 8

0 Answers0