I want to create a PDF report file using JasperReport containing data
with persian character fetched from database.
Any experience in this regard?
The HTML version works good with persian characters but PDF one does
not show persian characters.
This is my sample code for PDF:
File reportFile;
Map parameters = new HashMap();
String fileName = "D:/RD/web/report/test.jasper";
String outFileName;
try {
Locale locale = new Locale("fa", "", "");
parameters.put(JRParameter.REPORT_LOCALE, locale);
reportFile = new File(fileName);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject
(reportFile.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport
(jasperReport, parameters, MyConnection.con);
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT,
jasperPrint);
outFileName = "D:/RD/web/report/test.pdf";
exporter.setParameter(JRPdfExporterParameter.OUTPUT_FILE_NAME,
outFileName);
exporter.setParameter
(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporter.exportReport();