@ohos-ports/slides-grab 1.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README-ko.md +292 -0
  3. package/README.md +301 -0
  4. package/bin/ohos-postinstall.cjs +118 -0
  5. package/bin/ppt-agent.js +620 -0
  6. package/convert.cjs +20 -0
  7. package/native/@img/sharp-libvips-openharmony-arm64/lib/glib-2.0/include/glibconfig.h +220 -0
  8. package/native/@img/sharp-libvips-openharmony-arm64/lib/index.js +1 -0
  9. package/native/@img/sharp-libvips-openharmony-arm64/lib/libexpat.so +0 -0
  10. package/native/@img/sharp-libvips-openharmony-arm64/lib/libffi.so +0 -0
  11. package/native/@img/sharp-libvips-openharmony-arm64/lib/libjpeg.so +0 -0
  12. package/native/@img/sharp-libvips-openharmony-arm64/lib/libpcre2-8.so.0 +0 -0
  13. package/native/@img/sharp-libvips-openharmony-arm64/lib/libvips-cpp.so.42.20.3 +0 -0
  14. package/native/@img/sharp-libvips-openharmony-arm64/lib/libvips.so.42.20.3 +0 -0
  15. package/native/@img/sharp-libvips-openharmony-arm64/package.json +13 -0
  16. package/native/@img/sharp-openharmony-arm64/lib/sharp-openharmony-arm64.node +0 -0
  17. package/native/@img/sharp-openharmony-arm64/package.json +16 -0
  18. package/package.json +95 -0
  19. package/runtimes/claude-code/agents/design-critic-agent.md +23 -0
  20. package/runtimes/codex/agents/slides-grab-design-critic.md +22 -0
  21. package/scripts/build-viewer.js +444 -0
  22. package/scripts/design-gate.js +258 -0
  23. package/scripts/download-video.js +213 -0
  24. package/scripts/editor-server.js +1167 -0
  25. package/scripts/figma-export.js +169 -0
  26. package/scripts/generate-image.js +116 -0
  27. package/scripts/generate-images.js +164 -0
  28. package/scripts/html2pdf.js +822 -0
  29. package/scripts/html2png.js +246 -0
  30. package/scripts/html2pptx.js +162 -0
  31. package/scripts/import-template.js +86 -0
  32. package/scripts/install-runtime.js +216 -0
  33. package/scripts/render-tldraw.js +44 -0
  34. package/scripts/validate-slides.js +221 -0
  35. package/skills/slides-grab/SKILL.md +65 -0
  36. package/skills/slides-grab/references/presentation-workflow-reference.md +61 -0
  37. package/skills/slides-grab-card-news/SKILL.md +35 -0
  38. package/skills/slides-grab-design/SKILL.md +88 -0
  39. package/skills/slides-grab-design/references/beautiful-slide-defaults.md +88 -0
  40. package/skills/slides-grab-design/references/design-gate.md +349 -0
  41. package/skills/slides-grab-design/references/design-rules.md +76 -0
  42. package/skills/slides-grab-design/references/design-system-full.md +568 -0
  43. package/skills/slides-grab-design/references/detailed-design-rules.md +70 -0
  44. package/skills/slides-grab-export/SKILL.md +55 -0
  45. package/skills/slides-grab-export/references/export-rules.md +27 -0
  46. package/skills/slides-grab-export/references/html2pptx.md +627 -0
  47. package/skills/slides-grab-export/references/ooxml.md +427 -0
  48. package/skills/slides-grab-export/references/pptx-skill-reference.md +189 -0
  49. package/skills/slides-grab-html/SKILL.md +67 -0
  50. package/skills/slides-grab-image/SKILL.md +82 -0
  51. package/skills/slides-grab-plan/SKILL.md +68 -0
  52. package/skills/slides-grab-plan/references/design-md-to-slides-conversion.md +135 -0
  53. package/skills/slides-grab-plan/references/outline-format.md +47 -0
  54. package/skills/slides-grab-plan/references/plan-workflow-reference.md +140 -0
  55. package/src/codex-imagen.js +182 -0
  56. package/src/design-diversity-data.js +6932 -0
  57. package/src/design-gate-report.js +244 -0
  58. package/src/design-gate-state.js +329 -0
  59. package/src/design-import.js +164 -0
  60. package/src/design-md-parser.js +415 -0
  61. package/src/design-styles-data.js +1928 -0
  62. package/src/design-styles.js +209 -0
  63. package/src/editor/codex-edit.js +584 -0
  64. package/src/editor/edit-subprocess.js +170 -0
  65. package/src/editor/editor-codex-prompt.md +50 -0
  66. package/src/editor/editor.html +1785 -0
  67. package/src/editor/js/editor-bbox.js +332 -0
  68. package/src/editor/js/editor-chat.js +56 -0
  69. package/src/editor/js/editor-direct-edit.js +238 -0
  70. package/src/editor/js/editor-dom.js +59 -0
  71. package/src/editor/js/editor-init.js +405 -0
  72. package/src/editor/js/editor-navigation.js +54 -0
  73. package/src/editor/js/editor-select.js +558 -0
  74. package/src/editor/js/editor-send.js +175 -0
  75. package/src/editor/js/editor-sse.js +163 -0
  76. package/src/editor/js/editor-state.js +41 -0
  77. package/src/editor/js/editor-type.js +71 -0
  78. package/src/editor/js/editor-utils.js +167 -0
  79. package/src/editor/js/model-registry.js +37 -0
  80. package/src/editor/screenshot.js +82 -0
  81. package/src/export-resolution.cjs +68 -0
  82. package/src/figma.js +71 -0
  83. package/src/html2pptx-scale.cjs +120 -0
  84. package/src/html2pptx.cjs +1262 -0
  85. package/src/image-contract.js +329 -0
  86. package/src/image-native.js +468 -0
  87. package/src/nano-banana.js +841 -0
  88. package/src/ohos-browser-bridge.cjs +272 -0
  89. package/src/pptx-raster-export.cjs +299 -0
  90. package/src/resolve.js +110 -0
  91. package/src/slide-mode.cjs +72 -0
  92. package/src/template-fidelity.js +267 -0
  93. package/src/template-import.js +505 -0
  94. package/src/template-layout.js +261 -0
  95. package/src/template-pack.js +255 -0
  96. package/src/tldraw/render.js +473 -0
  97. package/src/validation/cli.js +120 -0
  98. package/src/validation/core.js +1023 -0
  99. package/templates/chart.html +121 -0
  100. package/templates/closing.html +54 -0
  101. package/templates/content.html +50 -0
  102. package/templates/contents.html +60 -0
  103. package/templates/cover.html +64 -0
  104. package/templates/custom/.gitkeep +0 -0
  105. package/templates/custom/README.md +7 -0
  106. package/templates/design-styles/README.md +20 -0
  107. package/templates/design-styles/preview.html +4438 -0
  108. package/templates/diagram-tldraw.html +56 -0
  109. package/templates/diagram.html +98 -0
  110. package/templates/quote.html +31 -0
  111. package/templates/section-divider.html +43 -0
  112. package/templates/split-layout.html +43 -0
  113. package/templates/statistics.html +55 -0
  114. package/templates/team.html +49 -0
  115. package/templates/timeline.html +59 -0
@@ -0,0 +1,27 @@
1
+ # slides-grab Export Reference
2
+
3
+ These are the packaged export rules for installable `slides-grab` skills.
4
+
5
+ ## Package-first commands
6
+ - Raster PPTX export (default, highest visual fidelity): `slides-grab convert --slides-dir <path> --output <name>.pptx --engine raster`
7
+ - Editable-text PPTX export (best-effort DOM extraction): `slides-grab convert --slides-dir <path> --output <name>-editable.pptx --engine text`
8
+ - PDF export: `slides-grab pdf --slides-dir <path> --output <name>.pdf`
9
+ - Figma export: `slides-grab figma --slides-dir <path> --output <name>-figma.pptx`
10
+
11
+ ## Export stage rules
12
+ - Only export after the user approves the reviewed HTML slides.
13
+ - Do not modify slide content during export unless explicitly requested.
14
+ - If export fails, fix the root cause in the source HTML/CSS or packaged runtime path.
15
+ - For decks with Chart.js or other `<canvas>` charts, run `slides-grab validate --slides-dir <path>` first and fix any `empty-canvas` error before exporting.
16
+ - Build and open `viewer.html` once for chart-heavy decks so the same charts are confirmed in the generated review surface.
17
+ - Keep Chart.js animation disabled in source slides so PDF/PNG capture sees the final painted chart.
18
+
19
+ ## User-facing caveats
20
+ - PPTX export is experimental / unstable.
21
+ - `--resolution` can only be used with raster PPTX export. Text export requires semantic text tags, rasterizes canvas/SVG visuals, and may reject unsupported HTML/CSS.
22
+ - Figma export is experimental / unstable.
23
+ - Best-effort output may still require manual cleanup after export.
24
+
25
+ ## Runtime source of truth
26
+ - Export behavior must come from the packaged CLI/runtime in `bin/`, `scripts/`, and `src/`.
27
+ - Installable skills must not require scripts from inside a skill directory.
@@ -0,0 +1,627 @@
1
+ # HTML to PowerPoint Guide (Experimental / Unstable)
2
+
3
+ Convert HTML slides to best-effort, experimental / unstable PowerPoint presentations using the `html2pptx.js` library.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Creating HTML Slides](#creating-html-slides)
8
+ 2. [Using the html2pptx Library](#using-the-html2pptx-library)
9
+ 3. [Using PptxGenJS](#using-pptxgenjs)
10
+
11
+ ---
12
+
13
+ ## Creating HTML Slides
14
+
15
+ Every HTML slide must include proper body dimensions:
16
+
17
+ ### Layout Dimensions
18
+
19
+ - **16:9** (default): `width: 720pt; height: 405pt`
20
+ - **4:3**: `width: 720pt; height: 540pt`
21
+ - **16:10**: `width: 720pt; height: 450pt`
22
+
23
+ ### Supported Elements
24
+
25
+ - `<p>`, `<h1>`-`<h6>` - Text with styling
26
+ - `<ul>`, `<ol>` - Lists (never use manual bullets •, -, *)
27
+ - `<b>`, `<strong>` - Bold text (inline formatting)
28
+ - `<i>`, `<em>` - Italic text (inline formatting)
29
+ - `<u>` - Underlined text (inline formatting)
30
+ - `<span>` - Inline formatting with CSS styles (bold, italic, underline, color)
31
+ - `<br>` - Line breaks
32
+ - `<div>` with bg/border - Becomes shape
33
+ - `<img>` - Images
34
+ - `class="placeholder"` - Reserved space for charts (returns `{ id, x, y, w, h }`)
35
+
36
+ ### Critical Text Rules
37
+
38
+ **ALL text MUST be inside `<p>`, `<h1>`-`<h6>`, `<ul>`, or `<ol>` tags:**
39
+ - ✅ Correct: `<div><p>Text here</p></div>`
40
+ - ❌ Wrong: `<div>Text here</div>` - **Text will NOT appear in PowerPoint**
41
+ - ❌ Wrong: `<span>Text</span>` - **Text will NOT appear in PowerPoint**
42
+ - Text in `<div>` or `<span>` without a text tag will be silently ignored
43
+
44
+ **NEVER use manual bullet symbols (•, -, *, etc.)** - Use `<ul>` or `<ol>` lists instead
45
+
46
+ **ONLY use web-safe fonts that are universally available:**
47
+ - ✅ Web-safe fonts: `Arial`, `Helvetica`, `Times New Roman`, `Georgia`, `Courier New`, `Verdana`, `Tahoma`, `Trebuchet MS`, `Impact`, `Comic Sans MS`
48
+ - ❌ Wrong: `'Segoe UI'`, `'SF Pro'`, `'Roboto'`, custom fonts - **Might cause rendering issues**
49
+
50
+ ### Styling
51
+
52
+ - Use `display: flex` on body to prevent margin collapse from breaking overflow validation
53
+ - Use `margin` for spacing (padding included in size)
54
+ - Inline formatting: Use `<b>`, `<i>`, `<u>` tags OR `<span>` with CSS styles
55
+ - `<span>` supports: `font-weight: bold`, `font-style: italic`, `text-decoration: underline`, `color: #rrggbb`
56
+ - `<span>` does NOT support: `margin`, `padding` (not supported in PowerPoint text runs)
57
+ - Example: `<span style="font-weight: bold; color: #667eea;">Bold blue text</span>`
58
+ - Flexbox works - positions calculated from rendered layout
59
+ - Use hex colors with `#` prefix in CSS
60
+ - **Text alignment**: Use CSS `text-align` (`center`, `right`, etc.) when needed as a hint to PptxGenJS for text formatting if text lengths are slightly off
61
+
62
+ ### Shape Styling (DIV elements only)
63
+
64
+ **IMPORTANT: Backgrounds, borders, and shadows only work on `<div>` elements, NOT on text elements (`<p>`, `<h1>`-`<h6>`, `<ul>`, `<ol>`)**
65
+
66
+ - **Backgrounds**: CSS `background` or `background-color` on `<div>` elements only
67
+ - Example: `<div style="background: #f0f0f0;">` - Creates a shape with background
68
+ - **Borders**: CSS `border` on `<div>` elements converts to PowerPoint shape borders
69
+ - Supports uniform borders: `border: 2px solid #333333`
70
+ - Supports partial borders: `border-left`, `border-right`, `border-top`, `border-bottom` (rendered as line shapes)
71
+ - Example: `<div style="border-left: 8pt solid #E76F51;">`
72
+ - **Border radius**: CSS `border-radius` on `<div>` elements for rounded corners
73
+ - `border-radius: 50%` or higher creates circular shape
74
+ - Percentages <50% calculated relative to shape's smaller dimension
75
+ - Supports px and pt units (e.g., `border-radius: 8pt;`, `border-radius: 12px;`)
76
+ - Example: `<div style="border-radius: 25%;">` on 100x200px box = 25% of 100px = 25px radius
77
+ - **Box shadows**: CSS `box-shadow` on `<div>` elements converts to PowerPoint shadows
78
+ - Supports outer shadows only (inset shadows are ignored to prevent corruption)
79
+ - Example: `<div style="box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);">`
80
+ - Note: Inset/inner shadows are not supported by PowerPoint and will be skipped
81
+
82
+ ### Icons & Gradients
83
+
84
+ - **CRITICAL: Never use CSS gradients (`linear-gradient`, `radial-gradient`)** - They don't convert to PowerPoint
85
+ - **ALWAYS create gradient/icon PNGs FIRST using Sharp, then reference in HTML**
86
+ - For gradients: Rasterize SVG to PNG background images
87
+ - For icons: Rasterize Lucide SVG to PNG images
88
+ - All visual effects must be pre-rendered as raster images before HTML rendering
89
+
90
+ **Rasterizing Icons with Sharp:**
91
+
92
+ ```javascript
93
+ const React = require('react');
94
+ const ReactDOMServer = require('react-dom/server');
95
+ const sharp = require('sharp');
96
+ const { House } = require('lucide-react');
97
+
98
+ async function rasterizeIconPng(IconComponent, color, size = "256", filename) {
99
+ const svgString = ReactDOMServer.renderToStaticMarkup(
100
+ React.createElement(IconComponent, { color: `#${color}`, size: size, strokeWidth: 1.75 })
101
+ );
102
+
103
+ // Convert SVG to PNG using Sharp
104
+ await sharp(Buffer.from(svgString))
105
+ .png()
106
+ .toFile(filename);
107
+
108
+ return filename;
109
+ }
110
+
111
+ // Usage: Rasterize icon before using in HTML
112
+ const iconPath = await rasterizeIconPng(House, "4472c4", "256", "home-icon.png");
113
+ // Then reference in HTML: <img src="home-icon.png" style="width: 40pt; height: 40pt;">
114
+ ```
115
+
116
+ **Rasterizing Gradients with Sharp:**
117
+
118
+ ```javascript
119
+ const sharp = require('sharp');
120
+
121
+ async function createGradientBackground(filename) {
122
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="562.5">
123
+ <defs>
124
+ <linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%">
125
+ <stop offset="0%" style="stop-color:#COLOR1"/>
126
+ <stop offset="100%" style="stop-color:#COLOR2"/>
127
+ </linearGradient>
128
+ </defs>
129
+ <rect width="100%" height="100%" fill="url(#g)"/>
130
+ </svg>`;
131
+
132
+ await sharp(Buffer.from(svg))
133
+ .png()
134
+ .toFile(filename);
135
+
136
+ return filename;
137
+ }
138
+
139
+ // Usage: Create gradient background before HTML
140
+ const bgPath = await createGradientBackground("gradient-bg.png");
141
+ // Then in HTML: <body style="background-image: url('gradient-bg.png');">
142
+ ```
143
+
144
+ ### Example
145
+
146
+ ```html
147
+ <!DOCTYPE html>
148
+ <html>
149
+ <head>
150
+ <style>
151
+ html { background: #ffffff; }
152
+ body {
153
+ width: 720pt; height: 405pt; margin: 0; padding: 0;
154
+ background: #f5f5f5; font-family: Arial, sans-serif;
155
+ display: flex;
156
+ }
157
+ .content { margin: 30pt; padding: 40pt; background: #ffffff; border-radius: 8pt; }
158
+ h1 { color: #2d3748; font-size: 32pt; }
159
+ .box {
160
+ background: #70ad47; padding: 20pt; border: 3px solid #5a8f37;
161
+ border-radius: 12pt; box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.25);
162
+ }
163
+ </style>
164
+ </head>
165
+ <body>
166
+ <div class="content">
167
+ <h1>Recipe Title</h1>
168
+ <ul>
169
+ <li><b>Item:</b> Description</li>
170
+ </ul>
171
+ <p>Text with <b>bold</b>, <i>italic</i>, <u>underline</u>.</p>
172
+ <div id="chart" class="placeholder" style="width: 350pt; height: 200pt;"></div>
173
+
174
+ <!-- Text MUST be in <p> tags -->
175
+ <div class="box">
176
+ <p>5</p>
177
+ </div>
178
+ </div>
179
+ </body>
180
+ </html>
181
+ ```
182
+
183
+ ## Using the html2pptx Library
184
+
185
+ ### Dependencies
186
+
187
+ These libraries have been globally installed and are available to use:
188
+ - `pptxgenjs`
189
+ - `playwright`
190
+ - `sharp`
191
+
192
+ ### Basic Usage
193
+
194
+ ```javascript
195
+ const pptxgen = require('pptxgenjs');
196
+ const html2pptx = require('./html2pptx');
197
+
198
+ const pptx = new pptxgen();
199
+ pptx.layout = 'LAYOUT_16x9'; // Must match HTML body dimensions
200
+
201
+ const { slide, placeholders } = await html2pptx('slide1.html', pptx);
202
+
203
+ // Add chart to placeholder area
204
+ if (placeholders.length > 0) {
205
+ slide.addChart(pptx.charts.LINE, chartData, placeholders[0]);
206
+ }
207
+
208
+ await pptx.writeFile('output.pptx');
209
+ ```
210
+
211
+ ### API Reference
212
+
213
+ #### Function Signature
214
+ ```javascript
215
+ await html2pptx(htmlFile, pres, options)
216
+ ```
217
+
218
+ #### Parameters
219
+ - `htmlFile` (string): Path to HTML file (absolute or relative)
220
+ - `pres` (pptxgen): PptxGenJS presentation instance with layout already set
221
+ - `options` (object, optional):
222
+ - `tmpDir` (string): Temporary directory for generated files (default: `process.env.TMPDIR || '/tmp'`)
223
+ - `slide` (object): Existing slide to reuse (default: creates new slide)
224
+ - `fitToLayout` (boolean): Scale extracted positions and typography to the configured presentation layout when the HTML has the same aspect ratio (default: `false`)
225
+ - `browser` (Playwright Browser): Existing browser instance to reuse across multiple slides (default: launches and closes one browser for the call)
226
+
227
+ #### Returns
228
+ ```javascript
229
+ {
230
+ slide: pptxgenSlide, // The created/updated slide
231
+ placeholders: [ // Array of placeholder positions
232
+ { id: string, x: number, y: number, w: number, h: number },
233
+ ...
234
+ ]
235
+ }
236
+ ```
237
+
238
+ ### Validation
239
+
240
+ The library automatically validates and collects all errors before throwing:
241
+
242
+ 1. **HTML dimensions must match presentation layout** - Reports dimension mismatches
243
+ 2. **Content must not overflow body** - Reports overflow with exact measurements
244
+ 3. **CSS gradients** - Reports unsupported gradient usage
245
+ 4. **Text element styling** - Reports backgrounds/borders/shadows on text elements (only allowed on divs)
246
+
247
+ **All validation errors are collected and reported together** in a single error message, allowing you to fix all issues at once instead of one at a time.
248
+
249
+ ### Working with Placeholders
250
+
251
+ ```javascript
252
+ const { slide, placeholders } = await html2pptx('slide.html', pptx);
253
+
254
+ // Use first placeholder
255
+ slide.addChart(pptx.charts.BAR, data, placeholders[0]);
256
+
257
+ // Find by ID
258
+ const chartArea = placeholders.find(p => p.id === 'chart-area');
259
+ slide.addChart(pptx.charts.LINE, data, chartArea);
260
+ ```
261
+
262
+ ### Complete Example
263
+
264
+ ```javascript
265
+ const pptxgen = require('pptxgenjs');
266
+ const html2pptx = require('./html2pptx');
267
+
268
+ async function createPresentation() {
269
+ const pptx = new pptxgen();
270
+ pptx.layout = 'LAYOUT_16x9';
271
+ pptx.author = 'Your Name';
272
+ pptx.title = 'My Presentation';
273
+
274
+ // Slide 1: Title
275
+ const { slide: slide1 } = await html2pptx('<slides-dir>/title.html', pptx);
276
+
277
+ // Slide 2: Content with chart
278
+ const { slide: slide2, placeholders } = await html2pptx('<slides-dir>/data.html', pptx);
279
+
280
+ const chartData = [{
281
+ name: 'Sales',
282
+ labels: ['Q1', 'Q2', 'Q3', 'Q4'],
283
+ values: [4500, 5500, 6200, 7100]
284
+ }];
285
+
286
+ slide2.addChart(pptx.charts.BAR, chartData, {
287
+ ...placeholders[0],
288
+ showTitle: true,
289
+ title: 'Quarterly Sales',
290
+ showCatAxisTitle: true,
291
+ catAxisTitle: 'Quarter',
292
+ showValAxisTitle: true,
293
+ valAxisTitle: 'Sales ($000s)'
294
+ });
295
+
296
+ // Save
297
+ await pptx.writeFile({ fileName: 'presentation.pptx' });
298
+ console.log('Presentation created successfully!');
299
+ }
300
+
301
+ createPresentation().catch(console.error);
302
+ ```
303
+
304
+ ## Using PptxGenJS
305
+
306
+ After converting HTML to slides with `html2pptx`, you'll use PptxGenJS to add dynamic content like charts, images, and additional elements.
307
+
308
+ ### ⚠️ Critical Rules
309
+
310
+ #### Colors
311
+ - **NEVER use `#` prefix** with hex colors in PptxGenJS - causes file corruption
312
+ - ✅ Correct: `color: "FF0000"`, `fill: { color: "0066CC" }`
313
+ - ❌ Wrong: `color: "#FF0000"` (breaks document)
314
+
315
+ ### Adding Images
316
+
317
+ Always calculate aspect ratios from actual image dimensions:
318
+
319
+ ```javascript
320
+ // Get image dimensions: identify image.png | grep -o '[0-9]* x [0-9]*'
321
+ const imgWidth = 1860, imgHeight = 1519; // From actual file
322
+ const aspectRatio = imgWidth / imgHeight;
323
+
324
+ const h = 3; // Max height
325
+ const w = h * aspectRatio;
326
+ const x = (10 - w) / 2; // Center on 16:9 slide
327
+
328
+ slide.addImage({ path: "chart.png", x, y: 1.5, w, h });
329
+ ```
330
+
331
+ ### Adding Text
332
+
333
+ ```javascript
334
+ // Rich text with formatting
335
+ slide.addText([
336
+ { text: "Bold ", options: { bold: true } },
337
+ { text: "Italic ", options: { italic: true } },
338
+ { text: "Normal" }
339
+ ], {
340
+ x: 1, y: 2, w: 8, h: 1
341
+ });
342
+ ```
343
+
344
+ ### Adding Shapes
345
+
346
+ ```javascript
347
+ // Rectangle
348
+ slide.addShape(pptx.shapes.RECTANGLE, {
349
+ x: 1, y: 1, w: 3, h: 2,
350
+ fill: { color: "4472C4" },
351
+ line: { color: "000000", width: 2 }
352
+ });
353
+
354
+ // Circle
355
+ slide.addShape(pptx.shapes.OVAL, {
356
+ x: 5, y: 1, w: 2, h: 2,
357
+ fill: { color: "ED7D31" }
358
+ });
359
+
360
+ // Rounded rectangle
361
+ slide.addShape(pptx.shapes.ROUNDED_RECTANGLE, {
362
+ x: 1, y: 4, w: 3, h: 1.5,
363
+ fill: { color: "70AD47" },
364
+ rectRadius: 0.2
365
+ });
366
+ ```
367
+
368
+ ### Adding Charts
369
+
370
+ **Required for most charts:** Axis labels using `catAxisTitle` (category) and `valAxisTitle` (value).
371
+
372
+ **Chart Data Format:**
373
+ - Use **single series with all labels** for simple bar/line charts
374
+ - Each series creates a separate legend entry
375
+ - Labels array defines X-axis values
376
+
377
+ **Time Series Data - Choose Correct Granularity:**
378
+ - **< 30 days**: Use daily grouping (e.g., "10-01", "10-02") - avoid monthly aggregation that creates single-point charts
379
+ - **30-365 days**: Use monthly grouping (e.g., "2024-01", "2024-02")
380
+ - **> 365 days**: Use yearly grouping (e.g., "2023", "2024")
381
+ - **Validate**: Charts with only 1 data point likely indicate incorrect aggregation for the time period
382
+
383
+ ```javascript
384
+ const { slide, placeholders } = await html2pptx('slide.html', pptx);
385
+
386
+ // CORRECT: Single series with all labels
387
+ slide.addChart(pptx.charts.BAR, [{
388
+ name: "Sales 2024",
389
+ labels: ["Q1", "Q2", "Q3", "Q4"],
390
+ values: [4500, 5500, 6200, 7100]
391
+ }], {
392
+ ...placeholders[0], // Use placeholder position
393
+ barDir: 'col', // 'col' = vertical bars, 'bar' = horizontal
394
+ showTitle: true,
395
+ title: 'Quarterly Sales',
396
+ showLegend: false, // No legend needed for single series
397
+ // Required axis labels
398
+ showCatAxisTitle: true,
399
+ catAxisTitle: 'Quarter',
400
+ showValAxisTitle: true,
401
+ valAxisTitle: 'Sales ($000s)',
402
+ // Optional: Control scaling (adjust min based on data range for better visualization)
403
+ valAxisMaxVal: 8000,
404
+ valAxisMinVal: 0, // Use 0 for counts/amounts; for clustered data (e.g., 4500-7100), consider starting closer to min value
405
+ valAxisMajorUnit: 2000, // Control y-axis label spacing to prevent crowding
406
+ catAxisLabelRotate: 45, // Rotate labels if crowded
407
+ dataLabelPosition: 'outEnd',
408
+ dataLabelColor: '000000',
409
+ // Use single color for single-series charts
410
+ chartColors: ["4472C4"] // All bars same color
411
+ });
412
+ ```
413
+
414
+ #### Scatter Chart
415
+
416
+ **IMPORTANT**: Scatter chart data format is unusual - first series contains X-axis values, subsequent series contain Y-values:
417
+
418
+ ```javascript
419
+ // Prepare data
420
+ const data1 = [{ x: 10, y: 20 }, { x: 15, y: 25 }, { x: 20, y: 30 }];
421
+ const data2 = [{ x: 12, y: 18 }, { x: 18, y: 22 }];
422
+
423
+ const allXValues = [...data1.map(d => d.x), ...data2.map(d => d.x)];
424
+
425
+ slide.addChart(pptx.charts.SCATTER, [
426
+ { name: 'X-Axis', values: allXValues }, // First series = X values
427
+ { name: 'Series 1', values: data1.map(d => d.y) }, // Y values only
428
+ { name: 'Series 2', values: data2.map(d => d.y) } // Y values only
429
+ ], {
430
+ x: 1, y: 1, w: 8, h: 4,
431
+ lineSize: 0, // 0 = no connecting lines
432
+ lineDataSymbol: 'circle',
433
+ lineDataSymbolSize: 6,
434
+ showCatAxisTitle: true,
435
+ catAxisTitle: 'X Axis',
436
+ showValAxisTitle: true,
437
+ valAxisTitle: 'Y Axis',
438
+ chartColors: ["4472C4", "ED7D31"]
439
+ });
440
+ ```
441
+
442
+ #### Line Chart
443
+
444
+ ```javascript
445
+ slide.addChart(pptx.charts.LINE, [{
446
+ name: "Temperature",
447
+ labels: ["Jan", "Feb", "Mar", "Apr"],
448
+ values: [32, 35, 42, 55]
449
+ }], {
450
+ x: 1, y: 1, w: 8, h: 4,
451
+ lineSize: 4,
452
+ lineSmooth: true,
453
+ // Required axis labels
454
+ showCatAxisTitle: true,
455
+ catAxisTitle: 'Month',
456
+ showValAxisTitle: true,
457
+ valAxisTitle: 'Temperature (°F)',
458
+ // Optional: Y-axis range (set min based on data range for better visualization)
459
+ valAxisMinVal: 0, // For ranges starting at 0 (counts, percentages, etc.)
460
+ valAxisMaxVal: 60,
461
+ valAxisMajorUnit: 20, // Control y-axis label spacing to prevent crowding (e.g., 10, 20, 25)
462
+ // valAxisMinVal: 30, // PREFERRED: For data clustered in a range (e.g., 32-55 or ratings 3-5), start axis closer to min value to show variation
463
+ // Optional: Chart colors
464
+ chartColors: ["4472C4", "ED7D31", "A5A5A5"]
465
+ });
466
+ ```
467
+
468
+ #### Pie Chart (No Axis Labels Required)
469
+
470
+ **CRITICAL**: Pie charts require a **single data series** with all categories in the `labels` array and corresponding values in the `values` array.
471
+
472
+ ```javascript
473
+ slide.addChart(pptx.charts.PIE, [{
474
+ name: "Market Share",
475
+ labels: ["Product A", "Product B", "Other"], // All categories in one array
476
+ values: [35, 45, 20] // All values in one array
477
+ }], {
478
+ x: 2, y: 1, w: 6, h: 4,
479
+ showPercent: true,
480
+ showLegend: true,
481
+ legendPos: 'r', // right
482
+ chartColors: ["4472C4", "ED7D31", "A5A5A5"]
483
+ });
484
+ ```
485
+
486
+ #### Multiple Data Series
487
+
488
+ ```javascript
489
+ slide.addChart(pptx.charts.LINE, [
490
+ {
491
+ name: "Product A",
492
+ labels: ["Q1", "Q2", "Q3", "Q4"],
493
+ values: [10, 20, 30, 40]
494
+ },
495
+ {
496
+ name: "Product B",
497
+ labels: ["Q1", "Q2", "Q3", "Q4"],
498
+ values: [15, 25, 20, 35]
499
+ }
500
+ ], {
501
+ x: 1, y: 1, w: 8, h: 4,
502
+ showCatAxisTitle: true,
503
+ catAxisTitle: 'Quarter',
504
+ showValAxisTitle: true,
505
+ valAxisTitle: 'Revenue ($M)'
506
+ });
507
+ ```
508
+
509
+ ### Chart Colors
510
+
511
+ **CRITICAL**: Use hex colors **without** the `#` prefix - including `#` causes file corruption.
512
+
513
+ **Align chart colors with your chosen design palette**, ensuring sufficient contrast and distinctiveness for data visualization. Adjust colors for:
514
+ - Strong contrast between adjacent series
515
+ - Readability against slide backgrounds
516
+ - Accessibility (avoid red-green only combinations)
517
+
518
+ ```javascript
519
+ // Example: Ocean palette-inspired chart colors (adjusted for contrast)
520
+ const chartColors = ["16A085", "FF6B9D", "2C3E50", "F39C12", "9B59B6"];
521
+
522
+ // Single-series chart: Use one color for all bars/points
523
+ slide.addChart(pptx.charts.BAR, [{
524
+ name: "Sales",
525
+ labels: ["Q1", "Q2", "Q3", "Q4"],
526
+ values: [4500, 5500, 6200, 7100]
527
+ }], {
528
+ ...placeholders[0],
529
+ chartColors: ["16A085"], // All bars same color
530
+ showLegend: false
531
+ });
532
+
533
+ // Multi-series chart: Each series gets a different color
534
+ slide.addChart(pptx.charts.LINE, [
535
+ { name: "Product A", labels: ["Q1", "Q2", "Q3"], values: [10, 20, 30] },
536
+ { name: "Product B", labels: ["Q1", "Q2", "Q3"], values: [15, 25, 20] }
537
+ ], {
538
+ ...placeholders[0],
539
+ chartColors: ["16A085", "FF6B9D"] // One color per series
540
+ });
541
+ ```
542
+
543
+ ### Adding Tables
544
+
545
+ Tables can be added with basic or advanced formatting:
546
+
547
+ #### Basic Table
548
+
549
+ ```javascript
550
+ slide.addTable([
551
+ ["Header 1", "Header 2", "Header 3"],
552
+ ["Row 1, Col 1", "Row 1, Col 2", "Row 1, Col 3"],
553
+ ["Row 2, Col 1", "Row 2, Col 2", "Row 2, Col 3"]
554
+ ], {
555
+ x: 0.5,
556
+ y: 1,
557
+ w: 9,
558
+ h: 3,
559
+ border: { pt: 1, color: "999999" },
560
+ fill: { color: "F1F1F1" }
561
+ });
562
+ ```
563
+
564
+ #### Table with Custom Formatting
565
+
566
+ ```javascript
567
+ const tableData = [
568
+ // Header row with custom styling
569
+ [
570
+ { text: "Product", options: { fill: { color: "4472C4" }, color: "FFFFFF", bold: true } },
571
+ { text: "Revenue", options: { fill: { color: "4472C4" }, color: "FFFFFF", bold: true } },
572
+ { text: "Growth", options: { fill: { color: "4472C4" }, color: "FFFFFF", bold: true } }
573
+ ],
574
+ // Data rows
575
+ ["Product A", "$50M", "+15%"],
576
+ ["Product B", "$35M", "+22%"],
577
+ ["Product C", "$28M", "+8%"]
578
+ ];
579
+
580
+ slide.addTable(tableData, {
581
+ x: 1,
582
+ y: 1.5,
583
+ w: 8,
584
+ h: 3,
585
+ colW: [3, 2.5, 2.5], // Column widths
586
+ rowH: [0.5, 0.6, 0.6, 0.6], // Row heights
587
+ border: { pt: 1, color: "CCCCCC" },
588
+ align: "center",
589
+ valign: "middle",
590
+ fontSize: 14
591
+ });
592
+ ```
593
+
594
+ #### Table with Merged Cells
595
+
596
+ ```javascript
597
+ const mergedTableData = [
598
+ [
599
+ { text: "Q1 Results", options: { colspan: 3, fill: { color: "4472C4" }, color: "FFFFFF", bold: true } }
600
+ ],
601
+ ["Product", "Sales", "Market Share"],
602
+ ["Product A", "$25M", "35%"],
603
+ ["Product B", "$18M", "25%"]
604
+ ];
605
+
606
+ slide.addTable(mergedTableData, {
607
+ x: 1,
608
+ y: 1,
609
+ w: 8,
610
+ h: 2.5,
611
+ colW: [3, 2.5, 2.5],
612
+ border: { pt: 1, color: "DDDDDD" }
613
+ });
614
+ ```
615
+
616
+ ### Table Options
617
+
618
+ Common table options:
619
+ - `x, y, w, h` - Position and size
620
+ - `colW` - Array of column widths (in inches)
621
+ - `rowH` - Array of row heights (in inches)
622
+ - `border` - Border style: `{ pt: 1, color: "999999" }`
623
+ - `fill` - Background color (no # prefix)
624
+ - `align` - Text alignment: "left", "center", "right"
625
+ - `valign` - Vertical alignment: "top", "middle", "bottom"
626
+ - `fontSize` - Text size
627
+ - `autoPage` - Auto-create new slides if content overflows