diff --git a/sam/docs/guides/pptx-generation-guide.md b/sam/docs/guides/pptx-generation-guide.md new file mode 100644 index 0000000..cdf0670 --- /dev/null +++ b/sam/docs/guides/pptx-generation-guide.md @@ -0,0 +1,387 @@ +# HTML → PPTX 변환 도구 사용법 + +> **작성일**: 2026-03-01 +> **상태**: 확정 + +--- + +## 1. 개요 + +HTML 슬라이드 파일을 PowerPoint(PPTX)로 변환하는 로컬 도구이다. +Playwright(브라우저 렌더링) + PptxGenJS(PPTX 생성)를 조합하여, HTML/CSS로 디자인한 슬라이드를 그대로 PPTX로 출력한다. + +### 1.1 구성 요소 + +``` +~/.claude/skills/pptx-skill/scripts/ +├── html2pptx.js ← 핵심 변환 엔진 (HTML → PPTX) +└── node_modules/ + ├── pptxgenjs ← PPTX 파일 생성 라이브러리 + ├── playwright ← 브라우저 렌더링 (HTML 파싱) + ├── sharp ← 이미지 처리 + └── ... +``` + +### 1.2 사전 조건 + +| 항목 | 현재 설치 상태 | +|------|---------------| +| Node.js | v24.13.0 (`~/.nvm/versions/node/`) | +| html2pptx.js | `~/.claude/skills/pptx-skill/scripts/html2pptx.js` | +| pptxgenjs | 위 scripts/node_modules 안에 설치됨 | +| playwright | 위 scripts/node_modules 안에 설치됨 | + +> 별도 `npm install`이 필요 없다. 이미 모든 의존성이 설치되어 있다. + +--- + +## 2. 작업 흐름 + +``` +① HTML 슬라이드 작성 (slides/ 폴더) + ↓ +② 변환 스크립트 작성 (convert.cjs) + ↓ +③ 터미널에서 실행: node convert.cjs + ↓ +④ PPTX 파일 생성 완료 +``` + +--- + +## 3. HTML 슬라이드 작성법 + +### 3.1 기본 템플릿 + +```html + + +
+ + + + + + +본문 내용
+ + +``` + +### 3.2 슬라이드 크기 (body width/height) + +| 용도 | body 크기 | 변환 스크립트 layout | +|------|----------|---------------------| +| **16:9 가로형** (발표용) | `width: 720pt; height: 405pt;` | `width: 10, height: 5.625` | +| **9:16 세로형** (브로셔) | `width: 405pt; height: 720pt;` | `width: 5.625, height: 10` | +| **4:3 가로형** (구형) | `width: 720pt; height: 540pt;` | `width: 10, height: 7.5` | + +> **중요**: HTML의 body 크기와 변환 스크립트의 layout 크기가 일치해야 한다. 불일치 시 에러 발생. + +### 3.3 필수 규칙 + +#### 텍스트 줄바꿈 방지 (가장 중요) + +브라우저와 PowerPoint의 폰트 렌더링 차이로, HTML에서 한 줄인 텍스트가 PPTX에서 두 줄로 넘어가는 문제가 발생한다. + +```html + +이 텍스트는 한 줄입니다
+ + +이 텍스트는 한 줄입니다
+ + +
+ 여러 줄로 의도된 텍스트입니다.
+ 이 경우 nowrap을 넣지 않는다.
+
` 태그 전부
+
+#### 이미지 경로
+
+```html
+
+
+
+
+
+```
+
+#### 스타일 작성
+
+```html
+
+
` 태그에 nowrap 추가 | +| 이미지 안 보임 | 상대 경로 사용 | 절대 경로(`/home/aweso/...`)로 변경 | +| `Cannot find module 'pptxgenjs'` | module.paths 설정 누락 | 스크립트 상단 2줄(module.paths.unshift) 확인 | +| `Cannot find module 'playwright'` | Playwright 미설치 | `cd ~/.claude/skills/pptx-skill/scripts && npx playwright install chromium` | +| PPTX는 생성되지만 빈 슬라이드 | HTML 내용 없음 | HTML 파일을 브라우저로 열어 확인 | + +--- + +## 9. 빠른 시작 (3분 가이드) + +### Step 1: 폴더 만들기 + +```bash +mkdir -p /home/aweso/sam/docs/my-pptx/slides +``` + +### Step 2: HTML 슬라이드 만들기 + +`slides/slide-01.html` 파일 생성: + +```html + + +
+ + + + +MY COMPANY
+부제목 또는 설명
+ + +``` + +### Step 3: 변환 스크립트 만들기 + +`convert.cjs` 파일 생성: + +```javascript +const path = require('path'); +module.paths.unshift(path.join(require('os').homedir(), '.claude/skills/pptx-skill/scripts/node_modules')); +const PptxGenJS = require('pptxgenjs'); +const html2pptx = require(path.join(require('os').homedir(), '.claude/skills/pptx-skill/scripts/html2pptx.js')); + +async function main() { + const pres = new PptxGenJS(); + pres.defineLayout({ name: 'CUSTOM_16x9', width: 10, height: 5.625 }); + pres.layout = 'CUSTOM_16x9'; + + await html2pptx(path.join(__dirname, 'slides', 'slide-01.html'), pres); + + await pres.writeFile({ fileName: path.join(__dirname, 'my-presentation.pptx') }); + console.log('완료!'); +} +main().catch(console.error); +``` + +### Step 4: 실행 + +```bash +cd /home/aweso/sam/docs/my-pptx +node convert.cjs +# → my-presentation.pptx 생성됨 +``` + +--- + +**최종 업데이트**: 2026-03-01