Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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