How to generate a EAN-8 barcode as a PNG file in Node.JS

Cloudmersive
2 min readMar 23, 2020

--

Setting up a barcode system in Node.JS all by yourself can be a bit intimidating. To help ease that load a bit, we have developed an API that will help you in generating EAN-8 barcodes. Using it is a piece of cake, as you are about to see.

First comes our client installation, which just means adding a reference to your package.json file.

"dependencies": {
"cloudmersive-barcodeapi-client": "^1.1.2"
}

The next step is to call our function, in this case generateBarcodeEAN8.

var CloudmersiveBarcodeapiClient = require('cloudmersive-barcodeapi-client');var defaultClient = CloudmersiveBarcodeapiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveBarcodeapiClient.GenerateBarcodeApi();var value = "value_example"; // String | Barcode value to generate fromvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.generateBarcodeEAN8(value, callback);

Done! Yup, it’s just that simple. Any string that you enter in for the value will be encoded as a EAN-8. We have API support for a variety of other barcode formats as well, including QR, EAN-13, and more.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet