How to generate barcode for barcode generator API in JavaScript and Web API

See how to generate barcode to have barcode generator API in JavaScript

Source code documentation samples provide quick and easy way to add a required functionality into your application. Web API helps with barcode generator API in JavaScript. Web API is the flexible Web API that includes full set of functions from e-signature requests to data extraction, OCR, images recognition, pdf splitting and pdf splitting. Can also generate barcodes and read barcodes from images, scans and pdf.

You will save a lot of time on writing and testing code as you may just take the code below and use it in your application. For implimentation of this functionality, please copy and paste code below into your app using code editor. Then compile and run your app. This basic programming language sample code for JavaScript will do the whole work for you in implementing barcode generator API in your app.

Trial version of ByteScout is available for free download from our website. This and other source code samples for JavaScript and other programming languages are available.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)


function generateBarcode() { // Hide result blocks document.getElementById("errorBlock").style.display = "none"; document.getElementById("resultBlock").style.display = "none"; // Get API Key var apiKey = document.getElementById("apiKey").value.trim(); if (apiKey == "") { alert("API Key should not be empty."); return false; } // Get barcode type var barcodeType=document.getElementById("barcodeType").value; // Get barcode value var inputValue = document.getElementById("inputValue").value.trim(); if (inputValue == null || inputValue == "") { alert("Barcode Value should not be empty."); return false; } //show loader showLoader(true); // Prepare URL var url = ""; url += "&type=" + barcodeType; // Set barcode type (symbology) url += "&value=" + inputValue; // Set barcode value // Prepare request var httpRequest = new XMLHttpRequest();"POST", url, true); httpRequest.setRequestHeader("x-api-key", apiKey); // set API Key // Asynchronous response handler httpRequest.onreadystatechange = function() { if (httpRequest.readyState == 4) { // If OK if (httpRequest.status == 200) { var result = JSON.parse(httpRequest.responseText); if (result.error == false) { document.getElementById("resultBlock").style.display = "block"; // show hidden resultBlock document.getElementById("image").setAttribute("src", result.url); // Set image link to display } else { document.getElementById("errorBlock").style.display = "block"; // show hidden errorBlock document.getElementById("error").innerHTML = result.message; } } // Else display error else { document.getElementById("errorBlock").style.display = "block"; // show hidden errorBlock document.getElementById("error").innerHTML = "Request failed. Please check you use the correct API key."; } // Hide loader showLoader(false); } } // Send request httpRequest.send(); return true; } function showLoader(isDisplay){ var loader = document.getElementById("loader"); if(isDisplay){ = ""; } else{"none"; } }



Get 60 Day Free Trial

See also:


Get Your API Key

See also:

Related Samples: