Skip to content

Commit e650cfa

Browse files
committed
Added description to existing files.
1 parent 74ba23f commit e650cfa

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

ppt2video/convertor.py

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,65 @@ def ppt2video(pptx, video, timing, duration,
3333
# slides_len = len(presentation.Slides)
3434

3535
# powerpoint = win32com.client.Dispatch('PowerPoint.Application')
36-
# new_presentation = ppt.Presentations.Add(WithWindow=False)
36+
new_presentation = ppt.Presentations.Add(WithWindow=False)
37+
# slides = new_presentation.Slides
38+
# presentation.Slides[1].Copy()
39+
# new_presentation.Slides.Paste(1)
40+
# graphSlideID = gslides.Add(2, ppLayoutChart).SlideID
41+
# slides.FindBySlideID(graphSlideID)
42+
43+
44+
# Slides indexes start with 1
45+
for slide in presentation.Slides:
46+
# print(e.SlideIndex, e.SlideNumber, e.SlideID)
47+
for key, value in dict.items():
48+
# print(slide.SlideIndex, key)
49+
# print(len(new_presentation.Slides))
50+
if slide.SlideIndex == int(key) and value != "":
51+
len_new_ppt = len(new_presentation.Slides)
52+
53+
print(" slide.SlideIndex == key", slide.SlideIndex)
54+
55+
new_slide = new_presentation.Slides.Add(len_new_ppt+1, ppLayoutText)
56+
new_slide.Shapes.addShape(
57+
msoShapeRectangle, 150, 150, 250, 250). \
58+
TextFrame.TextRange.Text = value
59+
slide.Copy()
60+
new_presentation.Slides.Paste(len_new_ppt+2)
61+
# else:
62+
# print("slide.SlideIndex != key", slide.SlideIndex, key)
63+
64+
65+
# if e.SlideIndex == key:
66+
# print(" e.SlideIndex == key", e.SlideIndex )
67+
# else:
68+
# print("e.SlideIndex != key", e.SlideIndex, key)
69+
# if not presentation.Slides[int(key)]:
70+
# # e.Copy()
71+
# # new_presentation.Slides.Paste(length_new_presentation)
72+
# # length_new_presentation += 1
73+
# print("no index in dict", e.SlideIndex, e.SlideNumber, e.SlideID)
74+
# else:
75+
# if presentation.Slides[int(key)] and value != "":
76+
# # slide = new_presentation.Slides.Add(length_new_presentation+1, ppLayoutText)
77+
# # slide.Shapes.addShape(
78+
# # msoShapeRectangle, 150, 150, 250, 250). \
79+
# # TextFrame.TextRange.Text = value
80+
# # e.Copy()
81+
# # new_presentation.Slides.Paste(length_new_presentation+2)
82+
# # length_new_presentation += 1
83+
# print("index in both", e.SlideIndex, e.SlideNumber, e.SlideID)
84+
85+
86+
# for key, value in dict.items():
87+
# if presentation.Slides[int(key)] and value != "":
88+
# slide = new_presentation.Slides.Add(int(key)+1, ppLayoutText)
89+
# slide.Shapes.addShape(
90+
# msoShapeRectangle, 150, 150, 250, 250). \
91+
# TextFrame.TextRange.Text = value
92+
# presentation.Slides[int(key)].Copy()
93+
# new_presentation.Slides.Paste(int(key)+2)
94+
3795
# list_slides = [e for e in presentation.Slides]
3896
# # for each in presentation.Slides:
3997
# for key, value in dict.items():
@@ -102,7 +160,7 @@ def ppt2video(pptx, video, timing, duration,
102160

103161
# Presentation.CreateVideo method (PowerPoint)
104162
# https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentation.createvideo
105-
presentation.CreateVideo(video_path, timing, duration,
163+
new_presentation.CreateVideo(video_path, timing, duration,
106164
resolution, frames, quality)
107165
while True:
108166
try:
@@ -112,6 +170,7 @@ def ppt2video(pptx, video, timing, duration,
112170
break
113171
except Exception:
114172
pass
173+
new_presentation.Close()
115174
presentation.Close()
116175
ppt.Quit()
117176
pass
@@ -129,7 +188,11 @@ def ppt2video(pptx, video, timing, duration,
129188
# the first slide. You can leave it blank and no additional
130189
# slides will be inserted in the video.
131190
user_input_list = []
132-
input_dict = {"0":"0", "1":"1", "2":"2","3":"3","4":"4","5":"","6":"","7":"","8":"","9":""}
191+
# key in the dict represents the index of the slides in the presentation
192+
# to be converted into video. Slides indexes start with 1, "first slide".
193+
input_dict = { "1":"input index 1",
194+
"2":"input index 2", "4":"input index 4", "5":"input index 5",
195+
"10":"input index 10",}
133196

134197
ppt2video(f"./{file_name}", f"./{video_name}.mp4",
135198
UseTimingsAndNarrations,

ppt2video/presentation_video.mp4

951 KB
Binary file not shown.

0 commit comments

Comments
 (0)