I have a barcode and want to display it multiple times to print it out.
When I do add the tag svg
from javascript
, after generating barcode they don't show up.
$scope.generatePrintBarcodePage = function (sampleCode, number) {
$scope.barCodePrint = [];
var i;
for (i = 1; i <= number; i++) {
JsBarcode("#barcode" + i, sampleCode, {
height: 40,
displayValue: true
});
}
}
$scope.showBarcode = function (sampleCode, number) {
for (i = 1; i <= number; i++) {
const node = document.createElement("svg");
node.setAttribute("id", "barcode" + i);
document.getElementById("printPageBarcode").appendChild(node);
JsBarcode("#barcode" + i, sampleCode.SampleCode, {
}
}
Then no barcode is displayed.
But if I pre-create the tag svg
on the html file, they are displayed, but if I create it, I have no control over how many barcodes I want to print.
<div id="printPageBarcode" style=" height: 500px;">
<svg id="barcode1"></svg> <br />
<svg id="barcode2"></svg> <br />
<svg id="barcode3"></svg> <br />
<svg id="barcode4"></svg> <br />
<svg id="barcode5"></svg> <br />
</div>
How can I add the same barcode multiple time?