This blog has a link to generate a barcode, convert it into a picture, and print it. JS generates a barcode JsBarcode.all.js, converts it into a picture canvas2image.js, and prints a QR code jQuery.print.js_wybshyy's Blog-CSDN Blog
This article describes the usage of the JS barcode plug-in JsBarcode with an example. Share it with everyone for your reference, as follows:
Here is an introduction to the js plugin that generates barcodes on GitHub→JsBarcode
Barcodes supported are:
CODE128
CODE128 (automatic mode switching)
CODE128 A/B/C (forced mode)
EAN
EAN-13
EAN-8
EAN-5
EAN-2
UPC (A)
CODE39
ITF-14
MSI
MSI10
MSI11
MSI1010
MSI1110
Pharmacode
Codabar
code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no"/>
<title>
</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js">
</script>
<script type="text/javascript" src="js/JsBarcode.all.js">
</script>
</head>
<body>
<svg id="svgcode">
</svg>
<!-- or -->
<canvas id="canvascode">
</canvas>
<!-- or -->
<img id="imgcode" />
<script>
$("#svgcode").JsBarcode('Hi!'); //or JsBarcode("#svgcode", "Hi!");
$("#canvascode").JsBarcode('Hello world!'); //or JsBarcode("#canvascode", "Hello world!");
$("#imgcode").JsBarcode("I'm huangenai!"); //or JsBarcode("#imgcode", "I'm bwju!");
</script>
</body>
</html>
JsBarcode We can also set some properties of the barcode
<img />
<script>
JsBarcode("#imgcode", "123", {
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//设置条形码周围的空白边距
});
</script>
Barcode Generator: http://lindell.me/JsBarcode/generator/
JsBarcode Examples and Settings: http://codepen.io/lindell/pen/mPvLXx?editors=1010
Simple JsBarcode Demo: http://codepen.io /lindell/pen/eZKBdO?editors=1010