본문 바로가기

카테고리 없음

PYTHON-PPTX

1. 구성 요소 유형(type)

python-pptx에서 읽을수 있는  ppt 주요 구성요소의 유형(type)는 아래와 같다.

  1. AutoShapes (1)
  2. FREEFORM (5)
  3. GROUP (6)
  4. LINE (9)
  5. Pictures (13)
  6. PLACEHOLDER (14)
  7. Text box (17)
  8. Table (19)
  9. Chart
  10. SmartArt
  11. 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)

 

2. ppt 요소 불러오기

1) 슬라이드 불러오기

import pptx

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>

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'으로 구성요소의 유형을 불러들일수 있

 

 

3. 구성요소별 Properties

구성요소별로 주로 읽어들여야할 Properties는

1. AutoShapes :

   - 위치

   - 크기

   - 텍스트 폰트, 크기 등

  1. AutoShapes (1)