dom-to-pptx 1.1.0 → 1.1.1
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.
- package/CHANGELOG.md +12 -2
- package/README.md +295 -323
- package/dist/dom-to-pptx.bundle.js +247 -95
- package/dist/dom-to-pptx.cjs +247 -95
- package/dist/dom-to-pptx.cjs.map +1 -1
- package/dist/dom-to-pptx.mjs +247 -95
- package/dist/dom-to-pptx.mjs.map +1 -1
- package/package.json +83 -83
- package/rollup.config.js +9 -14
- package/src/font-embedder.js +163 -159
- package/src/font-utils.js +32 -35
- package/src/image-processor.js +58 -19
- package/src/index.js +971 -905
- package/src/utils.js +711 -674
- package/dist/dom-to-pptx.min.js +0 -64284
package/README.md
CHANGED
|
@@ -1,323 +1,295 @@
|
|
|
1
|
-
# dom-to-pptx
|
|
2
|
-
|
|
3
|
-
**The High-Fidelity HTML to PowerPoint Converter (v1.1.
|
|
4
|
-
|
|
5
|
-
Most HTML-to-PPTX libraries fail when faced with modern web design. They break on gradients, misalign text, ignore rounded corners, or simply take a screenshot (which isn't editable).
|
|
6
|
-
|
|
7
|
-
**dom-to-pptx** is different. It is a **Coordinate Scraper & Style Engine** that traverses your DOM, calculates the exact computed styles of every element (Flexbox/Grid positions, complex gradients, shadows), and mathematically maps them to native PowerPoint shapes and text boxes. The result is a fully editable, vector-sharp presentation that looks exactly like your web view.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
###
|
|
16
|
-
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<div
|
|
131
|
-
class="absolute
|
|
132
|
-
></div>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
<span class="
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
<div
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
class="
|
|
171
|
-
>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
class="
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
**Options Object:**
|
|
298
|
-
|
|
299
|
-
| Key | Type | Default | Description |
|
|
300
|
-
| :--------------- | :-------- | :------------- | :-------------------------------------------- |
|
|
301
|
-
| `fileName` | `string` | `"export.pptx"` | The name of the downloaded file. |
|
|
302
|
-
| `autoEmbedFonts` | `boolean` | `true` | Automatically detect and embed used fonts. |
|
|
303
|
-
| `fonts` | `Array` | `[]` | Manual array of font objects: `{ name, url }`. |
|
|
304
|
-
|
|
305
|
-
## Important Notes
|
|
306
|
-
|
|
307
|
-
1. **Fonts & CORS:**
|
|
308
|
-
* **Automatic Embedding:** Works perfectly for local fonts and external fonts served with correct CORS headers.
|
|
309
|
-
* **Google Fonts:** For auto-detection to work with Google Fonts, you must add `crossorigin="anonymous"` to your link tag:
|
|
310
|
-
`<link href="https://fonts.googleapis.com/..." rel="stylesheet" crossorigin="anonymous">`
|
|
311
|
-
* If a font cannot be accessed due to CORS, the library will log a warning and proceed without embedding it (PowerPoint will fallback to Arial).
|
|
312
|
-
|
|
313
|
-
2. **Layout System:** The library does not "read" Flexbox or Grid definitions directly. It measures the final `x, y, width, height` of every element relative to the slide root and places them absolutely. This ensures 100% visual accuracy regardless of the CSS layout method used.
|
|
314
|
-
|
|
315
|
-
3. **CORS Images:** External images (`<img>` tags) must also be served with `Access-Control-Allow-Origin: *` headers to be processed by the rounding/masking engine.
|
|
316
|
-
|
|
317
|
-
## License
|
|
318
|
-
|
|
319
|
-
MIT © [Atharva Dharmendra Jagtap](https://github.com/atharva9167j) and `dom-to-pptx` contributors.
|
|
320
|
-
|
|
321
|
-
## Acknowledgements
|
|
322
|
-
|
|
323
|
-
This project is built on top of [PptxGenJS](https://github.com/gitbrent/PptxGenJS). Huge thanks to the PptxGenJS maintainers and all contributors — dom-to-pptx leverages and extends their excellent work on PPTX generation.
|
|
1
|
+
# dom-to-pptx
|
|
2
|
+
|
|
3
|
+
**The High-Fidelity HTML to PowerPoint Converter (v1.1.1)**
|
|
4
|
+
|
|
5
|
+
Most HTML-to-PPTX libraries fail when faced with modern web design. They break on gradients, misalign text, ignore rounded corners, or simply take a screenshot (which isn't editable).
|
|
6
|
+
|
|
7
|
+
**dom-to-pptx** is different. It is a **Coordinate Scraper & Style Engine** that traverses your DOM, calculates the exact computed styles of every element (Flexbox/Grid positions, complex gradients, shadows), and mathematically maps them to native PowerPoint shapes and text boxes. The result is a fully editable, vector-sharp presentation that looks exactly like your web view.
|
|
8
|
+
|
|
9
|
+
### 🛠️ Fixes in v1.1.1
|
|
10
|
+
|
|
11
|
+
- Fix list rendering, shape positioning, and text wrapping issues.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### 🚀 New in v1.1.0
|
|
16
|
+
|
|
17
|
+
- **Smart Font Embedding:** The library **automatically detects** the fonts used in your HTML, finds their URLs in your CSS, and embeds them into the PPTX. Your slides will look identical on any computer, even if the user doesn't have the fonts installed.
|
|
18
|
+
- **Enhanced Icon Support:** Flawless rendering of FontAwesome, Material Icons, and SVG-based icon libraries (including gradient text icons).
|
|
19
|
+
|
|
20
|
+
### 🎨 Advanced Visual Fidelity
|
|
21
|
+
|
|
22
|
+
- **Complex Gradients:** Includes a built-in CSS Gradient Parser that converts `linear-gradient` strings (with multiple stops, specific angles like `45deg`, and transparency) into vector SVGs.
|
|
23
|
+
- **Mathematically Accurate Shadows:** Converts CSS Cartesian shadows (`x`, `y`, `blur`) into PowerPoint's Polar coordinate system (`angle`, `distance`) for 1:1 depth matching.
|
|
24
|
+
- **Anti-Halo Image Processing:** Uses off-screen HTML5 Canvas with `source-in` composite masking to render rounded images without the ugly white "halo" artifacts found in other libraries.
|
|
25
|
+
- **Soft Edges/Blurs:** Accurately translates CSS `filter: blur()` into PowerPoint's soft-edge effects, preserving visual depth.
|
|
26
|
+
|
|
27
|
+
### 📐 Smart Layout & Typography
|
|
28
|
+
|
|
29
|
+
- **Auto-Scaling Engine:** Build your slide in HTML at **1920x1080** (or any aspect ratio). The library automatically calculates the scaling factor to fit it perfectly into a standard 16:9 PowerPoint slide.
|
|
30
|
+
- **Rich Text Blocks:** Handles mixed-style text (e.g., **bold** spans inside a normal paragraph).
|
|
31
|
+
- **Text Transformations:** Supports CSS `text-transform: uppercase/lowercase` and `letter-spacing`.
|
|
32
|
+
|
|
33
|
+
### ⚡ Technical Capabilities
|
|
34
|
+
|
|
35
|
+
- **Z-Index Handling:** Respects DOM order for correct layering of elements.
|
|
36
|
+
- **Border Radius Math:** Calculates perfect corner rounding percentages based on element dimensions.
|
|
37
|
+
- **Client-Side:** Runs entirely in the browser. No server required.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install dom-to-pptx
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
This library is intended for use in the browser (React, Vue, Svelte, Vanilla JS, etc.).
|
|
48
|
+
|
|
49
|
+
### 1. Basic Example (Auto-Font Embedding)
|
|
50
|
+
|
|
51
|
+
By default, `dom-to-pptx` attempts to automatically find and embed your web fonts.
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import { exportToPptx } from 'dom-to-pptx';
|
|
55
|
+
|
|
56
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
57
|
+
// Pass the CSS selector of the container
|
|
58
|
+
await exportToPptx('#slide-container', {
|
|
59
|
+
fileName: 'slide-presentation.pptx',
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. Manual Font Configuration (Optional)
|
|
65
|
+
|
|
66
|
+
If you are using external fonts (like Google Fonts) that are hosted on a server without CORS headers, automatic detection might fail. In that case, you can explicitly pass the font URLs:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { exportToPptx } from 'dom-to-pptx';
|
|
70
|
+
|
|
71
|
+
await exportToPptx('#slide-container', {
|
|
72
|
+
fileName: 'report.pptx',
|
|
73
|
+
// Optional: Only needed if auto-detection fails due to CORS
|
|
74
|
+
fonts: [
|
|
75
|
+
{
|
|
76
|
+
name: 'Roboto',
|
|
77
|
+
url: 'https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxK.woff2',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Multi-Slide Example
|
|
84
|
+
|
|
85
|
+
To export multiple HTML elements as separate slides, pass an array of elements or selectors:
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
import { exportToPptx } from 'dom-to-pptx';
|
|
89
|
+
|
|
90
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
91
|
+
const slideElements = document.querySelectorAll('.slide');
|
|
92
|
+
await exportToPptx(Array.from(slideElements), {
|
|
93
|
+
fileName: 'multi-slide-presentation.pptx',
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. Browser Usage (Script Tags)
|
|
99
|
+
|
|
100
|
+
You can use `dom-to-pptx` directly via CDN. The bundle includes all dependencies.
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<script src="https://cdn.jsdelivr.net/npm/dom-to-pptx@latest/dist/dom-to-pptx.bundle.js"></script>
|
|
104
|
+
|
|
105
|
+
<script>
|
|
106
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
107
|
+
// The library is available globally as `domToPptx`
|
|
108
|
+
await domToPptx.exportToPptx('#slide-container', {
|
|
109
|
+
fileName: 'slide.pptx',
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
</script>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Recommended HTML Structure
|
|
116
|
+
|
|
117
|
+
We recommend building your slide container at **1920x1080px**. The library will handle the downscaling to fit the PowerPoint slide (16:9).
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<!-- Container (16:9 Aspect Ratio) -->
|
|
121
|
+
<!-- The library will capture this background color/gradient automatically -->
|
|
122
|
+
<div
|
|
123
|
+
id="slide-container"
|
|
124
|
+
class="slide w-[1000px] h-[562px] bg-white rounded-xl overflow-hidden relative shadow-2xl shadow-black/50 flex"
|
|
125
|
+
>
|
|
126
|
+
<!-- Left Sidebar -->
|
|
127
|
+
<div class="w-1/3 bg-slate-900 relative overflow-hidden flex flex-col p-10 justify-between">
|
|
128
|
+
<!-- Decorative gradients -->
|
|
129
|
+
<div class="absolute top-0 left-0 w-full h-full opacity-30 pointer-events-none">
|
|
130
|
+
<div
|
|
131
|
+
class="absolute -top-20 -left-20 w-64 h-64 bg-purple-600 rounded-full blur-3xl mix-blend-screen"
|
|
132
|
+
></div>
|
|
133
|
+
<div
|
|
134
|
+
class="absolute bottom-0 right-0 w-80 h-80 bg-indigo-600 rounded-full blur-3xl mix-blend-screen"
|
|
135
|
+
></div>
|
|
136
|
+
</div>
|
|
137
|
+
<div class="relative z-10">
|
|
138
|
+
<div
|
|
139
|
+
class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/10 border border-white/10 backdrop-blur-md mb-6"
|
|
140
|
+
>
|
|
141
|
+
<span class="w-2 h-2 rounded-full bg-green-400 animate-pulse"></span>
|
|
142
|
+
<span class="text-xs font-medium text-slate-300 tracking-wider">LIVE DATA</span>
|
|
143
|
+
</div>
|
|
144
|
+
<h2 class="text-4xl font-bold text-white leading-tight mb-4">
|
|
145
|
+
Quarterly <br />
|
|
146
|
+
<span class="text-transparent bg-clip-text bg-gradient-to-r from-indigo-400 to-cyan-400"
|
|
147
|
+
>Performance</span
|
|
148
|
+
>
|
|
149
|
+
</h2>
|
|
150
|
+
<p class="text-slate-400 leading-relaxed">
|
|
151
|
+
Visualizing the impact of high-fidelity DOM conversion on presentation workflows.
|
|
152
|
+
</p>
|
|
153
|
+
</div>
|
|
154
|
+
<!-- Feature List (Flexbox/Grid test) -->
|
|
155
|
+
<div class="relative z-10 space-y-4">
|
|
156
|
+
<div class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5">
|
|
157
|
+
<div
|
|
158
|
+
class="w-8 h-8 rounded-full bg-indigo-500/20 flex items-center justify-center text-indigo-400 font-bold"
|
|
159
|
+
>
|
|
160
|
+
1
|
|
161
|
+
</div>
|
|
162
|
+
<div class="text-sm text-slate-300">Pixel-perfect Shadows</div>
|
|
163
|
+
</div>
|
|
164
|
+
<div class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5">
|
|
165
|
+
<div
|
|
166
|
+
class="w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center text-purple-400 font-bold"
|
|
167
|
+
>
|
|
168
|
+
2
|
|
169
|
+
</div>
|
|
170
|
+
<div class="text-sm text-slate-300">Complex Gradients</div>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
<!-- Right Content -->
|
|
175
|
+
<div class="w-2/3 bg-slate-50 p-10 relative">
|
|
176
|
+
<!-- Header -->
|
|
177
|
+
<div class="flex justify-between items-start mb-10">
|
|
178
|
+
<div>
|
|
179
|
+
<h3 class="text-slate-800 font-bold text-xl">Revenue Breakdown</h3>
|
|
180
|
+
<p class="text-slate-500 text-sm">Fiscal Year 2024</p>
|
|
181
|
+
</div>
|
|
182
|
+
<div class="flex -space-x-2">
|
|
183
|
+
<!-- Rounded Images Test (CORS friendly) -->
|
|
184
|
+
<img
|
|
185
|
+
class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
|
|
186
|
+
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&w=64&h=64"
|
|
187
|
+
alt="User 1"
|
|
188
|
+
/>
|
|
189
|
+
<img
|
|
190
|
+
class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
|
|
191
|
+
src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?auto=format&fit=crop&w=64&h=64"
|
|
192
|
+
alt="User 2"
|
|
193
|
+
/>
|
|
194
|
+
<div
|
|
195
|
+
class="w-10 h-10 rounded-full border-2 border-white bg-slate-200 flex items-center justify-center text-xs font-bold text-slate-500 shadow-md"
|
|
196
|
+
>
|
|
197
|
+
+5
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
<!-- Grid Layout Test -->
|
|
202
|
+
<div class="grid grid-cols-2 gap-6 mb-8">
|
|
203
|
+
<!-- Card 1: Gradient & Shadow -->
|
|
204
|
+
<div
|
|
205
|
+
class="bg-white p-5 rounded-xl complex-shadow border border-slate-100 relative overflow-hidden group"
|
|
206
|
+
>
|
|
207
|
+
<div class="relative z-10">
|
|
208
|
+
<p class="text-xs font-bold text-indigo-500 uppercase tracking-wider mb-1">Total Sales</p>
|
|
209
|
+
<h4 class="text-3xl font-bold text-slate-800">$124,500</h4>
|
|
210
|
+
<div class="mt-3 flex items-center text-xs font-semibold text-green-600">
|
|
211
|
+
<svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
212
|
+
<path
|
|
213
|
+
stroke-linecap="round"
|
|
214
|
+
stroke-linejoin="round"
|
|
215
|
+
stroke-width="2"
|
|
216
|
+
d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"
|
|
217
|
+
></path>
|
|
218
|
+
</svg>
|
|
219
|
+
<span>+14.5%</span>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<!-- Card 2: Gradient Border/Background -->
|
|
224
|
+
<div
|
|
225
|
+
class="p-5 rounded-xl shadow-lg text-white relative overflow-hidden"
|
|
226
|
+
style="
|
|
227
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
228
|
+
"
|
|
229
|
+
>
|
|
230
|
+
<p class="text-xs font-bold text-white/80 uppercase tracking-wider mb-1">Active Users</p>
|
|
231
|
+
<h4 class="text-3xl font-bold text-white">45.2k</h4>
|
|
232
|
+
<div class="mt-3 w-full bg-black/20 rounded-full h-1.5">
|
|
233
|
+
<div class="bg-white/90 h-1.5 rounded-full" style="width: 70%"></div>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
<!-- Complex Typography & Layout -->
|
|
238
|
+
<div class="bg-indigo-50/50 rounded-xl p-6 border border-indigo-100">
|
|
239
|
+
<h5 class="font-bold text-indigo-900 mb-3">Analysis Summary</h5>
|
|
240
|
+
<p class="text-indigo-800/80 text-sm leading-relaxed">
|
|
241
|
+
The
|
|
242
|
+
<span class="font-bold text-indigo-600">Q3 projection</span>
|
|
243
|
+
exceeds expectations due to the new
|
|
244
|
+
<span class="italic">optimization algorithm</span>. We observed a
|
|
245
|
+
<strong class="text-indigo-700">240% increase</strong>
|
|
246
|
+
in processing speed across all nodes.
|
|
247
|
+
</p>
|
|
248
|
+
</div>
|
|
249
|
+
<!-- Floating Badge (Absolute positioning test) -->
|
|
250
|
+
<div
|
|
251
|
+
class="absolute bottom-6 right-6 bg-white/90 backdrop-blur px-4 py-2 rounded-lg shadow-lg border border-slate-200 flex items-center gap-2"
|
|
252
|
+
>
|
|
253
|
+
<div class="w-2 h-2 rounded-full bg-red-500"></div>
|
|
254
|
+
<span class="text-xs font-bold text-slate-600 uppercase">Confidential</span>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## API
|
|
261
|
+
|
|
262
|
+
### `exportToPptx(elementOrSelector, options)`
|
|
263
|
+
|
|
264
|
+
| Parameter | Type | Description |
|
|
265
|
+
| :------------------ | :---------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
|
|
266
|
+
| `elementOrSelector` | `string` \| `HTMLElement` \| `Array<string \| HTMLElement>` | The DOM node(s) or ID selector(s) to convert. Can be a single element/selector or an array for multi-slide export. |
|
|
267
|
+
| `options` | `object` | Configuration object. |
|
|
268
|
+
|
|
269
|
+
**Options Object:**
|
|
270
|
+
|
|
271
|
+
| Key | Type | Default | Description |
|
|
272
|
+
| :--------------- | :-------- | :-------------- | :--------------------------------------------- |
|
|
273
|
+
| `fileName` | `string` | `"export.pptx"` | The name of the downloaded file. |
|
|
274
|
+
| `autoEmbedFonts` | `boolean` | `true` | Automatically detect and embed used fonts. |
|
|
275
|
+
| `fonts` | `Array` | `[]` | Manual array of font objects: `{ name, url }`. |
|
|
276
|
+
|
|
277
|
+
## Important Notes
|
|
278
|
+
|
|
279
|
+
1. **Fonts & CORS:**
|
|
280
|
+
- **Automatic Embedding:** Works perfectly for local fonts and external fonts served with correct CORS headers.
|
|
281
|
+
- **Google Fonts:** For auto-detection to work with Google Fonts, you must add `crossorigin="anonymous"` to your link tag:
|
|
282
|
+
`<link href="https://fonts.googleapis.com/..." rel="stylesheet" crossorigin="anonymous">`
|
|
283
|
+
- If a font cannot be accessed due to CORS, the library will log a warning and proceed without embedding it (PowerPoint will fallback to Arial).
|
|
284
|
+
|
|
285
|
+
2. **Layout System:** The library does not "read" Flexbox or Grid definitions directly. It measures the final `x, y, width, height` of every element relative to the slide root and places them absolutely. This ensures 100% visual accuracy regardless of the CSS layout method used.
|
|
286
|
+
|
|
287
|
+
3. **CORS Images:** External images (`<img>` tags) must also be served with `Access-Control-Allow-Origin: *` headers to be processed by the rounding/masking engine.
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
MIT © [Atharva Dharmendra Jagtap](https://github.com/atharva9167j) and `dom-to-pptx` contributors.
|
|
292
|
+
|
|
293
|
+
## Acknowledgements
|
|
294
|
+
|
|
295
|
+
This project is built on top of [PptxGenJS](https://github.com/gitbrent/PptxGenJS). Huge thanks to the PptxGenJS maintainers and all contributors — dom-to-pptx leverages and extends their excellent work on PPTX generation.
|