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

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

Users frequently need to convert PDF to image because an image is one of the major data components. It is challenging to parse and display content from a PDF document due to the complexity of the format. 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 intend to use the Node.js SDK of GroupDocs.Conversion Cloud API for converting PDF to JPG. The API allows you to convert your documents and images 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, etc. It also provides .NET, Java, PHP, Ruby, Android, and Python SDKs as its document conversion family members for the Cloud API.

GroupDocs.Conversion Cloud can be installed in your Node.js applications by running the following command in the console:

npm install groupdocs-conversion-cloud

Please collect your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. After 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

This section covers a step-by-step guide on how to import PDF files to JPG images. Follow the simple steps below to convert a PDF file to a JPG image file:

  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 File

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

As a result, the PDF file that was uploaded will be accessible in the files section of your dashboard on the cloud.

Convert PDF to JPG using Node.js

Now, to convert PDF to JPG file programmatically, follow the steps and code sample below:

  • Create an instance of ConvertApi
  • Create an instance of ConvertSettings class
  • Now, set the cloud storage name
  • Next, set the input PDF file path
  • Set the output file format as “jpg”
  • Next, provide the output file path
  • Now, create an object of ConvertDocumentRequest class
  • Finally, get the output file 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 JPG file on the cloud. You can download it using the following code sample:

PDF to JPG Conversion using Advanced Options

The following steps and code snippet demonstrate how to convert PDF to image using PDF to JPG high-quality online converter API and some advanced settings:

  • Create an instance of ConvertApi
  • Create an instance of ConvertSettings
  • Now, set the cloud storage name
  • Next, set the PDF file path
  • Then, set the value “jpg” to the format
  • Define JpgConvertOptions
  • Set various convert settings such as grayscale, fromPage, pagesCount, quality, rotateAngle, usePdf, etc.
  • Now, set the conversations and the output file path
  • Create ConvertDocumentRequest object
  • Lastly, convert PDF to JPG by calling the ConvertApi.convertDocument() class

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

To convert PDF to JPG without using cloud storage, please follow the steps below:

  • 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 the output file to the local path using FileStream.writeFile() method

The following code snippet shows how to convert PDF documents 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.

Convert multiple pdf to jpg without using Cloud Storage

Convert multiple pdf to jpg without using Cloud Storage

Convert PDF to JPG and Add Watermark

Please use the following steps to convert PDF to JPG and then add a watermark to the converted PDF:

  • Create an instance of ConvertApi
  • Create an object of ConvertSettings
  • Now, set the cloud storage name
  • Next, set the PDF file path
  • Now, assign “jpg” to the format
  • Provide the output file path
  • Define WatermarkOptions class
  • Set Watermark options like text, color, width, height, background, etc.
  • Define PdfConvertOptions and assign WatermarkOptions
  • Now, set the convert Options value
  • Then, create ConvertDocumentRequest instance
  • Lastly, convert and call using the ConvertApi.convertDocument() class

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 for 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 in Node.js 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 in Node.js 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. Additionally, we advise you to refer to our Getting Started guide.

Furthermore, blog.groupdocs.cloud is writing new blog posts on interesting topics. Please get in touch for the most recent information.

Ask a question

You can use our Free Support Forum to ask any questions you may have about how to convert PDF into JPG format.

FAQs

How do I convert PDF to JPG in Node.js?

Please follow this link to learn the Node.js code snippet for how to turn PDF into JPG file quickly and easily.

How to convert PDF to JPG file using REST API?

Create an instance of ConvertApi, set the values of the convert settings, and invoke the convertDocument method with ConvertDocumentRequest for converting PDF to JPG file.

How to convert PDF into JPG free online?

PDF to JPG converter free online allows you to export PDF to JPG format, quickly and easily. Once the conversion is completed, you can download the JPG file.

How do I convert PDF file to JPG online for free?

  • Open online PDF to JPG converter free
  • Click inside the file drop area to upload PDF or drag & drop PDF file.
  • Click on Convert Now button, and online PDF to JPG converter software will convert PDF file into JPG.
  • The Download link of the output file will be available instantly after converting PDF to JPG file.

How to install PDF to JPG format converter free download library?

Install PDF to JPG converter free download Node.js library to create, and convert PDF to JPG programmatically.

How do I convert PDF to JPG offline in windows?

Please visit this link to download PDF to JPG converter software free for windows. This online PDF to JPG converter free download software can be used to turn PDF into JPG in windows quickly, with a single click.

See Also

To learn more, we suggest reading the following articles: