How to generate a QR code barcode as a PNG file in Node.js
The first step is to modify the package.json file to reference the library:
"dependencies": {
"cloudmersive-barcodeapi-client": "^1.1.2"
}
Now, all we need to do is call generateBarcodeQRCode:
var CloudmersiveBarcodeapiClient = require('cloudmersive-barcodeapi-client');
var defaultClient = CloudmersiveBarcodeapiClient.ApiClient.instance;// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';var apiInstance = new CloudmersiveBarcodeapiClient.GenerateBarcodeApi();var value = "value_example"; // String | QR code text to convert into the QR code barcodevar callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.generateBarcodeQRCode(value, callback);
This will generate a full barcode image in PNG format and return it. It’s that easy! Other functions are available for generating other types of barcode images, such as UPC-A 1D barcodes, UPC-E 1D barcodes, etc.