@office-open/pptx 0.4.5 → 0.5.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.
- package/README.md +43 -26
- package/dist/chunk-BY251N0e.mjs +1 -0
- package/dist/index.d.mts +487 -463
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +35 -8745
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/_chunks/chunk-C8-KU_0P.mjs +0 -29
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @office-open/pptx
|
|
2
2
|
|
|
3
|
-
> Generate .pptx files with JS/TS with a declarative API.
|
|
3
|
+
> Generate and parse .pptx files with JS/TS with a declarative API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
- **Notes** — Speaker notes for each slide
|
|
21
21
|
- **Group Shapes** — Group multiple shapes together
|
|
22
22
|
- **DrawingML** — Shapes with fills, outlines, shadows, glow, reflection, and 3D effects
|
|
23
|
+
- **Parsing** — Read existing .pptx files with `readPresentation` for round-trip workflows
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
25
26
|
|
|
@@ -38,26 +39,42 @@ import { Presentation, Shape, Packer, Paragraph, Run } from "@office-open/pptx";
|
|
|
38
39
|
import { writeFileSync } from "node:fs";
|
|
39
40
|
|
|
40
41
|
const pres = new Presentation({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
slides: [
|
|
43
|
+
{
|
|
44
|
+
children: [
|
|
45
|
+
new Shape({
|
|
46
|
+
text: "Hello World",
|
|
47
|
+
fill: "4472C4",
|
|
48
|
+
x: 100,
|
|
49
|
+
y: 100,
|
|
50
|
+
width: 600,
|
|
51
|
+
height: 400,
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
const buffer = await Packer.toBuffer(pres);
|
|
58
59
|
writeFileSync("presentation.pptx", buffer);
|
|
59
60
|
```
|
|
60
61
|
|
|
62
|
+
## Parsing
|
|
63
|
+
|
|
64
|
+
Read existing `.pptx` files and re-create them as `ISlideOptions[]`:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { readPresentation, Presentation, Packer } from "@office-open/pptx";
|
|
68
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
69
|
+
|
|
70
|
+
const slides = readPresentation(new Uint8Array(readFileSync("input.pptx")));
|
|
71
|
+
|
|
72
|
+
// Modify parsed data, then re-generate
|
|
73
|
+
const pres = new Presentation({ slides });
|
|
74
|
+
const buffer = await Packer.toBuffer(pres);
|
|
75
|
+
writeFileSync("output.pptx", buffer);
|
|
76
|
+
```
|
|
77
|
+
|
|
61
78
|
## Performance
|
|
62
79
|
|
|
63
80
|
Performance vs [PptxGenJS](https://github.com/gitbrent/PptxGenJS) (higher hz is better, Windows 11 / Node 22):
|
|
@@ -66,27 +83,27 @@ Performance vs [PptxGenJS](https://github.com/gitbrent/PptxGenJS) (higher hz is
|
|
|
66
83
|
|
|
67
84
|
| Scenario | @office-open/pptx | PptxGenJS | Speedup |
|
|
68
85
|
| ------------------------- | ----------------: | ----------: | --------: |
|
|
69
|
-
| Simple (2 shapes) |
|
|
70
|
-
| Styled shapes (20 shapes) |
|
|
71
|
-
| Table (10x5) |
|
|
72
|
-
| Full featured |
|
|
86
|
+
| Simple (2 shapes) | 5.06M ops/s | 659K ops/s | **7.7x** |
|
|
87
|
+
| Styled shapes (20 shapes) | 244K ops/s | 82.9K ops/s | **2.9x** |
|
|
88
|
+
| Table (10x5) | 2.32M ops/s | 28.9K ops/s | **80.2x** |
|
|
89
|
+
| Full featured | 199K ops/s | 18.1K ops/s | **11.0x** |
|
|
73
90
|
|
|
74
91
|
**Create + toBuffer (end-to-end)**
|
|
75
92
|
|
|
76
93
|
| Scenario | @office-open/pptx | PptxGenJS (DEFLATE) | Speedup |
|
|
77
94
|
| ------------------------- | ----------------: | ------------------: | -------: |
|
|
78
|
-
| Simple (2 shapes) | 1,
|
|
79
|
-
| Styled shapes (20 shapes) | 1,
|
|
80
|
-
| Table (10x5) | 1,
|
|
81
|
-
| Full featured | 1,
|
|
95
|
+
| Simple (2 shapes) | 1,705 ops/s | 1,456 ops/s | **1.2x** |
|
|
96
|
+
| Styled shapes (20 shapes) | 1,377 ops/s | 1,243 ops/s | **1.1x** |
|
|
97
|
+
| Table (10x5) | 1,644 ops/s | 983 ops/s | **1.7x** |
|
|
98
|
+
| Full featured | 1,138 ops/s | 806 ops/s | **1.4x** |
|
|
82
99
|
|
|
83
100
|
**Large Files — Create + toBuffer**
|
|
84
101
|
|
|
85
102
|
| Scenario | @office-open/pptx | PptxGenJS (DEFLATE) | Speedup |
|
|
86
103
|
| --------------------- | ----------------: | ------------------: | -------: |
|
|
87
|
-
| 10 slides × 10 shapes |
|
|
88
|
-
| 50×10 table |
|
|
89
|
-
| 20 slides full |
|
|
104
|
+
| 10 slides × 10 shapes | 493 ops/s | 475 ops/s | **1.0x** |
|
|
105
|
+
| 50×10 table | 450 ops/s | 243 ops/s | **1.9x** |
|
|
106
|
+
| 20 slides full | 450 ops/s | 343 ops/s | **1.3x** |
|
|
90
107
|
|
|
91
108
|
## Examples
|
|
92
109
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,t)=>()=>(e&&(t=e(e=0)),t),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},o=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!r.call(i,d)&&d!==o&&e(i,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return i},s=(e,t,n)=>(o(e,t,`default`),n&&o(n,t,`default`)),c=t=>r.call(t,`module.exports`)?t[`module.exports`]:o(e({},`__esModule`,{value:!0}),t);export{c as i,a as n,s as r,i as t};
|