Transform your image files into organized, shareable PDF documents with ease using the GroupDocs.Conversion Cloud Java SDK. With minimal coding requirements, you can programmatically convert common image formats like JPEG, PNG, BMP, and TIFF to PDF—simplifying your document processing workflows directly within Java applications.
The Cloud API is designed for both performance and user-friendliness. You have precise control over output formatting, resolution, and layout, while maintaining a lightweight and speedy integration. By utilizing this Java REST API for converting images to PDF, developers can minimize manual involvement and provide users with a consistent export experience across different platforms.
Whether you’re creating enterprise applications, cloud-based file processing systems, or internal automation scripts, our Cloud API provides the necessary flexibility and scalability. It guarantees that you can carry out this functionality without relying on external software. Please consult our comprehensive guide and begin today to create high-performance image-to-PDF conversion applications in Java.
The following code example assists developers in embedding this feature into their Java solutions.
package com.groupdocs;
import com.groupdocs.cloud.conversion.client.*;
import com.groupdocs.cloud.conversion.model.*;
import com.groupdocs.cloud.conversion.api.ConvertApi;
import com.groupdocs.cloud.conversion.model.requests.*;
public class ConvertImageToPdf {
public static void main(String[] args) {
// Set up client credentials and initialize configuration
String MyClientId = "your-client-id";
String MyClientSecret = "your-client-secret";
Configuration configure = new Configuration(MyClientId, MyClientSecret);
// Initialize conversion API to convert Image to PDF
ConvertApi conversionAPI = new ConvertApi(configure);
// Initialize ConvertSettings
ConvertSettings settings = new ConvertSettings();
// Source file path in the cloud storage
settings.setFilePath("SampleFiles/source.jpg");
settings.setFormat("pdf");
// Configure PDF conversion options
PdfConvertOptions convertOptions = new PdfConvertOptions();
convertOptions.setGrayscale(false);
convertOptions.setMarginTop(10);
convertOptions.setMarginBottom(10);
settings.setConvertOptions(convertOptions);
// Specify output path
settings.setOutputPath("conversion/result.pdf");
try {
// Create and execute conversion request
ConvertDocumentRequest request = new ConvertDocumentRequest(settings);
conversionAPI.convertDocument(request);
} catch (Exception e) {
System.err.println("Error occurred: " + e.getMessage());
}
}
}