This article mainly introduces how to implement operations on pptfiles in Python. it involves the skills related to Python operation slides and is of great practical value, for more information, see the following example. Share it with you for your reference. The specific analysis is as follows:
The following code can be used for powerpoint files. you can specify the slide pages to be captured. you need to install powerpoint on the local machine and specify the size and resolution.
Import osimport comtypes. clientdef export_presentation (path_to_ppt, path_to_folder): if not (OS. path. isfile (path_to_ppt) and OS. path. isdir (path_to_folder): raise "Please give valid paths! "Powerpoint = comtypes. client. createObject ("Powerpoint. application ") # Needed for script to work, though I don't see any reason why... powerpoint. visible = True powerpoint. open (path_to_ppt) # Or some other image types powerpoint. activePresentation. export (path_to_folder, "JPG") # you can write it here: # Presentation. slides [1]. export ("C:/path/to/jpg.jpg", "JPG", 800,600); powerpoint. presentations [1]. close () powerpoint. quit ()
I hope this article will help you with Python programming.