Reputation: 31
slides=prs1.slides
for slide in prs1.slides:
ImageData.insert(1, "Slide "+str(slides.index(slide)+1))
TextData.insert(1, "Slide "+str(slides.index(slide)+1))
for shape in slide.shapes:
if 'Picture' in shape.name:
write_image(shape, ImageData)
elif shape.has_table:
table_data(shape, TextData)
elif shape.has_text_frame:
s=""
for paragraph in shape.text_frame.paragraphs:
for run in paragraph.runs:
s+= " "+run.text
TextData.append(s)
elif shape.shape_type == MSO_SHAPE_TYPE.GROUP:
group_data(shape, ImageData, TextData)
def group_data(group_shape, ImageData, TextData):
#for group_shape in group_shapes:
for shape in group_shape.shapes:
if 'Picture' in shape.name:
if (ImageData == []):
ImageData.append("Slide "+str(slides.index(slide)+1))
write_image(shape, ImageData)
elif shape.has_table:
TextData.append("Slide "+str(slides.index(slide)+1))
table_data(shape, TextData)
elif shape.has_text_frame:
if (TextData == []):
TextData.append("Slide "+str(slides.index(slide)+1))
s=""
for paragraph in shape.text_frame.paragraphs:
for run in paragraph.runs:
s+= " "+run.text
TextData.append(s)
elif shape.shape_type == MSO_SHAPE_TYPE.GROUP:
group_data(shape, ImageData, TextData)
I'm not able to read SmartArt data from slides. This is the above code through which i'm able to get 80% of pptx file data. I want to fetch 100% data and store it in a csv file. Even i want to save ppt file as pptx file using python code.
Upvotes: 2
Views: 1378
Reputation: 28991
python-pptx
has no API-support for SmartArt. The schema and semantics for the XML of SmartArt are unpublished (the last time I went looking) so it's not likely to be added anytime soon.
If you want to interpret SmartArt objects you'll have to dig into the XML yourself and do the best you can.
Like a chart or a table, SmartArt is enclosed in a GraphicFrame shape. Like a chart, its contents are stored as a separate part.
Not really an answer, but at least some background to get you started. I recommend you look for an alternative because this direction is going to be a lot of frustrating work that probably ends up in brittle code because you're reverse-engineering rather that working from a spec.
Upvotes: 3