Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active September 22, 2022 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blog-aspose-cloud/0329b745ebc2220c073727689d0b7ad7 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/0329b745ebc2220c073727689d0b7ad7 to your computer and use it in GitHub Desktop.
Convert PDF to JPG using Java Cloud SDK

PDF to JPG in Java


This Gist provides the details on how to convert PDF to JPG using Aspose.PDF Cloud SDK for Java.
In following code snippet, we are going to first read the input PDF from local drive, upload it to cloud storage using PdfApi.uploadFile(..) method and then going to call putPageConvertToJpeg(...) API to initiate the PDF to JPG conversion. The resultant JPG is saved in cloud storage. For complete details, please visit Convert PDF to JPG in Java.

Convert PDF to JPG

Important Links

Product Page | Docs | Live Demo | Swagger UI | Code Samples | Source Code | New Releases | Blog | Free Support | Free Trial

Convert PDF to JPG in Java
// for more examples, please visit https://github.com/aspose-pdf-cloud/aspose-pdf-cloud-java
try
{
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/
String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";
// create an instance of PdfApi
PdfApi pdfApi = new PdfApi(clientSecret,clientId);
// name of input PDF document
String inputFile = "45.pdf";
// name of resultant JPG image
String resultantImage = "Resultant.jpg";
// read the content of input PDF file
File file = new File("c://Users/"+inputFile);
// upload PDF to cloud storage
pdfApi.uploadFile("input.pdf", file, null);
// page number of PDF to be converted
int pageNumber = 1;
// width of resultant JPG image
int width = 800;
// height of resultant JPG image
int height = 1000;
// call the API for PDF to JPG conversion
pdfApi.putPageConvertToJpeg("input.pdf", pageNumber, resultantImage, width, height, null, null);
// print conversion status message
System.out.println("PDF to JPG conversion sucessfull !");
}catch(Exception ex)
{
System.out.println(ex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment