diff --git a/node/package.json b/node/package.json index 9571589..9a6a072 100644 --- a/node/package.json +++ b/node/package.json @@ -13,7 +13,7 @@ "adm-zip": "^0.5.10", "applicationinsights": "^1.7.4", "axios": "^1.5.0", - "bitgener": "^1.2.12", + "bwip-js": "^4.3.2", "chromium": "^3.0.3", "express": "^4.18.2", "fs-extra": "^11.1.1", diff --git a/node/pdf-generate/helpers/notices/genDataMatrix.js b/node/pdf-generate/helpers/notices/genDataMatrix.js index 5b5db53..83f520c 100644 --- a/node/pdf-generate/helpers/notices/genDataMatrix.js +++ b/node/pdf-generate/helpers/notices/genDataMatrix.js @@ -1,32 +1,25 @@ -const bitgener = require('bitgener'); -const { v4: uuidv4 } = require("uuid"); -const path = require('path'); +const bwipjs = require('bwip-js'); +const fs = require('fs'); -function genDataMatrix(data, saveDir) { - const filename = path.join( - saveDir,uuidv4()+".svg"); - bitgener({ - data: data, - type: 'datamatrix', - output: filename, - encoding: 'utf8', - rectangular: false, - padding: 0, - width: 256, - height: 256, - original2DSize: false, - color: 'black', - opacity: 1, - bgColor: '#F7931A', - bgOpacity: 0, - hri: { - show: false - } - }).then((ret) => { - console.log(ret); +function genDataMatrix(data, path) { + const trimmedData = data.replaceAll(' ', ''); + + let svg = bwipjs.toSVG({ + bcid: 'datamatrix', + text: data, + width: 256, + height: 256, + padding: 0, + scale: 3, + includetext: false, + textxalign: 'center', }); - return filename; + const filePath = path + "/" + trimmedData+".svg"; + fs.writeFileSync(filePath, svg); + + return filePath; + } module.exports = genDataMatrix; \ No newline at end of file