How to convert PDF to HTML in jquery async API for PDF to HTML API in JavaScript with Web API

Tutorial: how to convert PDF to HTML in jquery async API for PDF to HTML API in JavaScript

Sample source codes below will show you how to cope with a difficult task, for example, PDF to HTML API in JavaScript. Web API helps with PDF to HTML API in JavaScript. Web API is the Rest API that provides set of data extraction functions, tools for documents manipulation, splitting and merging of pdf files. Includes built-in OCR, images recognition, can generate and read barcodes from images, scans and pdf.

The SDK samples like this one below explain how to quickly make your application do PDF to HTML API in JavaScript with the help of Web API. Follow the instruction and copy – paste code for JavaScript into your project’s code editor. Use of Web API in JavaScript is also explained in the documentation included along with the product.

Our website provides free trial version of Web API that includes source code samples to help with your JavaScript project.

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

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


var apiKey, formData, toType, isInline; $(document).ready(function () { $("#resultBlock").hide(); $("#errorBlock").hide(); $("#result").attr("href", '').html(''); }); $(document).on("click", "#submit", function () { $("#resultBlock").hide(); $("#errorBlock").hide(); $("#inlineOutput").text(''); // inline output div $("#status").text(''); // status div apiKey = $("#apiKey").val().trim(); //Get your API key at formData = $("#form input[type=file]")[0].files[0]; // file to upload toType = $("#convertType").val(); // output type isInline = $("#outputType").val() == "inline"; // if we need output as inline content or link to output file $("#status").html('Requesting presigned url for upload... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />'); $.ajax({ url: '', type: 'GET', headers: {'x-api-key': apiKey}, // passing our api key success: function (result) { if (result['error'] === false) { var presignedUrl = result['presignedUrl']; // reading provided presigned url to put our content into $("#status").html('Uploading... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />'); $.ajax({ url: presignedUrl, // no api key is required to upload file type: 'PUT', headers: {'content-type': 'application/pdf'}, // setting to pdf type as we are uploading pdf file data: formData, processData: false, success: function (result) { $("#status").html('Processing... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />'); $.ajax({ url: ''+toType+'?url='+ presignedUrl + '&encrypt=true&inline=' + isInline + '&async=True', type: 'POST', headers: {'x-api-key': apiKey}, success: function (result) { if (result.error) { $("#status").text('Error uploading file.'); } else { checkIfJobIsCompleted(result.jobId, result.url); } } }); }, error: function () { $("#status").text('error'); } }); } } }); }); function checkIfJobIsCompleted(jobId, resultFileUrl) { $.ajax({ url: '' + 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(checkIfJobIsCompleted(jobId, resultFileUrl), 3000) } else if (jobResult.status == "success") { $("#status").text('Done converting.'); $("#resultBlock").show(); if (isInline && toType != "xls" && toType != "xlsx") { $.ajax({ url: resultFileUrl, dataType: 'text', success: function (respText) { $("#inlineOutput").text(respText); } }); } else { $("#result").attr("href", resultFileUrl).html(resultFileUrl); } } } }); }



Get 60 Day Free Trial

See also:


Get Your API Key

See also:

Related Samples: