Jump to content

Display Report In JSP Error font vietnam


longdv1208

Recommended Posts

public static byte [] compileToBinary() throws JRException, IOException{
        byte [] binary=null;
        String pathFile="D:\NetBeans\jasperreport\web\template\template.jrxml";
        String destFile="D:\NetBeans\jasperreport\web\template\webtest.html";
        JasperReport report=JasperCompileManager.compileReport(pathFile);
        HashMap<Object,Object> hashMap=new ConstMap<Object, Object>();
        hashMap.put("DEFAULT_PDF_FONT_NAME", "D:\NetBeans\jasperreport\web\times.ttf");
        JasperPrint print=JasperFillManager.fillReport(report, hashMap, new JREmptyDataSource());
        byte [] byteFile =JasperExportManager.exportReportToPdf(print);
        JasperExportManager.exportReportToHtmlFile(print, destFile);
        ByteArrayInputStream byinputStream=new ByteArrayInputStream(byteFile);
        InputStream inputStream=new BufferedInputStream(byinputStream);
        ByteArrayOutputStream outputStream =new ByteArrayOutputStream();
        int b=-1;
        while((b=byinputStream.read())!=-1){
            outputStream.write(b);
        }
        binary=outputStream.toByteArray();
        inputStream.close();
        return binary;
    }

<body>
      <%
        byte [] data=CompileFile.compileToBinary();
        response.setContentType("application/pdf");
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Content-Disposition", "inline");
        response.setContentLength(data.length);
        OutputStream outputStream=response.getOutputStream();
        outputStream.write(data);
        outputStream.flush();
        outputStream.close();
        //LookAndFeelFactory.installDefaultLookAndFeel();
        //JasperViewer.viewReport(CompileFile.getJasperPrint());
      %>
    </body>

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : pdfFontName   : times.ttfpdfEncoding   : Identity-HisPdfEmbedded : false

root cause

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : pdfFontName   : times.ttfpdfEncoding   : Identity-HisPdfEmbedded : false

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1 logs.



Post Edited by longdv1208 at 07/14/2011 07:39
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...