dom-to-pptx 1.0.6 → 1.0.8
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 +16 -0
- package/{Readme.md → README.md} +329 -288
- package/dist/dom-to-pptx.bundle.js +16497 -27916
- package/dist/dom-to-pptx.cjs +1221 -1114
- package/dist/dom-to-pptx.min.js +1221 -1114
- package/dist/dom-to-pptx.mjs +1221 -1114
- package/package.json +1 -1
- package/rollup.config.js +13 -7
- package/src/index.js +755 -657
- package/src/utils.js +488 -479
package/{Readme.md → README.md}
RENAMED
|
@@ -1,288 +1,329 @@
|
|
|
1
|
-
# dom-to-pptx
|
|
2
|
-
|
|
3
|
-
**The High-Fidelity HTML to PowerPoint Converter (v1.0.
|
|
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
|
-
## Features
|
|
10
|
-
|
|
11
|
-
### 🎨 Advanced Visual Fidelity
|
|
12
|
-
|
|
13
|
-
- **Complex Gradients:** Includes a built-in CSS Gradient Parser that converts `linear-gradient` strings (with multiple stops, angles, and transparency) into vector SVGs for perfect rendering. This now also supports `text-fill-color` gradients, falling back to the first color for broad compatibility.
|
|
14
|
-
- **Mathematically Accurate Shadows:** Converts CSS Cartesian shadows (`x`, `y`, `blur`) into PowerPoint's Polar coordinate system (`angle`, `distance`) for 1:1 depth matching.
|
|
15
|
-
- **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.
|
|
16
|
-
- **Soft Edges/Blurs:** Accurately translates CSS `filter: blur()` into PowerPoint's soft-edge effects, preserving visual depth.
|
|
17
|
-
|
|
18
|
-
### 📐 Smart Layout & Typography
|
|
19
|
-
|
|
20
|
-
- **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 (10 x 5.625 inches) with auto-centering.
|
|
21
|
-
- **Rich Text Blocks:** Handles mixed-style text (e.g., **bold** spans inside a normal paragraph) while sanitizing HTML source code whitespace (newlines/tabs) to prevent jagged text alignment.
|
|
22
|
-
- **Font Stack Normalization:** Automatically maps web-only fonts (like `ui-sans-serif`, `system-ui`) to safe system fonts (`Arial`, `Calibri`) to ensure the file opens correctly on any computer.
|
|
23
|
-
- **Text Transformations:** Supports CSS `text-transform: uppercase/lowercase` and `letter-spacing` (converted to PT).
|
|
24
|
-
|
|
25
|
-
### ⚡ Technical Capabilities
|
|
26
|
-
|
|
27
|
-
- **Z-Index Handling:** Respects DOM order for correct layering of elements.
|
|
28
|
-
- **Border Radius Math:** Calculates perfect corner rounding percentages based on element dimensions.
|
|
29
|
-
- **Client-Side:** Runs entirely in the browser. No server required.
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install dom-to-pptx
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Usage
|
|
38
|
-
|
|
39
|
-
This library is intended for use in the browser (React, Vue, Svelte, Vanilla JS, etc.).
|
|
40
|
-
|
|
41
|
-
### 1. Basic Example
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
import { exportToPptx } from 'dom-to-pptx';
|
|
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
|
-
<script src="https://cdn.jsdelivr.net/npm/
|
|
103
|
-
<!--
|
|
104
|
-
<script src="/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### Recommended HTML Structure
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</div>
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
# dom-to-pptx
|
|
2
|
+
|
|
3
|
+
**The High-Fidelity HTML to PowerPoint Converter (v1.0.8).**
|
|
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
|
+
## Features
|
|
10
|
+
|
|
11
|
+
### 🎨 Advanced Visual Fidelity
|
|
12
|
+
|
|
13
|
+
- **Complex Gradients:** Includes a built-in CSS Gradient Parser that converts `linear-gradient` strings (with multiple stops, angles, and transparency) into vector SVGs for perfect rendering. This now also supports `text-fill-color` gradients, falling back to the first color for broad compatibility.
|
|
14
|
+
- **Mathematically Accurate Shadows:** Converts CSS Cartesian shadows (`x`, `y`, `blur`) into PowerPoint's Polar coordinate system (`angle`, `distance`) for 1:1 depth matching.
|
|
15
|
+
- **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.
|
|
16
|
+
- **Soft Edges/Blurs:** Accurately translates CSS `filter: blur()` into PowerPoint's soft-edge effects, preserving visual depth.
|
|
17
|
+
|
|
18
|
+
### 📐 Smart Layout & Typography
|
|
19
|
+
|
|
20
|
+
- **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 (10 x 5.625 inches) with auto-centering.
|
|
21
|
+
- **Rich Text Blocks:** Handles mixed-style text (e.g., **bold** spans inside a normal paragraph) while sanitizing HTML source code whitespace (newlines/tabs) to prevent jagged text alignment.
|
|
22
|
+
- **Font Stack Normalization:** Automatically maps web-only fonts (like `ui-sans-serif`, `system-ui`) to safe system fonts (`Arial`, `Calibri`) to ensure the file opens correctly on any computer.
|
|
23
|
+
- **Text Transformations:** Supports CSS `text-transform: uppercase/lowercase` and `letter-spacing` (converted to PT).
|
|
24
|
+
|
|
25
|
+
### ⚡ Technical Capabilities
|
|
26
|
+
|
|
27
|
+
- **Z-Index Handling:** Respects DOM order for correct layering of elements.
|
|
28
|
+
- **Border Radius Math:** Calculates perfect corner rounding percentages based on element dimensions.
|
|
29
|
+
- **Client-Side:** Runs entirely in the browser. No server required.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install dom-to-pptx
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
This library is intended for use in the browser (React, Vue, Svelte, Vanilla JS, etc.).
|
|
40
|
+
|
|
41
|
+
### 1. Basic Example
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { exportToPptx } from 'dom-to-pptx';
|
|
45
|
+
|
|
46
|
+
// import PptxGenJS from 'pptxgenjs'; // Uncomment and use if needed for your setup
|
|
47
|
+
|
|
48
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
49
|
+
// Pass the CSS selector of the container you want to turn into a slide
|
|
50
|
+
await exportToPptx('#slide-container', {
|
|
51
|
+
fileName: 'slide-presentation.pptx',
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 2. Multi-Slide Example
|
|
57
|
+
|
|
58
|
+
To export multiple HTML elements as separate slides, pass an array of elements or selectors:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import { exportToPptx } from 'dom-to-pptx'; // ESM or CJS import
|
|
62
|
+
|
|
63
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
64
|
+
const slideElements = document.querySelectorAll('.slide');
|
|
65
|
+
await exportToPptx(Array.from(slideElements), {
|
|
66
|
+
fileName: 'multi-slide-presentation.pptx',
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Browser Usage (single-file bundle or legacy setup)
|
|
72
|
+
|
|
73
|
+
You can use `dom-to-pptx` directly in the browser in two ways:
|
|
74
|
+
|
|
75
|
+
- Recommended — Single-file bundle (includes runtime deps):
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- Single script that contains dom-to-pptx + pptxgenjs + html2canvas -->
|
|
79
|
+
<script src="https://cdn.jsdelivr.net/npm/dom-to-pptx@latest/dist/dom-to-pptx.bundle.js"></script>
|
|
80
|
+
<script>
|
|
81
|
+
document.getElementById('export-btn').addEventListener('click', async () => {
|
|
82
|
+
// The library is available globally as `domToPptx`
|
|
83
|
+
await domToPptx.exportToPptx('#slide-container', { fileName: 'slide-presentation.pptx' });
|
|
84
|
+
});
|
|
85
|
+
</script>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
You can load the bundle from a CDN (unpkg/jsdelivr):
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<script src="https://unpkg.com/dom-to-pptx@latest/dist/dom-to-pptx.bundle.js"></script>
|
|
92
|
+
```
|
|
93
|
+
```html
|
|
94
|
+
<script src="https://cdn.jsdelivr.net/npm/dom-to-pptx@latest/dist/dom-to-pptx.bundle.js"></script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
- Legacy — Explicit runtime includes (smaller dom-to-pptx file, you manage deps):
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<!-- Load pptxgenjs first -->
|
|
102
|
+
<script src="https://cdn.jsdelivr.net/npm/pptxgenjs@latest/dist/pptxgen.bundle.js"></script>
|
|
103
|
+
<!-- html2canvas is required by the legacy dom-to-pptx build for backdrop-filter and canvas image processing -->
|
|
104
|
+
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
|
|
105
|
+
<!-- Then load the legacy dom-to-pptx file that expects the above libs -->
|
|
106
|
+
<script src="https://cdn.jsdelivr.net/npm/dom-to-pptx@latest/dist/dom-to-pptx.min.js"></script>
|
|
107
|
+
<script>
|
|
108
|
+
document.getElementById('download-btn').addEventListener('click', async () => {
|
|
109
|
+
await domToPptx.exportToPptx('#slide-container', { fileName: 'slide-presentation.pptx' });
|
|
110
|
+
});
|
|
111
|
+
</script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Notes:
|
|
115
|
+
|
|
116
|
+
- The standalone `dist/dom-to-pptx.bundle.js` includes `pptxgenjs` and `html2canvas`, so you only need one script tag.
|
|
117
|
+
- If you prefer a smaller payload and already have `pptxgenjs` on the page, use the legacy `dist/dom-to-pptx.min.js` and load `pptxgenjs` first.
|
|
118
|
+
|
|
119
|
+
### 4. Recommended HTML Structure
|
|
120
|
+
|
|
121
|
+
### Recommended HTML Structure
|
|
122
|
+
|
|
123
|
+
For the best results, treat your container as a fixed-size canvas. We recommend building your slide at **1920x1080px**. The library will handle the downscaling.
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<!-- Container (16:9 Aspect Ratio) -->
|
|
127
|
+
<!-- The library will capture this background color/gradient automatically -->
|
|
128
|
+
<div
|
|
129
|
+
id="slide-container"
|
|
130
|
+
class="slide w-[1000px] h-[562px] bg-white rounded-xl overflow-hidden relative shadow-2xl shadow-black/50 flex"
|
|
131
|
+
>
|
|
132
|
+
<!-- Left Sidebar -->
|
|
133
|
+
<div
|
|
134
|
+
class="w-1/3 bg-slate-900 relative overflow-hidden flex flex-col p-10 justify-between"
|
|
135
|
+
>
|
|
136
|
+
<!-- Decorative gradients -->
|
|
137
|
+
<div
|
|
138
|
+
class="absolute top-0 left-0 w-full h-full opacity-30 pointer-events-none"
|
|
139
|
+
>
|
|
140
|
+
<div
|
|
141
|
+
class="absolute -top-20 -left-20 w-64 h-64 bg-purple-600 rounded-full blur-3xl mix-blend-screen"
|
|
142
|
+
></div>
|
|
143
|
+
<div
|
|
144
|
+
class="absolute bottom-0 right-0 w-80 h-80 bg-indigo-600 rounded-full blur-3xl mix-blend-screen"
|
|
145
|
+
></div>
|
|
146
|
+
</div>
|
|
147
|
+
<div class="relative z-10">
|
|
148
|
+
<div
|
|
149
|
+
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"
|
|
150
|
+
>
|
|
151
|
+
<span
|
|
152
|
+
class="w-2 h-2 rounded-full bg-green-400 animate-pulse"
|
|
153
|
+
></span>
|
|
154
|
+
<span class="text-xs font-medium text-slate-300 tracking-wider"
|
|
155
|
+
>LIVE DATA</span
|
|
156
|
+
>
|
|
157
|
+
</div>
|
|
158
|
+
<h2 class="text-4xl font-bold text-white leading-tight mb-4">
|
|
159
|
+
Quarterly <br />
|
|
160
|
+
<span
|
|
161
|
+
class="text-transparent bg-clip-text bg-gradient-to-r from-indigo-400 to-cyan-400"
|
|
162
|
+
>Performance</span
|
|
163
|
+
>
|
|
164
|
+
</h2>
|
|
165
|
+
<p class="text-slate-400 leading-relaxed">
|
|
166
|
+
Visualizing the impact of high-fidelity DOM conversion on
|
|
167
|
+
presentation workflows.
|
|
168
|
+
</p>
|
|
169
|
+
</div>
|
|
170
|
+
<!-- Feature List (Flexbox/Grid test) -->
|
|
171
|
+
<div class="relative z-10 space-y-4">
|
|
172
|
+
<div
|
|
173
|
+
class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5"
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
class="w-8 h-8 rounded-full bg-indigo-500/20 flex items-center justify-center text-indigo-400 font-bold"
|
|
177
|
+
>
|
|
178
|
+
1
|
|
179
|
+
</div>
|
|
180
|
+
<div class="text-sm text-slate-300">Pixel-perfect Shadows</div>
|
|
181
|
+
</div>
|
|
182
|
+
<div
|
|
183
|
+
class="flex items-center gap-3 p-3 rounded-lg bg-white/5 border border-white/5"
|
|
184
|
+
>
|
|
185
|
+
<div
|
|
186
|
+
class="w-8 h-8 rounded-full bg-purple-500/20 flex items-center justify-center text-purple-400 font-bold"
|
|
187
|
+
>
|
|
188
|
+
2
|
|
189
|
+
</div>
|
|
190
|
+
<div class="text-sm text-slate-300">Complex Gradients</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<!-- Right Content -->
|
|
195
|
+
<div class="w-2/3 bg-slate-50 p-10 relative">
|
|
196
|
+
<!-- Header -->
|
|
197
|
+
<div class="flex justify-between items-start mb-10">
|
|
198
|
+
<div>
|
|
199
|
+
<h3 class="text-slate-800 font-bold text-xl">
|
|
200
|
+
Revenue Breakdown
|
|
201
|
+
</h3>
|
|
202
|
+
<p class="text-slate-500 text-sm">Fiscal Year 2024</p>
|
|
203
|
+
</div>
|
|
204
|
+
<div class="flex -space-x-2">
|
|
205
|
+
<!-- Rounded Images Test (CORS friendly) -->
|
|
206
|
+
<img
|
|
207
|
+
class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
|
|
208
|
+
src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&w=64&h=64"
|
|
209
|
+
alt="User 1"
|
|
210
|
+
/>
|
|
211
|
+
<img
|
|
212
|
+
class="w-10 h-10 rounded-full border-2 border-white object-cover shadow-md"
|
|
213
|
+
src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?auto=format&fit=crop&w=64&h=64"
|
|
214
|
+
alt="User 2"
|
|
215
|
+
/>
|
|
216
|
+
<div
|
|
217
|
+
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"
|
|
218
|
+
>
|
|
219
|
+
+5
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<!-- Grid Layout Test -->
|
|
224
|
+
<div class="grid grid-cols-2 gap-6 mb-8">
|
|
225
|
+
<!-- Card 1: Gradient & Shadow -->
|
|
226
|
+
<div
|
|
227
|
+
class="bg-white p-5 rounded-xl complex-shadow border border-slate-100 relative overflow-hidden group"
|
|
228
|
+
>
|
|
229
|
+
<div class="relative z-10">
|
|
230
|
+
<p
|
|
231
|
+
class="text-xs font-bold text-indigo-500 uppercase tracking-wider mb-1"
|
|
232
|
+
>
|
|
233
|
+
Total Sales
|
|
234
|
+
</p>
|
|
235
|
+
<h4 class="text-3xl font-bold text-slate-800">$124,500</h4>
|
|
236
|
+
<div
|
|
237
|
+
class="mt-3 flex items-center text-xs font-semibold text-green-600"
|
|
238
|
+
>
|
|
239
|
+
<svg
|
|
240
|
+
class="w-3 h-3 mr-1"
|
|
241
|
+
fill="none"
|
|
242
|
+
stroke="currentColor"
|
|
243
|
+
viewBox="0 0 24 24"
|
|
244
|
+
>
|
|
245
|
+
<path
|
|
246
|
+
stroke-linecap="round"
|
|
247
|
+
stroke-linejoin="round"
|
|
248
|
+
stroke-width="2"
|
|
249
|
+
d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"
|
|
250
|
+
></path>
|
|
251
|
+
</svg>
|
|
252
|
+
<span>+14.5%</span>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
<!-- Card 2: Gradient Border/Background -->
|
|
257
|
+
<div
|
|
258
|
+
class="p-5 rounded-xl shadow-lg text-white relative overflow-hidden"
|
|
259
|
+
style="
|
|
260
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
261
|
+
"
|
|
262
|
+
>
|
|
263
|
+
<p
|
|
264
|
+
class="text-xs font-bold text-white/80 uppercase tracking-wider mb-1"
|
|
265
|
+
>
|
|
266
|
+
Active Users
|
|
267
|
+
</p>
|
|
268
|
+
<h4 class="text-3xl font-bold text-white">45.2k</h4>
|
|
269
|
+
<div class="mt-3 w-full bg-black/20 rounded-full h-1.5">
|
|
270
|
+
<div
|
|
271
|
+
class="bg-white/90 h-1.5 rounded-full"
|
|
272
|
+
style="width: 70%"
|
|
273
|
+
></div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
<!-- Complex Typography & Layout -->
|
|
278
|
+
<div class="bg-indigo-50/50 rounded-xl p-6 border border-indigo-100">
|
|
279
|
+
<h5 class="font-bold text-indigo-900 mb-3">Analysis Summary</h5>
|
|
280
|
+
<p class="text-indigo-800/80 text-sm leading-relaxed">
|
|
281
|
+
The
|
|
282
|
+
<span class="font-bold text-indigo-600">Q3 projection</span>
|
|
283
|
+
exceeds expectations due to the new
|
|
284
|
+
<span class="italic">optimization algorithm</span>. We observed a <strong class="text-indigo-700">240% increase</strong>
|
|
285
|
+
in processing speed across all nodes.
|
|
286
|
+
</p>
|
|
287
|
+
</div>
|
|
288
|
+
<!-- Floating Badge (Absolute positioning test) -->
|
|
289
|
+
<div
|
|
290
|
+
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"
|
|
291
|
+
>
|
|
292
|
+
<div class="w-2 h-2 rounded-full bg-red-500"></div>
|
|
293
|
+
<span class="text-xs font-bold text-slate-600 uppercase"
|
|
294
|
+
>Confidential</span
|
|
295
|
+
>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## API
|
|
302
|
+
|
|
303
|
+
### `exportToPptx(elementOrSelector, options)`
|
|
304
|
+
|
|
305
|
+
| Parameter | Type | Description |
|
|
306
|
+
| :------------------ | :---------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
|
|
307
|
+
| `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. |
|
|
308
|
+
| `options` | `object` | Configuration object. |
|
|
309
|
+
|
|
310
|
+
**Options Object:**
|
|
311
|
+
|
|
312
|
+
| Key | Type | Default | Description |
|
|
313
|
+
| :---------------- | :------- | :------------- | :-------------------------------------------- |
|
|
314
|
+
| `fileName` | `string` | `"slide.pptx"` | The name of the downloaded file. |
|
|
315
|
+
| `backgroundColor` | `string` | `null` | Force a background color for the slide (hex). |
|
|
316
|
+
|
|
317
|
+
## Important Notes
|
|
318
|
+
|
|
319
|
+
1. **CORS Images:** Because this library uses HTML5 Canvas to process rounded images, any external images must be served with `Access-Control-Allow-Origin: *` headers. If an image is "tainted" (CORS blocked), the browser will refuse to read its data, and it may appear blank in the PPTX.
|
|
320
|
+
2. **Layout System:** The library does not "read" Flexbox or Grid definitions directly. Instead, it lets the browser render the layout, measures the final `x, y, width, height` (BoundingBox) of every element, and places them absolutely on the slide. This ensures 100% visual accuracy regardless of the layout method used.
|
|
321
|
+
3. **Fonts:** PPTX files use the fonts installed on the viewer's OS. If you use a web font like "Inter", and the user doesn't have it installed, PowerPoint will fallback to Arial.
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT © [Atharva Dharmendra Jagtap](https://github.com/atharva9167j) and `dom-to-pptx` contributors.
|
|
326
|
+
|
|
327
|
+
## Acknowledgements
|
|
328
|
+
|
|
329
|
+
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.
|