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.

PDF to Text

POST/GET endpoint:

https://bytescout.io/v1/pdf/convert/to/text

Code sample (PDF 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);

PDF to CSV

POST/GET endpoint:

https://bytescout.io/v1/pdf/convert/to/csv

Code sample (PDF 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);