Japanese Character issue with JRHtmlExporter

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

I am using Jasper Report API 4.5. I am trying to export reports in HTML and PDF format. The application I am using Jasper Report in is having i18n support with Japanese language.

To export report in PDF format JRPdfExporter class is used. With this exporter generated PDF file works fine. Displays Japanese character properly. But when the same report with same data exported in HTML format the Japanese characters looks like '????'. I am displaying HTML report in web application and exporter class used to export in HTML format is JRHtmlExporter.

With HTML exporter I have set paramter JRHtmlExporterParameter.HTML_HEADER as below text:

 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />  

I have set HTML exporter's parameter JRExporterParameter.FONT_MAP as:

   Map<string, string=""> FONT_MAP = new HashMap<string, string="">();
   FONT_MAP.put("sansserif", "Arial, Verdana, Tahoma");
   FONT_MAP.put("serif", "Times New Roman");
   FONT_MAP.put("monospaced", "Courier, Courier New");</string,></string,>

Any guess where it is going wrong? Have I missed something in export functionality?

parthbhagat's picture
Joined: Aug 22 2010 - 11:26pm
Last seen: 1 year 9 months ago

1 Answer:

It's just an encoding problem - you probably set the encoding wrong somewhere. It's working fine for me.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 3 weeks ago

Yes, agree it is encoding issue. But where else I need to specify encoding? The same report works with same data fine when exported in PDF format.

parthbhagat - 7 years 10 months ago

JRXML file has character encoding as:
<?xml version="1.0" encoding="UTF-8"?>

Specified content type of HTML header as UTF-8/

Where else I need to set character encoding? For Japanese character do we require to have Font name specified in FONT_MAP parameter mentioned in the question?

parthbhagat - 7 years 10 months ago