一、初始画布
var arguments = {
width: '100%',
height: '100%',
color:'#000',
"decor-color": "transparent",//去除默认画布上那条横线
lineWidth: '3'
};
$("#signature").jSignature(arguments);
二、画布获取数据方式
1.var datapair=$("#signature").jSignature("getData");
获取到是字符串:
data:image/png;base64,+base64的字符串
2.var datapair=$("#signature").jSignature("getData", "svgbase64");
获取到是数组:
datapair[0]=data:image/svg+xml;base64,
datapair[1]=svgbase64的字符串
三、清除画布
$("#signature").jSignature("clear");
四、在页面中显示画布
var sig=$("#signature");
1.$("#img").attr("src","data:"+sig.jSignature('getData'));
2.$("#img").attr("src","image/svg+xml;base64,"+sig.jSignature('getData',"svgbase64"));
五、导出在excel中显示
1.
String imgStr=resultList.get(i).get("attend_sign_signature").toString().replace("data:image/png;base64,","");
//base64转成byte
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(imgStr);
for (int j = 0; j < b.length; ++j) {b[j] += 256;
}
}
//jxl方式导出excel
WritableImage image = new WritableImage(1,k + 13,1,1,b);