How to convert PDF to XLSX in jquery async API for PDF to excel API in JavaScript using PDF.co Web API

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

Source code documentation samples provide quick and easy way to add a required functionality into your application. PDF.co Web API was made to help with PDF to excel 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.

This rich sample source code in JavaScript for PDF.co Web API includes the number of functions and options you should do calling the API to implement PDF to excel API. For implimentation of this functionality, please copy and paste code below into your app using code editor. Then compile and run your app. Enjoy writing a code with ready-to-use sample JavaScript codes to add PDF to excel API functions using PDF.co Web API in JavaScript.

PDF.co Web API – free trial version is on available our website. Also, there are other code samples to help you with your JavaScript application included into trial version.

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

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

converter.js

      
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 https://app.pdf.co/documentation/api 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: 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&contenttype=application/pdf&encrypt=true', 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: 'https://api.pdf.co/v1/pdf/convert/to/' + 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: '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") { $("#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); } } } }); }

VIDEO

ON-PREMISE OFFLINE SDK

Get 60 Day Free Trial

See also:

ON-DEMAND REST WEB API

Get Your API Key

See also: