Last active
April 2, 2021 10:23
-
-
Save groupdocs-cloud-gists/94e40ca58b0d46396ab6246ac16aa3bb to your computer and use it in GitHub Desktop.
Convert PDF to PowerPoint PPTX Presentation using a REST API on the cloud in Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Convert PDF to PPTX using Python | |
1. Programmatically upload PDF file on the cloud | |
2. Convert uploaded PDF file to PPTX presentation programmatically using Python. | |
3. Download the output files from the cloud. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client_id = "112f0f38-9dae-42d5-b4fc-cc84ae644972" | |
client_secret = "16ad3fe0bdc39c910f57d2fd48a5d618" | |
my_storage = "" | |
configuration = groupdocs_conversion_cloud.Configuration(client_id, client_secret) | |
configuration.api_base_url = "https://api.groupdocs.cloud" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create necessary API instances | |
api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret) | |
# Prepare convert settings | |
settings = groupdocs_conversion_cloud.ConvertSettings() | |
settings.file_path = "sample.pdf" | |
settings.format = "pptx" | |
# Provide PDF load options | |
loadOptions = groupdocs_conversion_cloud.PdfLoadOptions() | |
loadOptions.hide_pdf_annotations = True | |
settings.load_options = loadOptions; | |
# Provide PPTX convert options | |
convertOptions = groupdocs_conversion_cloud.PptxConvertOptions() | |
convertOptions.from_page = 1 | |
convertOptions.pages_count = 2 | |
convertOptions.zoom = 1 | |
settings.convert_options = convertOptions | |
settings.output_path = "converted/" | |
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings) | |
response = api.convert_document(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create necessary API instances | |
api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret) | |
# Prepare convert settings | |
settings = groupdocs_conversion_cloud.ConvertSettings() | |
settings.file_path = "sample.pdf" | |
settings.format = "pptx" | |
settings.output_path = None # leave OutputPath will result the output as document IOStream | |
# Prepare request | |
request = groupdocs_conversion_cloud.ConvertDocumentRequest(settings) | |
# Convert | |
response = api.convert_document_download(request) | |
# Move downloaded file to your working directory | |
shutil.move(response, "C:\\Files\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create necessary API instances | |
api = groupdocs_conversion_cloud.ConvertApi.from_keys(client_id, client_secret) | |
# Prepare request | |
request = groupdocs_conversion_cloud.ConvertDocumentDirectRequest("pptx", "C:\\Files\\sample.pdf") | |
# Convert | |
response = api.convert_document_direct(request) | |
# Move downloaded file to your working directory | |
shutil.move(response, "C:\\Files\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create instance of the API | |
file_api = groupdocs_conversion_cloud.FileApi.from_config(configuration) | |
request = groupdocs_conversion_cloud.DownloadFileRequest("converted/sample.pptx", my_storage) | |
response = file_api.download_file(request) | |
# Move downloaded file to your working directory | |
shutil.move(response, "C:\\Files\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create instance of the API | |
fileApi = groupdocs_conversion_cloud.FileApi.from_config(configuration) | |
request = groupdocs_conversion_cloud.UploadFileRequest("sample.pptx", "C:\\Files\\sample.pdf", "") | |
response = fileApi.upload_file(request) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment