pptx-glimpse 0.3.0 → 0.3.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/README.md CHANGED
@@ -1,13 +1,24 @@
1
1
  # pptx-glimpse
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/pptx-glimpse)](https://www.npmjs.com/package/pptx-glimpse)
4
+ [![CI](https://github.com/hirokisakabe/pptx-glimpse/actions/workflows/ci.yml/badge.svg)](https://github.com/hirokisakabe/pptx-glimpse/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org/)
4
7
 
5
- A lightweight JavaScript library for rendering PowerPoint (.pptx) files as SVG or PNG in Node.js. No LibreOffice required.
8
+ No LibreOffice required just `npm install`.
6
9
 
7
- **[Try the Demo](https://pptx-glimpse.vercel.app/)** | [npm](https://www.npmjs.com/package/pptx-glimpse)
10
+ A lightweight JavaScript library that renders PowerPoint (.pptx) slides as SVG or PNG in Node.js.
11
+
12
+ **[Try the Demo](https://glimpse.pptx.app/)** | [npm](https://www.npmjs.com/package/pptx-glimpse)
8
13
 
9
14
  ![pptx-glimpse demo](https://raw.githubusercontent.com/hirokisakabe/pptx-glimpse/main/docs/demo.gif)
10
15
 
16
+ _Upload a .pptx file → get SVG/PNG output instantly_
17
+
18
+ | PowerPoint | pptx-glimpse |
19
+ | :------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: |
20
+ | ![PowerPoint](https://raw.githubusercontent.com/hirokisakabe/pptx-glimpse/main/docs/comparison-powerpoint.png) | ![pptx-glimpse](https://raw.githubusercontent.com/hirokisakabe/pptx-glimpse/main/docs/comparison-pptx-glimpse.png) |
21
+
11
22
  ## Motivation
12
23
 
13
24
  pptx-glimpse is designed for two primary use cases:
@@ -21,6 +32,15 @@ pptx-glimpse is designed for two primary use cases:
21
32
  The library focuses on accurately reproducing text, shapes, and spatial layout
22
33
  rather than pixel-perfect rendering of every PowerPoint feature.
23
34
 
35
+ ## Why not LibreOffice?
36
+
37
+ | | LibreOffice | pptx-glimpse |
38
+ | ------------ | -------------------------- | ------------------------------ |
39
+ | Install size | ~500 MB+ | `npm install` (~30 MB) |
40
+ | Docker image | Large base image required | Works in any Node.js image |
41
+ | Startup time | Process spawning overhead | In-process, no spawning |
42
+ | Concurrency | One process per conversion | Async, runs in your event loop |
43
+
24
44
  ## Requirements
25
45
 
26
46
  - **Node.js >= 20**
@@ -58,7 +78,8 @@ Both `convertPptxToSvg` and `convertPptxToPng` accept an optional `ConvertOption
58
78
  const results = await convertPptxToPng(pptx, {
59
79
  slides: [1, 3], // Convert only slides 1 and 3
60
80
  width: 1920, // Output width in pixels (default: 960)
61
- logLevel: "warn", // Warning log level: "off" | "warn" | "error"
81
+ height: 1080, // Output height in pixels (width takes priority if both set)
82
+ logLevel: "warn", // Warning log level: "off" | "warn" | "debug"
62
83
  fontDirs: ["/custom/fonts"], // Additional font directories to search
63
84
  fontMapping: {
64
85
  "Custom Corp Font": "Noto Sans", // Custom font name mapping
@@ -66,6 +87,59 @@ const results = await convertPptxToPng(pptx, {
66
87
  });
67
88
  ```
68
89
 
90
+ ### Advanced Usage
91
+
92
+ <details>
93
+ <summary>Font Utilities</summary>
94
+
95
+ #### Collecting used fonts
96
+
97
+ `collectUsedFonts` parses a PPTX file and returns all font names used across slides — without performing a full render. Useful for pre-checking which fonts need to be installed.
98
+
99
+ ```typescript
100
+ import { collectUsedFonts } from "pptx-glimpse";
101
+
102
+ const fonts = collectUsedFonts(pptx);
103
+ // {
104
+ // theme: { majorFont: "Calibri Light", minorFont: "Calibri", majorFontEa: "...", ... },
105
+ // fonts: ["Arial", "Calibri", "Meiryo"]
106
+ // }
107
+ ```
108
+
109
+ #### Font mapping helpers
110
+
111
+ ```typescript
112
+ import { DEFAULT_FONT_MAPPING, createFontMapping, getMappedFont } from "pptx-glimpse";
113
+
114
+ // Create a custom mapping (merges with defaults, user values take priority)
115
+ const mapping = createFontMapping({ Calibri: "Ubuntu" });
116
+
117
+ // Look up mapped font (case-insensitive)
118
+ getMappedFont("Meiryo", mapping); // "Noto Sans JP"
119
+ getMappedFont("calibri", mapping); // "Ubuntu"
120
+ ```
121
+
122
+ </details>
123
+
124
+ <details>
125
+ <summary>Custom Font Loading</summary>
126
+
127
+ In environments where system fonts are not available, you can build a text measurer from font buffers using `createOpentypeSetupFromBuffers`. This is a low-level utility for advanced use cases.
128
+
129
+ ```typescript
130
+ import { readFileSync } from "fs";
131
+ import { createOpentypeSetupFromBuffers } from "pptx-glimpse";
132
+
133
+ const setup = await createOpentypeSetupFromBuffers([
134
+ { name: "Carlito", data: readFileSync("fonts/Carlito-Regular.ttf") },
135
+ { name: "Noto Sans JP", data: readFileSync("fonts/NotoSansJP-Regular.ttf") },
136
+ ]);
137
+ // setup.measurer — text width measurement
138
+ // setup.fontResolver — text-to-SVG-path conversion
139
+ ```
140
+
141
+ </details>
142
+
69
143
  ## Fonts
70
144
 
71
145
  ### Automatic Font Loading
@@ -111,7 +185,7 @@ const results = await convertPptxToSvg(pptx, {
111
185
 
112
186
  ## Feature Support
113
187
 
114
- Supports conversion of static visual content in PowerPoint. Dynamic elements such as animations and transitions are not supported.
188
+ 136 preset shapes, charts, tables, SmartArt, gradients, shadows, and more covering the most common static PowerPoint content.
115
189
 
116
190
  ### Supported Features
117
191
 
@@ -189,10 +263,10 @@ Supports conversion of static visual content in PowerPoint. Dynamic elements suc
189
263
 
190
264
  #### Charts
191
265
 
192
- | Feature | Details |
193
- | ---------------- | ------------------------------------------------------------------------------------------------------------ |
194
- | Supported charts | Bar chart (vertical/horizontal), line chart, pie chart, scatter plot, area chart, doughnut, bubble, radar |
195
- | Chart elements | Title, legend (position), series (name/values/categories/color), category axis, value axis |
266
+ | Feature | Details |
267
+ | ---------------- | --------------------------------------------------------------------------------------------------------- |
268
+ | Supported charts | Bar chart (vertical/horizontal), line chart, pie chart, scatter plot, area chart, doughnut, bubble, radar |
269
+ | Chart elements | Title, legend (position), series (name/values/categories/color), category axis, value axis |
196
270
 
197
271
  #### SmartArt
198
272
 
@@ -210,24 +284,30 @@ Supports conversion of static visual content in PowerPoint. Dynamic elements suc
210
284
  | Theme | Theme color scheme, theme fonts (majorFont/minorFont), theme font refs |
211
285
  | showMasterSp | Control visibility of master shapes per slide / layout |
212
286
 
213
- ### Unsupported Features
214
-
215
- | Category | Unsupported features |
216
- | -------------- | ---------------------------------------------------------------------------------------------- |
217
- | Fill | Path gradient (rect/shape type) |
218
- | Effects | Reflection, 3D rotation / extrusion, artistic effects |
219
- | Charts | Stock, combo, histogram, box plot, waterfall, treemap, sunburst |
220
- | Chart details | Data labels, axis titles / tick marks / grid lines, error bars, trendlines |
221
- | Text | Individual text effects (shadow/glow), text columns |
222
- | Tables | Table style template application, diagonal borders |
223
- | Shapes | Shape operations (Union/Subtract/Intersect/Fragment) |
224
- | Multimedia | Embedded video / audio |
225
- | Animations | Object animations, slide transitions |
226
- | Slide elements | Slide notes, comments, headers / footers, slide numbers / dates |
227
- | Image formats | EMF/WMF (parsed but not rendered) |
228
- | Other | Macros / VBA, sections, zoom slides |
229
-
230
- ## Test Rendering
287
+ <details>
288
+ <summary>Unsupported Features</summary>
289
+
290
+ | Category | Unsupported features |
291
+ | -------------- | -------------------------------------------------------------------------- |
292
+ | Fill | Path gradient (rect/shape type) |
293
+ | Effects | Reflection, 3D rotation / extrusion, artistic effects |
294
+ | Charts | Stock, combo, histogram, box plot, waterfall, treemap, sunburst |
295
+ | Chart details | Data labels, axis titles / tick marks / grid lines, error bars, trendlines |
296
+ | Text | Individual text effects (shadow/glow), text columns |
297
+ | Tables | Table style template application, diagonal borders |
298
+ | Shapes | Shape operations (Union/Subtract/Intersect/Fragment) |
299
+ | Multimedia | Embedded video / audio |
300
+ | Animations | Object animations, slide transitions |
301
+ | Slide elements | Slide notes, comments, headers / footers, slide numbers / dates |
302
+ | Image formats | EMF/WMF (parsed but not rendered) |
303
+ | Other | Macros / VBA, sections, zoom slides |
304
+
305
+ </details>
306
+
307
+ ## Development
308
+
309
+ <details>
310
+ <summary>Test rendering</summary>
231
311
 
232
312
  You can specify a PPTX file to preview SVG and PNG conversion results.
233
313
 
@@ -243,6 +323,8 @@ npm run render -- presentation.pptx
243
323
  npm run render -- presentation.pptx ./my-output
244
324
  ```
245
325
 
326
+ </details>
327
+
246
328
  ## License
247
329
 
248
330
  MIT