Convert PDF to JPG Image in Node.js using REST API

How to Convert PDF to JPG Image in Node.js using REST API
Convert PDF to JPG Image in Node.js using REST API

You can convert PDF to images of popular formats such as JPG/JPEG programmatically on the cloud. As a Node.js developer, you can easily convert PDF to JPG high resolution online in your Node.js applications. This article will be focusing on how to convert PDF to JPG image in node.js using REST API.

The following topics shall be covered in this article:

PDF to Image Converter REST API and Node.js SDK

I will be using the Node.js SDK of GroupDocs.Conversion Cloud API for converting PDF to JPG. The API allows you to convert your documents to any format you need. It supports the conversion of over 50 types of documents and images such as Word, Excel, PowerPoint, PDF, HTML, JPG, PNG, CAD. It also provides .NET, Java, PHP, Ruby, Android, and Python SDKs as its document conversion family members for the Cloud API.

You can install GroupDocs.Conversion Cloud to your Node.js applications using the following command in the console:

npm install groupdocs-conversion-cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your ID and secret, add in the code as shown below:

How to Convert PDF to JPG format using REST API in Node.js

You can convert PDF to JPG image file by following the simple steps given below:

  1. Upload the PDF file to the cloud
  2. Convert PDF to JPG image online free in Node.js
  3. Download the converted JPG file

Upload the Image

Firstly, upload the JPG file to the Cloud using the following code sample:

As a result, the uploaded JPG file will be available in the files section of your dashboard on the cloud.

Convert PDF to JPG using Node.js

Please follow the steps mentioned below to convert PDF to JPG file programmatically:

  • Create an instance of ConvertApi
  • Create ConvertSettings instance
  • Set the PDF file path
  • Assign “jpg” to format
  • Provide output file path
  • Create ConvertDocumentRequest
  • Get results by calling the ConvertApi.convertDocument() method

The following code example shows how to convert pdf to jpg without losing quality using REST API in Node.js:

How to Convert PDF to JPG using Node.js
Convert PDF to JPG using Node.js

Download the Converted File

The above code sample will save the converted PDF file on the cloud. You can download it using the following code sample:

PDF to JPG Conversion using Advanced Options

Please follow the steps mentioned below using pdf to jpg high quality online converter API with some advanced settings:

  • Create an instance of ConvertApi
  • Create ConvertSettings instance
  • Set the PDF file path
  • Assign “jpg” to format
  • Provide output file path
  • Define JpgConvertOptions
  • Set various convert settings such as dpi, imageQuality, height, margins (top, left, right, bottom), etc.
  • Create ConvertDocumentRequest
  • Get results by calling the ConvertApi.convertDocument() method

The following code example shows how to convert pdf to jpg format online with advanced convert options:

How to convert pdf to jpg in windows 10 using Advanced Options
Convert from PDF to JPG single image using Advanced Options

Convert PDF to JPG without using Cloud Storage

Please follow the steps mentioned below to convert PDF to JPG format without using Cloud storage:

  • Create an instance of ConvertApi
  • Create ConvertDocumentDirectRequest
  • Provide the input file path and target format as input parameters
  • Get results by calling the convertDocumentDirect() method
  • Save output file to the local path using FileStream.writeFile() method

The following code example shows how to convert PDF document to JPG without using cloud storage. It means you will pass the input file in the request body and receive the output file in the API response.

Multiple pdf to jpg converter API using Node.js
Convert multiple pdf to jpg without using Cloud Storage

Convert PDF to JPG and Add Watermark

Please follow the steps mentioned below to convert PDF to JPG and then add watermark to the converted PDF:

  • Create an instance of ConvertApi
  • Create ConvertSettings instance
  • Set the PDF file path
  • Assign “jpg” to format
  • Provide output file path
  • Define WatermarkOptions
  • Set Watermark Text, Color, Width, Height, etc.
  • Define PdfConvertOptions and assign WatermarkOptions
  • Create ConvertDocumentRequest
  • Get results by calling the ConvertApi.convertDocument() method

The following code example shows how to convert PDF document to JPG and add a watermark to the converted PDF document using a REST API in Node.js.

PDF to JPG image converter API to add watermark
Convert PDF to JPG and Add Watermark

Online PDF to JPG Converter Free

How to use pdf to jpg high quality converter online free? Please try the following best free pdf to jpg converter online high quality, which is developed using the above API.

Conclusion

In this article, you have learned:

  • how to change PDF to JPG format on the cloud;
  • programmatically upload the PDF file and then download the converted file from the cloud;
  • convert pdf to jpg online free high quality without using cloud storage;
  • how to convert pdf to jpg on windows 10 using advanced options;
  • how to add a watermark to the converted PDF document using Node.js;

You can learn more about GroupDocs.Conversion Cloud API using the documentation. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.

Ask a question

You can ask your queries about how to convert PDF into JPG format, via our Free Support Forum

See Also