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.
https://api.pdf.co/v1/pdf/convert/to/jpg
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);
https://api.pdf.co/v1/pdf/convert/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);
https://api.pdf.co/v1/pdf/convert/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);
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