pptx-glimpse 0.1.2 → 0.1.3

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
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/pptx-glimpse)](https://www.npmjs.com/package/pptx-glimpse)
4
4
 
5
- A TypeScript library to render PPTX slides as SVG / PNG.
5
+ A Node.js library to render PPTX as SVG / PNG.
6
6
 
7
- [Demo](https://hirokisakabe.github.io/pptx-glimpse/) | [npm](https://www.npmjs.com/package/pptx-glimpse)
7
+ [Demo](https://pptx-glimpse.vercel.app/) | [npm](https://www.npmjs.com/package/pptx-glimpse)
8
8
 
9
9
  ## Motivation
10
10
 
@@ -21,8 +21,7 @@ rather than pixel-perfect rendering of every PowerPoint feature.
21
21
 
22
22
  ## Requirements
23
23
 
24
- - **Node.js >= 20** (does not work in browser environments)
25
- - Requires a platform supported by [sharp](https://sharp.pixelplumbing.com/), which is used for PNG conversion
24
+ - **Node.js >= 20**
26
25
 
27
26
  ## Installation
28
27
 
@@ -33,7 +32,7 @@ npm install pptx-glimpse
33
32
  ## Usage
34
33
 
35
34
  ```typescript
36
- import { readFileSync } from "fs";
35
+ import { readFileSync, writeFileSync } from "fs";
37
36
  import { convertPptxToSvg, convertPptxToPng } from "pptx-glimpse";
38
37
 
39
38
  const pptx = readFileSync("presentation.pptx");
@@ -45,6 +44,67 @@ const svgResults = await convertPptxToSvg(pptx);
45
44
  // Convert to PNG
46
45
  const pngResults = await convertPptxToPng(pptx);
47
46
  // [{ slideNumber: 1, png: Buffer, width: 960, height: 540 }, ...]
47
+
48
+ writeFileSync("slide1.png", pngResults[0].png);
49
+ ```
50
+
51
+ ### Options
52
+
53
+ Both `convertPptxToSvg` and `convertPptxToPng` accept an optional `ConvertOptions` object.
54
+
55
+ ```typescript
56
+ const results = await convertPptxToPng(pptx, {
57
+ slides: [1, 3], // Convert only slides 1 and 3
58
+ width: 1920, // Output width in pixels (default: 960)
59
+ logLevel: "warn", // Warning log level: "off" | "warn" | "error"
60
+ fontDirs: ["/custom/fonts"], // Additional font directories to search
61
+ fontMapping: {
62
+ "Custom Corp Font": "Noto Sans", // Custom font name mapping
63
+ },
64
+ });
65
+ ```
66
+
67
+ ## Fonts
68
+
69
+ ### Automatic Font Loading
70
+
71
+ pptx-glimpse automatically scans system font directories and loads fonts using [opentype.js](https://opentype.js.org/). Text in SVG output is converted to `<path>` elements, ensuring consistent rendering regardless of the environment.
72
+
73
+ Default system font directories:
74
+
75
+ | OS | Directories |
76
+ | ------- | ------------------------------------------------------------ |
77
+ | Linux | `/usr/share/fonts`, `/usr/local/share/fonts` |
78
+ | macOS | `/System/Library/Fonts`, `/Library/Fonts`, `~/Library/Fonts` |
79
+ | Windows | `C:\Windows\Fonts` |
80
+
81
+ Use the `fontDirs` option to add custom font directories.
82
+
83
+ ### Font Mapping
84
+
85
+ PPTX files often reference proprietary fonts (e.g., Calibri, Meiryo). pptx-glimpse maps these to open-source alternatives available on Google Fonts.
86
+
87
+ Default mapping:
88
+
89
+ | PPTX Font | Mapped to |
90
+ | ----------------------------------- | ------------- |
91
+ | Calibri | Carlito |
92
+ | Arial | Arimo |
93
+ | Times New Roman | Tinos |
94
+ | Courier New | Cousine |
95
+ | Cambria | Caladea |
96
+ | Meiryo / Yu Gothic / MS Gothic etc. | Noto Sans JP |
97
+ | MS Mincho / Yu Mincho etc. | Noto Serif JP |
98
+
99
+ You can customize the mapping via the `fontMapping` option:
100
+
101
+ ```typescript
102
+ const results = await convertPptxToSvg(pptx, {
103
+ fontMapping: {
104
+ "Custom Corp Font": "Noto Sans", // Add a new mapping
105
+ Arial: "Inter", // Override the default
106
+ },
107
+ });
48
108
  ```
49
109
 
50
110
  ## Feature Support
@@ -127,10 +187,10 @@ Supports conversion of static visual content in PowerPoint. Dynamic elements suc
127
187
 
128
188
  #### Charts
129
189
 
130
- | Feature | Details |
131
- | ---------------- | ------------------------------------------------------------------------------------------ |
132
- | Supported charts | Bar chart (vertical/horizontal), line chart, pie chart, scatter plot |
133
- | Chart elements | Title, legend (position), series (name/values/categories/color), category axis, value axis |
190
+ | Feature | Details |
191
+ | ---------------- | ------------------------------------------------------------------------------------------------------------ |
192
+ | Supported charts | Bar chart (vertical/horizontal), line chart, pie chart, scatter plot, area chart, doughnut, bubble, radar |
193
+ | Chart elements | Title, legend (position), series (name/values/categories/color), category axis, value axis |
134
194
 
135
195
  #### SmartArt
136
196
 
@@ -154,9 +214,9 @@ Supports conversion of static visual content in PowerPoint. Dynamic elements suc
154
214
  | -------------- | ---------------------------------------------------------------------------------------------- |
155
215
  | Fill | Path gradient (rect/shape type) |
156
216
  | Effects | Reflection, 3D rotation / extrusion, artistic effects |
157
- | Charts | Area, radar, doughnut, bubble, stock, combo, histogram, box plot, waterfall, treemap, sunburst |
217
+ | Charts | Stock, combo, histogram, box plot, waterfall, treemap, sunburst |
158
218
  | Chart details | Data labels, axis titles / tick marks / grid lines, error bars, trendlines |
159
- | Text | Vertical text, individual text effects (shadow/glow), text outline, text columns |
219
+ | Text | Individual text effects (shadow/glow), text columns |
160
220
  | Tables | Table style template application, diagonal borders |
161
221
  | Shapes | Shape operations (Union/Subtract/Intersect/Fragment) |
162
222
  | Multimedia | Embedded video / audio |