124 lines
4.4 KiB
Markdown
124 lines
4.4 KiB
Markdown
---
|
|
name: pptx-creator
|
|
label: PPT 프레젠테이션 생성
|
|
description: Python을 사용하여 전문적인 PowerPoint 프레젠테이션을 생성합니다. 작업 폴더의 양식 파일을 자동 활용합니다.
|
|
icon: \uE7BE
|
|
allowed-tools:
|
|
- folder_map
|
|
- document_read
|
|
- file_read
|
|
- file_write
|
|
- process
|
|
- pptx_create
|
|
- template_render
|
|
tabs: cowork
|
|
---
|
|
|
|
사용자의 요구에 맞는 PowerPoint 프레젠테이션을 Python으로 생성하세요.
|
|
## 실행 경로 선택 (Python 가능/불가)
|
|
- 먼저 `process`로 `python --version`을 확인하세요.
|
|
- Python 가능: 기존 python-pptx 경로를 사용하세요.
|
|
- Python 불가: `pptx_create`로 슬라이드 초안을 생성하고 `template_render` + `file_write`로 발표자료 구조를 보강하세요.
|
|
|
|
|
|
## 사전 준비
|
|
필요한 패키지를 확인하고 설치하세요:
|
|
```
|
|
process: pip install python-pptx
|
|
```
|
|
|
|
## 양식 활용 (마스터 슬라이드 템플릿)
|
|
작업 폴더에 PPT 양식이 있으면 **반드시** 활용하세요:
|
|
|
|
1. **양식 탐색**: `folder_map`으로 작업 폴더를 스캔하여 `.pptx` 파일 확인
|
|
2. **양식 후보 판별**:
|
|
- 파일명에 "양식", "template", "서식", "표준", "기본" 포함
|
|
- 또는 사용자가 명시적으로 "XX 양식으로 작성해줘" 요청
|
|
- 또는 사용자가 특정 .pptx 파일명을 언급
|
|
3. **양식 구조 파악**: `document_read`로 양식의 슬라이드 레이아웃 목록 확인
|
|
4. **양식 기반 생성**:
|
|
```python
|
|
prs = Presentation('양식_발표.pptx')
|
|
# 마스터 슬라이드의 배경, 로고, 색 테마, 폰트가 자동 상속
|
|
# 기존 슬라이드 제거 후 새 내용 추가
|
|
while len(prs.slides) > 0:
|
|
rId = prs.slides._sldIdLst[0].rId
|
|
prs.part.drop_rel(rId)
|
|
del prs.slides._sldIdLst[0]
|
|
```
|
|
5. **레이아웃 확인** (양식마다 다를 수 있음):
|
|
```python
|
|
for i, layout in enumerate(prs.slide_layouts):
|
|
print(f'{i}: {layout.name}')
|
|
```
|
|
6. **양식이 없으면**: 아래 기본 템플릿으로 새 프레젠테이션 생성
|
|
|
|
## 작업 절차
|
|
1. **요구사항 파악**: 발표 주제, 슬라이드 수, 스타일 확인
|
|
2. **양식 확인**: folder_map으로 작업 폴더에 양식 .pptx 파일이 있는지 확인
|
|
3. **스크립트 작성**: file_write로 Python 스크립트 생성
|
|
4. **실행**: `process`로 스크립트 실행
|
|
5. **결과 안내**: 생성된 .pptx 파일 경로를 사용자에게 전달
|
|
|
|
## 스크립트 템플릿
|
|
```python
|
|
from pptx import Presentation
|
|
from pptx.util import Inches, Pt, Emu
|
|
from pptx.dml.color import RGBColor
|
|
from pptx.enum.text import PP_ALIGN
|
|
import os
|
|
|
|
# 양식 파일 자동 감지
|
|
template_keywords = ['양식', 'template', '서식', '표준', '기본']
|
|
template_file = None
|
|
for f in os.listdir('.'):
|
|
if f.endswith('.pptx') and any(kw in f.lower() for kw in template_keywords):
|
|
template_file = f
|
|
break
|
|
|
|
# 양식이 있으면 활용, 없으면 새 프레젠테이션
|
|
if template_file:
|
|
prs = Presentation(template_file)
|
|
# 기존 슬라이드 제거 (마스터/레이아웃은 유지)
|
|
while len(prs.slides) > 0:
|
|
rId = prs.slides._sldIdLst[0].rId
|
|
prs.part.drop_rel(rId)
|
|
del prs.slides._sldIdLst[0]
|
|
print(f'양식 활용: {template_file}')
|
|
print(f'사용 가능한 레이아웃: {[l.name for l in prs.slide_layouts]}')
|
|
else:
|
|
prs = Presentation()
|
|
prs.slide_width = Inches(13.333)
|
|
prs.slide_height = Inches(7.5)
|
|
|
|
# 제목 슬라이드
|
|
slide = prs.slides.add_slide(prs.slide_layouts[0])
|
|
slide.shapes.title.text = '프레젠테이션 제목'
|
|
if len(slide.placeholders) > 1:
|
|
slide.placeholders[1].text = '부제목'
|
|
|
|
# 내용 슬라이드
|
|
slide = prs.slides.add_slide(prs.slide_layouts[1])
|
|
slide.shapes.title.text = '섹션 제목'
|
|
body = slide.placeholders[1]
|
|
body.text = '첫 번째 포인트'
|
|
p = body.text_frame.add_paragraph()
|
|
p.text = '두 번째 포인트'
|
|
|
|
prs.save('presentation.pptx')
|
|
print('프레젠테이션 생성 완료: presentation.pptx')
|
|
```
|
|
|
|
## 지원 기능
|
|
- 제목/내용/빈 슬라이드 레이아웃
|
|
- 텍스트 서식 (글꼴, 크기, 색상, 정렬)
|
|
- 표 삽입
|
|
- 이미지 삽입
|
|
- 도형 (사각형, 원, 화살표)
|
|
- 차트 (막대, 선, 원형)
|
|
- 슬라이드 번호
|
|
- 마스터 슬라이드 커스터마이징
|
|
- **양식 파일 기반 마스터/레이아웃 상속** (배경, 로고, 색 테마, 폰트 자동 유지)
|
|
|
|
한국어로 안내하세요. 작업 폴더에 결과 파일을 저장하세요.
|