代码:
<!-- 打印模块 -->
<script src="static/jquery/jquery-migrate-1.2.1.min.js"></script>
<script language="javascript" src="static/jquery/jquery.jqprint-0.3.js"></script>
<!-- 条形码 -->
<script src="static/js/JsBarcode.all.js"></script>
<script type="text/javascript">
//获取条形码
function sptxm(id) {
JsBarcode("#div", "1111", {fontSize:20,fontOptions:'bold'});
}
//打印div中的内容
function print(){
$("#sps_txm").jqprint();
}
</script>
条形码参数:
JsBarcode("#div", “1111”, {
format: “CODE39”,//选择要使用的条形码类型
width:3,//设置条之间的宽度
height:100,//高度
displayValue:true,//是否在条形码下方显示文字
text:“456”,//覆盖显示的文本
fontOptions:“bold italic”,//使文字加粗体或变斜体
font:“fantasy”,//设置文本的字体
textAlign:“left”,//设置文本的水平对齐方式
textPosition:“top”,//设置文本的垂直位置
textMargin:5,//设置条形码和文本之间的间距
fontSize:15,//设置文本的大小
background:"#eee",//设置条形码的背景
lineColor:"#2196f3",//设置条和文本的颜色。
margin:15//设置条形码周围的空白边距
});