Skip to content

Instantly share code, notes, and snippets.

How to Convert PDF to PPT or PPTX using Java
package com.groupdocsdev.classes;
import com.groupdocs.cloud.conversion.api.*;
import com.groupdocs.cloud.conversion.model.requests.*;
import com.groupdocs.cloud.conversion.client.Configuration;
import com.groupdocs.cloud.conversion.client.ApiException;
import java.io.File;
// Download File from the Cloud Storage in Java
public class App {
public static void main(String[] args) {
// Create an instance of the convert API
FileApi apiInstance = new FileApi(configuration);
try {
DownloadFileRequest request = new DownloadFileRequest("java-testing\\output-sample-file.pptx", MyStorage, null);
File response = apiInstance.downloadFile(request);
System.err.println("Expected response type is File: " + response.length());
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
package com.groupdocsdev.classes;
import com.groupdocs.cloud.conversion.api.*;
import com.groupdocs.cloud.conversion.model.*;
import com.groupdocs.cloud.conversion.model.requests.*;
import com.groupdocs.cloud.conversion.client.Configuration;
import com.groupdocs.cloud.conversion.client.ApiException;
import java.util.List;
// Convert PDF to PowerPoint PPTX in Java.
public class App {
public static void main(String[] args) {
// Create an instance of the convert API
ConvertApi apiInstance = new ConvertApi(configuration);
try {
// Prepare convert settings
ConvertSettings settings = new ConvertSettings();
settings.setStorageName(MyStorage);
settings.setFilePath("java-testing/input-sample-file.pdf");
settings.setFormat("pptx");
PptxConvertOptions convertOptions = new PptxConvertOptions();
convertOptions.setFromPage(1);
convertOptions.setPagesCount(2);
convertOptions.setZoom(200);
settings.setConvertOptions(convertOptions);
settings.setOutputPath("java-testing/output-sample-file.pptx");
// convert to specified format
List<StoredConvertedResult> response = apiInstance.convertDocument(new ConvertDocumentRequest(settings));
System.out.println("Document converted successfully: " + response);
} catch (ApiException e) {
System.err.println("Exception while calling Java API: ");
e.printStackTrace();
}
}
}

You can PDF files to editable PowerPoint PPT and PPTX slides programmatically on the cloud. In this article, you will learn how to convert PDF to PPT or PPTX using Java.

The following topics shall be covered in this article:

  1. Java PDF to PPT and PPTX Conversion REST API and SDK Installation
  2. How to Convert PDF to Editable PowerPoint PPTX using Java
package com.groupdocsdev.classes;
import com.groupdocs.cloud.conversion.api.*;
import com.groupdocs.cloud.conversion.model.*;
import com.groupdocs.cloud.conversion.model.requests.*;
import com.groupdocs.cloud.conversion.client.Configuration;
import com.groupdocs.cloud.conversion.client.ApiException;
import java.io.File;
// Upload File to Cloud Storage using Java
public class App {
public static void main(String[] args) {
// Create an instance of the convert API
FileApi apiInstance = new FileApi(configuration);
try {
File fileStream = new File("H:\\groupdocs-cloud-data\\input-sample-file.pdf");
UploadFileRequest request = new UploadFileRequest("java-testing\\input-sample-file.pdf", fileStream, MyStorage);
FilesUploadResult response = apiInstance.uploadFile(request);
System.out.println("Expected response type is FilesUploadResult: " + response.getUploaded().size());
} catch (ApiException e) {
System.err.println("Exception while calling FileApi:");
e.printStackTrace();
}
}
}
# Get your client_id and client_secret from https://dashboard.groupdocs.cloud after free registration.
String ClientId = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
String ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
String MyStorage = "test-internal-storage";
Configuration configuration = new Configuration(ClientId, ClientSecret);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment