pdf to jpg

Convert pdf to jpg using Java cloud SDK

PDF files are widely used over the internet for information and data sharing. Now in order to view these documents, we need to use specific applications but if we save PDF as JPG, it can be viewed on any platform and any device. Also, the size of the file is greatly reduced. Furthermore, we can easily develop a PDF viewer because, once we save a PDF as an image, we can load the image in any browser. Therefore, in this article, we are going to discuss the details to convert PDF to JPG online using Cloud API.

PDF to JPG Conversion API

Aspose.PDF Cloud SDK for Java is an amazing product enabling us to implement PDF file creation, manipulation, and conversion to various supported formats within Java applications. It also enables you to convert PDF to Image. So in order to use the SDK, first we need to install it by adding the following details in pom.xml of the maven build type project.

        <name>Aspose Cloud Repository</name>


Now we need to create a free account by visiting Aspose.Cloud dashboard. You may Sign up using your existing GitHub or Google account, or click the Create a new Account button to complete the subscription.

Convert PDF to JPG in Java

Please follow the instructions specified below to accomplish the requirement for converting PDF to JPG online.

  • First, create an instance of PdfApi class where we provide Client ID Client Secret as arguments
  • Secondly, read the content of the input PDF from the local drive using the File object
  • Now upload the input PDF file to cloud storage using the uploadFile(…) method
  • Define dimensions for resultant jpg image (these are optional arguments)
  • Finally, call the putPageConvertToJpeg(…) method of PdfApi which takes the input PDF, page number to be converted, resultant JPG name, and dimensions for the resultant image

PDF to Image using cURL Commands

We can also convert PDF to Image format using cURL commands over the command line terminal. However, in order to access Aspose.PDF Cloud, we need to first generate a JSON Web Token (JWT) based on your individual client credentials. Please execute the following command to generate the JWT token.

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once the JWT is generated, please execute the following command to convert PDF to image and save the output in cloud storage.

curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf/pages/1/convert/jpeg?outPath=resultant.jpg&width=800&height=1000" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"


In this blog, you have learned an amazing skill for converting PDF to JPG using Java code snippets. Similarly, you have also learned about the usage of cURL commands to save PDF to Image via command line terminal. The Product Documentation is a great source for learning other amazing capabilities being offered by the API. So we suggest you try using our APIs and in case you encounter any issues while using the API, please feel free to contact the Free product support forum.

We also recommend visiting the following blogs for further details regarding: