c-lodop使用

下好插件在jsp页面引入

<script type="text/javascript" src="static/js/LodopFuncs.js"></script>

controll流处理图片:

/**
 * logo图片
 * @param page
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/logo")
@ResponseBody
public PageData logo(Page page,HttpServletRequest request) throws Exception {
ModelAndView mv = this.getModelAndView();
PageData pd = new PageData();
String path   =   request.getSession().getServletContext().getRealPath("/")+"yemei.jpg";
BufferedInputStream in = new BufferedInputStream(new FileInputStream(path));
ByteArrayOutputStream outStream = new ByteArrayOutputStream();    
try {
        byte[] buffer = new byte[1024];    
        int len = 0;    
        while( (len=in.read(buffer)) != -1 ){    
            outStream.write(buffer, 0, len);    
        }    
        pd.put("jpg", outStream.toByteArray());
mv.addObject("pd", pd);
} catch (Exception e) {
logger.error(e.toString(), e);
}finally{
if(in!=null){
in.close();
}
if(outStream!=null){
outStream.close();
}
}
return pd;
}

插入图片(ajax流获取图片)

jsp:

var yemei = "data:image/jpg;base64,";
$.ajax({
url : 'fcht/logo.do',
datatype : 'json',
type : 'POST',
async : false,
success : function(result) {
var obj = eval(result);
yemei = yemei+obj.jpg;

}

});


    function ddedxyhtPrint(way){
    ddedxyhtMessage();
    //LODOP.PRINT_DESIGN(); //打印设计
    if(way == '0'){
    LODOP.PREVIEW();//打印预览
    }else{
    LODOP.PRINT(); //直接打印
    }

    }

用html的方式设计模板

 function ddedxyhtMessage() {
      LODOP=getLodop(); 
         LODOP.SET_PRINT_PAGESIZE(2,0,0,"A4");
  LODOP.PRINT_INITA("0mm","0mm","210mm","2970mm","最高额股权质押合同");
  LODOP.ADD_PRINT_IMAGE("10.84mm","20mm","35.19mm","15.88mm",yemei);
  LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
  var bq = "</td></tr><tr><td colspan='2'>";//普通标签
  var bqc = "</td></tr><tr><td colspan='2' align='center'>";//居中标签
  var kg = "&nbsp;&nbsp;&nbsp;&nbsp;";//前面空格
  var htmlnr = "";
  htmlnr = htmlnr+"<style> table,td,th {line-height:36px;font-size:14px;font-family: '宋体';border: 0px solid black;border-style: solid;border-collapse: collapse}tr{height: 36px;}</style>";
  htmlnr = htmlnr+"<table align='center' border='0' width='100%'> ";
  htmlnr = htmlnr+"<tr> ";
  htmlnr = htmlnr+"  <td colspan='2'  align='center'> ";
  htmlnr = htmlnr+"<span style='font-size:28px;font-family: '宋体';><strong></br></br>最高额股权质押合同</strong></span> ";
  htmlnr = htmlnr+kg+""+bq;
  htmlnr = htmlnr+kg+"签约日期:<u>*#@$%^</u>年<u>*#@$%^</u>月<u>*#@$%^</u>日"+bq;
  htmlnr = htmlnr+kg+"签署地点:济南市高新万达广场C区北侧商业街101号、102号"+bq;
  htmlnr = htmlnr+kg+""+bq;
  htmlnr = htmlnr+"</table>";
  LODOP.ADD_PRINT_TABLE("26mm","20mm","160mm","255mm",htmlnr);//设置打印表格大小,放入html
  LODOP.ADD_PRINT_TEXT("280.38mm","25mm","26.46mm","6.61mm","");
  LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
  LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
  LODOP.SET_PRINT_STYLEA(0,"Horient",2);
  LODOP.ADD_PRINT_LINE(91,80,90,689,0,1);
  LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
  LODOP.SET_PRINT_STYLEA(0,"Horient",2);
  LODOP.ADD_PRINT_TEXT(77,417,294,20,"合同编号:  (201x)年鲁信典当质字第0xx号");
  LODOP.SET_PRINT_STYLEA(0,"PageIndex","first");//设置在多少页显示此条信息
  LODOP.ADD_PRINT_TEXT(77,192,96,20,"股权质押合同");
  LODOP.SET_PRINT_STYLEA(0,"PageIndex","2");
  LODOP.ADD_PRINT_TEXT(76,526,168,20,"山东省鲁信典当有限责任公司");
  LODOP.SET_PRINT_STYLEA(0,"PageIndex","2");
  LODOP.ADD_PRINT_TEXT(77,192,96,20,"股权质押合同");
  }

阅读更多
个人分类: js
相关热词: c-lodop
上一篇Word字体的字号与像素对应关系
下一篇导出excel
想对作者说点什么? 我来说一句

C-Lodop工作原理

chufeng1992 chufeng1992

2015-12-31 08:42:57

阅读数:2462

没有更多推荐了,返回首页

关闭
关闭