Reputation: 45
I use JasperReports for export PDF. I have a problem with special characters (è,à,û) whereas I don't have any problem with (é, € ). When I generate my file with Jaspersoft Studio, I don't have any problems (all special charactere are Ok). The problem occurs only when I export the PDF from my application (and just those characters don't work perfectly (è,à,û) and not (é, € )
Here is my code:
try {
jasperPrint = JasperFillManager.fillReport(jasperReport, parametres, connection);
} catch (JRException e) {
throw e;
} finally {
connection.close();
}
return jasperPrint;
}
public byte[] exporterMoisPDF(String siret, long annee, long mois, String num_declarant, String date_declaration, String mois_lettre, String nomFichierJasper)throws Exception {
byte[] rapportPDF=null;
JasperPrint jasperPrint = genererExportMoisJasper(siret, annee, mois, num_declarant, date_declaration, mois_lettre, nomFichierJasper);
jasperPrint.setLocaleCode("UTF-8");
rapportPDF = JasperExportManager.exportReportToPdf(jasperPrint);
return rapportPDF;
Upvotes: 0
Views: 2559
Reputation: 200
Try insert the <style name="style1" isDefault="true" pdfEncoding="Cp1252"/>
row to .jrxml file. (You can add it in a report designer too as "Style").
I also had problem with central european characters and it is solved by pdfEncoding="Cp1250" default style setting.
I tried the <property name="net.sf.jasperreports.default.pdf.encoding" value="Cp1250"/>
row too, but this had no effect in JasperReports 6.5.0 library on my environment.
Upvotes: 1
Reputation: 460
May be you don't have these characters in your fontname.ttf. Add proper font to jasperreports-fonts-x.x.x.jar and recompile it.
Upvotes: 1