1

jasper report- pdf not showing supplementary Chinese characters.brelow is the jasper xml snippet along with my code.

already tried : https://www.jianshu.com/p/a8b84e2ccdf0?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
but getting exception :

java.lang.ArrayIndexOutOfBoundsException: 131540 at com.lowagie.text.pdf.CJKFont.getWidth(Unknown Source)

jrXML snippet:  <font pdfFontName="ARIALUNI.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>


                        <paragraph leftIndent="15" />

                    </textElement>
                    <textFieldExpression><![CDATA[$F{searchText}]]></textFieldExpression>
                </textField>

Code :

                class Tet1 {

                    public static void main(String[] args) throws UnsupportedEncodingException {
                        JasperReport jasperReport = null;
                        JasperPrint jasperPrint;
                        HashMap jasperParameter = new HashMap();
                        JasperVO jasperVO = new JasperVO();
                        List searchVOList = new ArrayList();
                        InputStream isb = null;
                        try {
                            String str = ""学部首和汉";
                            String path = "C:\\MYData\\jasperNew\\test\\test.jrxml";
                            jasperReport = JasperCompileManager.compileReport(path);

                            System.out.println(str);



                            searchVOList.add(jasperVO.generateExcelData(str));
                            JRDataSource searchDS = new JRBeanCollectionDataSource(searchVOList);
                            jasperParameter.put("searchDS", searchDS);






                            /*System.out.println("text = " + new String(Character.toChars("??")));  */


                            jasperPrint = JasperFillManager.fillReport(jasperReport,
                                    jasperParameter, new JRBeanCollectionDataSource(
                                            searchVOList));

                            //JasperExportManager.exportReportToXmlFile(jasperPrint, "C:\\MYData\\jasperNew\\4u\\MyPDF22.xml", true);

                            JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\MYData\\jasperNew\\4u\\MyPDF.pdf");

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                    }

                }
  • Try passing special characters as unicode characters. – Tatiana B Jan 29 '19 at 08:13
  • You need to check that font supports them and then include the font-extensions, see as example this for more info [Jasper Reports PDF doesn't export cyrillic values](https://stackoverflow.com/q/34041619/5292302) – Petter Friberg Jan 29 '19 at 08:48

0 Answers0