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

Cloudmersive
2 min readApr 2, 2020

--

This tutorial will show you how to easily set up barcode generation with EAN-13 format and export as a PNG file. We will accomplish this very easily with an API we have designed to work hand in hand with Node.JS to save you as much time as possible. Let’s look at the process.

We begin simply enough with installation of our API client. Npm install will get the job done for us quickly.

npm install cloudmersive-barcodeapi-client --save

Next up, our function call:

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.generateBarcodeEAN13(value, callback);

Enter in a value and the API will generate a corresponding barcode. It’s really that easy. This same client offers support for other popular barcode formats, including QR and UPC-E, to name a couple.

--

--

Cloudmersive

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