# Slide Tools (pptxgenjs) PowerPoint で再編集可能な .pptx を生成するツール群。 4 ツール: - `SetTheme` : テーマ (色・フォント・サイズ) を選ぶ。冒頭で 1 回 - `AddSlide` : スライドを 1 枚追加する - `BuildPptx` : 蓄積した状態から .pptx を書き出す。最後に 1 回 - `ResetSlides` : 全スライドを破棄する (テーマは維持) 中間状態は `output/.slides.json` に保存される。直接編集しないこと。 ## SetTheme ```ts SetTheme({ preset: "corporate-blue" | "minimal-mono" | "vibrant" | "academic" | "dark" | "warm-paper", overrides?: { primary?: string, // "#1A5490" 等 accent?: string, background?: string, text?: string, muted?: string, heading_font?: string, body_font?: string, title_size?: number, // pt heading_size?: number, body_size?: number, } }) ``` preset 一覧: | preset | 雰囲気 | |---|---| | corporate-blue | 営業・社内提案 (青基調) | | minimal-mono | 既定。シンプルな黒白 | | vibrant | ポップ、LT 向け (赤×ティール) | | academic | 学術発表 (落ち着いた青、セリフ) | | dark | 暗背景・明るいテキスト | | warm-paper | クリーム背景、温かみ | ## AddSlide ```ts AddSlide({ layout: "title" | "section" | "bullets" | "two-column" | "image-right" | "image-left" | "image-full" | "table" | "chart" | "quote" | "closing" | "custom", content: { /* layout 依存 */ }, notes?: string }) ``` ### layout ごとの content **title**: `{ title, subtitle?, author?, date? }` **section**: `{ number?: "01", title }` **bullets**: `{ title, bullets: Bullet[], footnote? }` - `Bullet` = `string` または `{ text, bold?, bullets?: Bullet[] }`。`bullets` をネストするとサブ項目(インデント)になる。基本は文字列配列で十分 **two-column**: `{ title, left: {heading?, bullets?: Bullet[], text?}, right: {...} }` **image-right** / **image-left**: `{ title, body: string | string[], image: { path, alt? } }` **image-full**: `{ image: { path }, caption? }` **table**: `{ title, headers: string[], rows: string[][], col_widths?: number[] }` - col_widths は比率 (合計 1.0 で全幅、例 `[0.3, 0.5, 0.2]`)。省略時は均等割 **chart**: `{ title, chart_type: "bar"|"line"|"pie"|"doughnut"|"area"|"scatter", data: { categories: string[], series: [{name, values: number[]}] } }` - series[].values.length は categories.length と一致必須 **quote**: `{ quote, attribution? }` **closing**: `{ message?: "Thank you", contact? }` **custom**: `{ elements: Array<...> }` (escape hatch、詳細下記) ### custom.elements 座標単位は inch。安全領域は x=0.5, y=0.5, w=12.33, h=6.5。 ```ts { type: "text", text, x, y, w, h, options?: {font_size, bold, color, align} } { type: "image", path, x, y, w, h } { type: "shape", shape: "rect"|"roundRect"|"arrow"|"oval"|"line", x, y, w, h, options?: {fill, line, text} } { type: "table", headers, rows, x, y, w, h } { type: "chart", chart_type, data, x, y, w, h } ``` ### よくある失敗 - 画像パスは workspace 相対 (`input/foo.png` 等)。URL は不可 → 事前に DownloadFile - chart の series.values.length と categories.length の不一致は AddSlide 時点で reject - table.col_widths を指定するなら headers の長さと同じ要素数 ## BuildPptx ```ts BuildPptx({ output?: string }) // 既定 "output/slides.pptx" ``` - `output` は workspace 相対、`output/` 配下のみ可 - 戻り値に「スライド数 / ファイルサイズ / テーマ / 警告」が含まれる - スライドが 0 枚なら error - `.slides.json` が壊れていれば error + `ResetSlides()` を提案 ## ResetSlides ```ts ResetSlides() ``` - slides[] を空にする - theme は維持 - 全枚やり直すときのみ使う ## PDF が欲しい場合 このツールは PDF 出力に非対応。生成された .pptx を PowerPoint / Keynote / LibreOffice で開いて Export してもらう。