transfer
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
from pptx import Presentation
|
||||
|
||||
# load the uploaded file
|
||||
input_path = "./tech_project_proposal_ideas_dark_theme.pptx"
|
||||
output_path = "./new_pptx.pptx"
|
||||
|
||||
def to_title_case(text: str) -> str:
|
||||
if not text:
|
||||
return text
|
||||
# title case for slide titles (major words capitalized)
|
||||
return text.title()
|
||||
|
||||
def to_sentence_case(text: str) -> str:
|
||||
if not text:
|
||||
return text
|
||||
text = text.strip()
|
||||
if not text:
|
||||
return text
|
||||
# sentence case for bullet points
|
||||
return text[0].upper() + text[1:]
|
||||
|
||||
# open ppt
|
||||
prs = Presentation(input_path)
|
||||
|
||||
for slide in prs.slides:
|
||||
for shape in slide.shapes:
|
||||
if not shape.has_text_frame:
|
||||
continue
|
||||
tf = shape.text_frame
|
||||
# heuristics: assume first shape (or largest font) in slide is the title
|
||||
if slide.shapes.index(shape) == 0 or "title" in shape.name.lower():
|
||||
for para in tf.paragraphs:
|
||||
para.text = to_title_case(para.text)
|
||||
else:
|
||||
for para in tf.paragraphs:
|
||||
para.text = to_sentence_case(para.text)
|
||||
|
||||
# save output
|
||||
prs.save(output_path)
|
||||
|
||||
output_path
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user