jasper文件我已经编译好了.
在JAVA类里面使用以下代码进行调用.小票打印机没响应.是怎么回事呀?
Map<String, String> params = new HashMap<String, String>();
params.put("ftitle", ApplicationContext.getHosName() + "购物凭证小票"); List<XiaopiaoPrint> xps = new ArrayList<XiaopiaoPrint>();
for (TGoodsDJ djtemp : djs) {
XiaopiaoPrint print = new XiaopiaoPrint();
print.setFlsdj(djtemp.getFlsdj());
print.setFsl(djtemp.getFsl());
print.setFlsje(djtemp.getFlsdj() * djtemp.getFsl());
print.setFtm(djtemp.getFtm());
print.setFname(djtemp.getFname());
xps.add(print);
}
JRBeanCollectionDataSource printSource = new JRBeanCollectionDataSource(
xps); String rcp_path = Platform.getInstallLocation().getURL().getPath();
String fileName = rcp_path + "/report/xiaopiao.jasper";
File file = new File(fileName);
if (!file.exists()) {
return;
}
try { JasperReport jspJasperReport = null;
try {
jspJasperReport = (JasperReport) JRLoader
.loadObject(new FileInputStream(file));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// JasperReport jspJasperReport = (JasperReport) JRLoader
// .loadObject(new File(fileName));
JasperPrint prt = JasperFillManager.fillReport(jspJasperReport,
params, printSource);
} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

解决方案 »

  1.   

    你还没用流输出啊!在
    JasperPrint prt = JasperFillManager.fillReport(jspJasperReport,
    params, printSource);
    后加下面这个试试看!JasperExportManager.exportReportToPdf(prt);
    response.setContentType("application/pdf;charset=UTF-8");
    response.setHeader("Content-Disposition","attachment;   filename=IReportInword.pdf");
    response.setContentLength(bytes.length);
    ServletOutputStream ouputStream = response.getOutputStream();
    ouputStream.write(bytes, 0, bytes.length);
    ouputStream.flush();
    ouputStream.close();
      

  2.   

    打漏了 是byte[] bytes=JasperExportManager.exportReportToPdf(prt);