Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active June 4, 2025 22:36
Show Gist options
  • Save groupdocs-cloud-gists/5b6877fbd80e0aa372cbcfb7d50c9463 to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/5b6877fbd80e0aa372cbcfb7d50c9463 to your computer and use it in GitHub Desktop.
Convert PDF to JPG with Node.js
Develop PDF to JPEG converter using Node.js API
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-node
// Obtain your API credentials
string clientId = "XXXXXX-XXXXXXXXX-4088-9ca0-55c38f4b7f22";
string clientSecret1 = "XXXXXXXXXXXXXXXXXXXX";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret
Configuration configuration = new Configuration(clientId, clientSecret);
// Define the API base URL to perform PDF to JPEG conversion online
configuration.setApiBaseUrl("https://api.groupdocs.cloud");
// Initialize an instance of ConvertApi with the Configuration object
ConvertApi convertApi = new ConvertApi(configuration);
ConvertSettings settings = new ConvertSettings();
settings.setStorageName("internal");
settings.setFilePath("input.pdf");
settings.setFormat("JPG");
settings.setOutputPath("resultant.jpg");
// Use ConvertDocument method to convert a PDF file to JPG image format
ConvertDocumentRequest request = new ConvertDocumentRequest(settings);
List<StoredConvertedResult> response = convertApi.convertDocument(request);
// Check the response and print success message
if (response != null && response.equals("OK")) {
System.out.println("The PDF to JPEG conversion completed successfuly! The resultant JPEG image is saved at: " + response.getFilePath());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment