1. 구성 요소 유형(type)
python-pptx에서 읽을수 있는 ppt 주요 구성요소의 유형(type)는 아래와 같다.
- AutoShapes (1)
- FREEFORM (5)
- GROUP (6)
- LINE (9)
- Pictures (13)
- PLACEHOLDER (14)
- Text box (17)
- Table (19)
- Chart
- SmartArt
- Embedded objects
불러들이는 코드
import pptx
pr = pptx.Presentation(r'주소\파일명.pptx')
num_slides = len(pr.slides)
print(f"The presentation has {num_slides} slides.")
shape_list = []
for i in range(num_slides):
slide = pr.slides[i]
for shape in slide.shapes:
print("-------------")
print(shape.shape_type)
shape_list.append(shape.shape_type)
shape_list = list(set(shape_list))
print(shape_list)
pr = pptx.Presentation(r'주소\파일명.pptx')
num_slides = len(pr.slides)
print(f"The presentation has {num_slides} slides.")
shape_list = []
for i in range(num_slides):
slide = pr.slides[i]
for shape in slide.shapes:
print("-------------")
print(shape.shape_type)
shape_list.append(shape.shape_type)
shape_list = list(set(shape_list))
print(shape_list)
2. ppt 요소 불러오기
1) 슬라이드 불러오기
import pptx
pr = pptx.Presentation(r'파일위치')
for slide in pr.slides : ## '.slides'로 슬라이드 불러오
print(slide)
pr = pptx.Presentation(r'파일위치')
for slide in pr.slides : ## '.slides'로 슬라이드 불러오
print(slide)
<pptx.slide.Slide object at 0x0000021B8E1396C0>
<pptx.slide.Slide object at 0x0000021CD9FE51E0>
<pptx.slide.Slide object at 0x0000021CD9FE52D0>
<pptx.slide.Slide object at 0x0000021CD9FE5330>
<pptx.slide.Slide object at 0x0000021CD9FE5390>
<pptx.slide.Slide object at 0x0000021CD9FE51E0>
<pptx.slide.Slide object at 0x0000021CD9FE52D0>
<pptx.slide.Slide object at 0x0000021CD9FE5330>
<pptx.slide.Slide object at 0x0000021CD9FE5390>
2) 슬라이드 구성요소 유형(type) 불러오기
import pptx
pr = pptx.Presentation(r'파일위치')
for slide in pr.slides:
for shape in slide.shapes: ## slide.shapes로 구성요소(shape)를 불러올수 있음
print(shape.shape_type) ## '_type'으로 구성요소의 유형을 불러들일수 있
pr = pptx.Presentation(r'파일위치')
for slide in pr.slides:
for shape in slide.shapes: ## slide.shapes로 구성요소(shape)를 불러올수 있음
print(shape.shape_type) ## '_type'으로 구성요소의 유형을 불러들일수 있
3. 구성요소별 Properties
구성요소별로 주로 읽어들여야할 Properties는
1. AutoShapes :
- 위치
- 크기
- 텍스트 폰트, 크기 등
- AutoShapes (1)