Build a robust PDF to PPT converter using Python SDK. Learn the steps to convert PDF to PowerPoint presentation with fewer code lines
We are aware of the fact that PDF files are widely used for information and data sharing. This format is quite popular because it preserves the document layout when viewed on any platform. But in case you need to present its information, you will need to copy all the details and create a new presentation file. Instead of manually creating the PowerPoint file, the better solution is to programmatically convert PDF to (PPT, PPTX, etc) format. In this article, we are going to discuss the details of how we can programmatically convert PDF to PPT using Python SDK.
PDF Conversion API
In order to facilitate our customers with PDF processing and manipulation, we have created Aspose.PDF Cloud SDK for Python which is a wrapper around Aspose.PDF Cloud API. It enables you to create, edit, manipulate and transform PDF files to various supported file-formats including XLSX, PPTX, DOCX, HTML, SVG, JPEG, etc formats. So in order to use the SDK, the first step is its installation. The SDK is available for free download over PIP and GitHub repository. Now execute the following command on the terminal/command prompt to install the latest version of SDK on the system.
pip install asposepdfcloud
Info: Aspose provides a free online PDF Import Service that allows you to convert PDFs to PowerPoint.
After the installation, the next major step is a free subscription to our cloud services via Aspose.Cloud dashboard. The purpose of this subscription is to only allow authorized persons to access our file processing services. If you have GitHub or Google account, simply Sign Up or, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
PDF to PPT Converter in Python
Please follow the instructions specified below to perform the conversion of the PDF file to PPTX format. Please note that the resultant PPTX is not a simple image-based PowerPoint but it contains all the elements in editable format.
- Firstly, we need to create an instance of ApiClient class while providing Client ID Client Secret as arguments
- Secondly, create an instance of PdfApi class that takes the ApiClient object as an input argument
- Thirdly, create variables holding names of the input PDF file and resultant PPTX file
- Finally, call the put_pdf_in_request_to_pptx(..) method to convert PDF files to PPTX format and save the resultant file to cloud storage
Use the following links to download URL2PDF.pdf and Resultant.pptx.
Convert PDF to PowerPoint using cURL Command
Owing to the REST architecture of Aspose.PDF Cloud, the API can also be accessed via cURL commands on any platform. Simply use the terminal application and convert PDF to PPTX.
However, before executing the conversion command, we need to first generate a JSON Web Token (JWT) based on your individual client credentials specified over Aspose.Cloud dashboard. It is mandatory because our APIs are only accessible to registered users. Please execute the following command to generate the JWT token.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
Once we have the JWT token, please execute the following command to perform the conversion operation.
curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/URL2PDF.pdf/convert/pptx?outPath=Resultant.pptx&separateImages=false&slidesAsImages=false" \ -H "accept: application/json" \ -H "authorization: Bearer <JWT Token>"
In case you need to convert the PDF file and save the output in the response stream, please try using the following cURL command.
curl -X GET "https://api.aspose.cloud/v3.0/pdf/URL2PDF.pdf/convert/pptx?separateImages=false&slidesAsImages=false" \ -H "accept: multipart/form-data" \ -H "authorization: Bearer <JWT Token>" \ -o myConverted.pptx
In this article, we have discussed a very easy and convenient approach to converting PDF to PPT in Python as well as using the cURL command. This method is very useful when you need to perform the conversion of bulk documents. We also encourage you to freely download the source code of SDK available on GitHub.
Also, the product documentation contains a plethora of articles explaining other exciting features of the API. Furthermore, if you encounter any issues while using the API or you have any further queries, please feel free to contact us via the free customer support forum.
We also recommend visiting the following links to learn more about