How to convert PDF to image in JavaScript using Cloud API (low level) - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to convert PDF to image in JavaScript using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to convert PDF to image in JavaScript using Cloud API (low level)

The code sample below will demonstrate how to convert PDF to image(JPEG, PNG, TIFF) in JavaScript & jQuery using ByteScout Cloud API (low level). You can set such parameters as image resolution, quality, and image output format.

You can also check how to convert PDF to image in Java, pure JavaScript, and PHP.

PDF to JPEG

POST/GET endpoint:

https://api.pdf.co/v1/pdf/convert/to/jpg

Code Sample (PDF to JPEG):

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.pdfConvertToJpgPost(opts, callback);

PDF to PNG

POST/GET endpoint:

https://api.pdf.co/v1/pdf/convert/to/png

Code Sample (PDF to PNG):

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.pdfConvertToPngPost(opts, callback);

PDF to TIFF

POST/GET endpoint:

https://api.pdf.co/v1/pdf/convert/to/tiff

Code Sample (PDF to TIFF):

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.pdfConvertToTiffPost(opts, callback);

Tutorials:

prev
next