jasper pdf中未显示补充汉字

时间:2019-01-29 08:05:16

标签: java jasper-reports

jasper报告-pdf不显示补充汉字。brelow是jasper xml代码段以及我的代码。

已经尝试过:https://www.jianshu.com/p/a8b84e2ccdf0?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
     但出现异常:

java.lang.ArrayIndexOutOfBoundsException:131540     com.lowagie.text.pdf.CJKFont.getWidth(未知来源)

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


                        <paragraph leftIndent="15" />

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

代码:

                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();
                        }

                    }

                }

0 个答案:

没有答案