We were using JasperReports 4.6.0 and Java 1.6 to generate the PDF reports. It was working fine for parameters with text on English. If I pass the Arabic input parameter the input parameter passed as like a junk character hence I couldn't fetch the recordset. The same was working when I use JasperReports 3.7.6 and Java 1.5
My code:
JasperPrint print = null;
Runtime run = null;
String strJasperFile = "E:/DailyWork/FEB-2013/report2.jasper";
String strOutputFile = "E:/DailyWork/FEB-2013/report2.xls";
String printtime="";
Connection con = getSqlConnection();
HashMap mpDetailSp = new HashMap();
mpDetailSp.put("parameter1", "B المهمات");
print = JasperFillManager.fillReport(strJasperFile, mpDetailSp, con);
JRExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, strOutputFile);
exporter.exportReport();
Could you please advise me how to sort it out this problem?
Finally, I found out the solution for this problem. It was encoding setting in the Java 1.6 JVM. I had set the environment variable as like below to sort it out the problem
JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF8
It was resolved my problem. The input was given by the another forum post in statck overflow
https://stackoverflow.com/a/623036/770927
I thank to Edward Grech, He explained obvious reason and solution in the above post.
Not being the an expert in Jasper I can suppose that the problem is in the text encoding. I performed a short search and found this resource: http://www.adp-gmbh.ch/misc/tools/jasper/java.html
Please take a look in the template example and pay attention on line
<?xml version="1.0" encoding="UTF-8"?>
on top of the file. Does your filereport2.jasper
contain such line? Check it and include it if it is missing.Additionally add line
exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
I hope now all will work.