`

求救:有关iReport调用打印机的问题

阅读更多

   1、前提:

         工程(B/S结构)部署在一台服务器上;

         接着,在另外一个PC机访问服务器(http://192.168.28.1:8088/dmscs/aLogin.jsp);

         在PC机上安装打印机,点击打印;

 

   2、问题:

        PC机上打印机未出现打印的字条,而在服务器上出现打印的信息;

 

   3、最终效果:

         如何在调用PC机上的打印机打印出字条?????

 

 

    4、使用工具:

          ireport 3.6.0

 

    5、使用技术:

          struts2

   

   6、程序中调用的打印方法:

        /**
  *功能:打印
  *编写时间:2013-08-23
  */
 public boolean printProcedure(String[] str) {
  boolean bf = false;
  String url = this.getClass().getClassLoader().getResource("").getPath().replace("WEB-INF/classes/", "jasper");
  url = url+"/pCode.jasper";
  url.replace('/', '\\');
  JasperReport report = null;
  JasperPrint jasperPrint = null;
  
  GetDayRandomNumber grn = new GetDayRandomNumber();
  String fileValue = grn.getValue(str[1]);
  
  if (fileValue==null||fileValue.equals("null")){//表示没有
   Random rd = new Random();
   int random = 0;
    do{
     random = rd.nextInt(999);
    }while(random<100);
   grn.modifyValue(str[1], String.valueOf(random));
   fileValue = String.valueOf(random);
  }
  
  try{
   report =(JasperReport)JRLoader.loadObject(url);
   
   Map<String,String> map = new HashMap<String,String>();
   map.put("xm", str[3]);
   map.put("cm", str[2]);
   map.put("rq", str[1]);
   map.put("sjs",fileValue+str[6]);
   jasperPrint = JasperFillManager.fillReport(report,map);

   JasperPrintManager.printReport(jasperPrint, false);

   System.out.println("export pdf success!");
   bf = true;
  } catch (Exception e) {
   e.printStackTrace();
  }
  return bf;
 }

    

 

 

 

 

 

0
0
分享到:
评论
1 楼 caixu23 2013-11-13  
jasperPrint = JasperFillManager.fillReport(report,map);
   JasperPrintManager.printReport(jasperPrint, false);

你要用这个,就要用Applet,将流传回客户机。


一般BS的,你要将jasper转为html才能在浏览器端打印,具体的方法你可以去google一下,最好结合lodop

相关推荐

Global site tag (gtag.js) - Google Analytics