This sample code will show how to extract data from PDF to Text or CSV in JavaScript using Cloud API (low level).
Also, check this article to learn how to extract and convert spreadsheets between various file formats in JavaScript using Cloud API.
https://api.pdf.co/v1/pdf/convert/to/text
var Bytescoutio = require('bytescoutio'); var defaultClient = Bytescoutio.ApiClient.instance; // Configure API key authorization: api_key var api_key = defaultClient.authentications['api_key']; api_key.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix['x-api-key'] = "Token" var api = new Bytescoutio.DefaultApi() var opts = { 'pages': pages_example, // {String} Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. 'name': name_example, // {String} File name for generated result. 'url': url_example // {String} URL of the source PDF file. }; var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; api.pdfConvertToTextPost(opts, callback);
https://api.pdf.co/v1/pdf/convert/to/csv
var Bytescoutio = require('bytescoutio'); var defaultClient = Bytescoutio.ApiClient.instance; // Configure API key authorization: api_key var api_key = defaultClient.authentications['api_key']; api_key.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix['x-api-key'] = "Token" var api = new Bytescoutio.DefaultApi() var opts = { 'pages': pages_example, // {String} Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. 'name': name_example, // {String} File name for generated result. 'url': url_example // {String} URL of the source PDF file. }; var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; api.pdfConvertToCsvPost(opts, callback);
IMPORTANT:
Cloud API is deprecated and was replaced with more powerful and secure www.PDF.co Web API
CLICK HERE
TO LEARN MORE
ABOUT NEW
www.PDF.co
w/ Web API
On-Premise API Server
Cloud API Server