How to generate barcode (jquery) async API for barcode generator API in JavaScript and PDF.co Web API

How to generate barcode (jquery) async API in JavaScript with easy ByteScout code samples to make barcode generator API. Step-by-step tutorial

The documentation is designed to help you to implement the features on your side. PDF.co Web API was made to help with barcode generator API in JavaScript. PDF.co Web API is the Web API with a set of tools for documents manipulation, data conversion, data extraction, splitting and merging of documents. Includes image recognition, built-in OCR, barcode generation and barcode decoders to decode bar codes from scans, pictures and pdf.

JavaScript code samples for JavaScript developers help to speed up the application’s code writing when using PDF.co Web API. For implimentation of this functionality, please copy and paste code below into your app using code editor. Then compile and run your app. Use of PDF.co Web API in JavaScript is also explained in the documentation included along with the product.

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.

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

generate_barcode.js
      
var apiKey = ""; $(document).ready(function () { $("#resultBlock").hide(); $("#errorBlock").hide(); }); $(document).on("click", "#submit", function () { apiKey = $("#apiKey").val().trim(); //Get your API key by registering at https://app.pdf.co/documentation/api var url = "https://api.pdf.co/v1/barcode/generate?name=barcode.png"; url += "&type=" + $("#barcodeType").val(); // Set barcode type (symbology) url += "&value=" + $("#inputValue").val(); // Set barcode value url += "&async=True"; // Set async // Show loader $("#loader").show(); $.ajax({ url: url, type: "GET", headers: { "x-api-key": apiKey }, }) .done(function (data, textStatus, jqXHR) { if (data.error) { $("#errorBlock").show(); $("#error").html(data.message); $("#loader").hide(); } else { checkIfJobIsCompleted(data.jobId, data.url); } }) .fail(function (jqXHR, textStatus, errorThrown) { $("#errorBlock").show(); $("#error").html("Request failed. Please check you use the correct API key."); $("#loader").hide(); }); }); function checkIfJobIsCompleted(jobId, resultFileUrl) { $.ajax({ url: 'https://api.pdf.co/v1/job/check?jobid=' + jobId, type: 'GET', headers: { 'x-api-key': apiKey }, // passing our api key success: function (jobResult) { $("#status").html(jobResult.status + ' &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />'); if (jobResult.status == "working") { // Check again after 3 seconds setTimeout(function(){ checkIfJobIsCompleted(jobId, resultFileUrl); }, 3000); } else if (jobResult.status == "success") { $("#resultBlock").show(); $("#image").attr("src", resultFileUrl); } $("#loader").hide(); }, error: function(){ $("#errorBlock").show(); $("#error").html("Request failed. Please check you use the correct API key."); $("#loader").hide(); } }); }

Try PDF.co Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Get PDF.co Web API Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Related Samples: