I’m sure many have came across this question but I couldn’t find any solution for non-windows machines.
I need to prepare a python script that can run in linux (multiple versions) as well as in Windows machines. The script should read a PPT file and convert them into an PDF then I am converting the PDF into images. I can achieve the second part (PDF to images) but I can’t achieve the first part (PPT to PDF).
Can anyone please help me to achieve this?
I tried spire, Aspose but both are them are commercial and we need to pay. python pptx doesn’t support conversion. Win32 is not available in Linux.
I am at a deadend.
This is the code I used to achieve the above (both first and second part) using spire library but it doesn’t convert more than 10 pages.
!pip install Spire.Presentation
# Function to convert PPT to Images
def ppt_to_images(ppt_file, destination_folder):
presentation = Presentation()
presentation.LoadFromFile(ppt_file)
presentation_name = ppt_file.split('/')[-1].split('.')[0]
#Save PPT document to images
for i, slide in enumerate(presentation.Slides):
file_name = presentation_name + '_' + str(i) + ".png"
image = slide.SaveAsImage()
image.Save(destination_folder + '/' + file_name)
image.Dispose()
presentation.Dispose()
return None
ppt_to_images("/content/drive/MyDrive/Colab Notebooks/DummyPPTs/dummy_powerpoint.pptx", OUTPUT_FOLDER)
Calling the above function using
ppt_to_images("/content/drive/MyDrive/Colab Notebooks/DummyPPTs/dummy_powerpoint.pptx", OUTPUT_FOLDER)