I am trying to get the path of the file that I am writing as below. help me with code how to get the path from the below function.
I need the file path as the return variable. I am passing a number as barcodeSourceNumber.
pathToFile = build_barcode('123456789');
function build_barcode(barcodeSourceNumber) {
var pngFileName;
const bwipjs = require('bwip-js');
bwipjs.toBuffer({
bcid: 'code128', // Barcode type
text: barcodeSourceNumber, // Text to encode
scale: 3, // 3x scaling factor
height: 10, // Bar height, in millimeters
includetext: false, // Show human-readable text
textxalign: 'center', // Always good to set this
}, function (err, png) {
var pngFileName = = barcodeSourceNumber + '.png';
fs.writeFileSync(pngFileName, png);
});
return pngFileName;
}
But I am getting '.' or undefined as the return value when I try to call the function.