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.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
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"; var oData = { name: 'barcode.png', type: $("#barcodeType").val(), // Set barcode type (symbology) value: $("#inputValue").val(), // Set barcode value async: true }; // Show loader $("#loader").show(); $.ajax({ url: url, data: oData, 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: 'POST', headers: { 'x-api-key': apiKey }, // passing our api key success: function (jobResult) { $("#status").html(jobResult.status + ' <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(); } }); }
VIDEO
ON-PREMISE OFFLINE SDK
See also:
ON-DEMAND REST WEB API
Get Your API Key
See also:
PDF-co-Web-API-JavaScript-Generate-Barcode-(JQuery)-Async-API.pdf