@office-open/pptx 0.4.6 → 0.5.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,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** — Parse existing .pptx files with `parsePresentation` 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
- slides: [
42
- {
43
- children: [
44
- new Shape({
45
- text: "Hello World",
46
- fill: "4472C4",
47
- x: 100,
48
- y: 100,
49
- width: 600,
50
- height: 400,
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 { parsePresentation, Presentation, Packer } from "@office-open/pptx";
68
+ import { readFileSync, writeFileSync } from "node:fs";
69
+
70
+ const slides = parsePresentation(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):
@@ -82,11 +99,11 @@ Performance vs [PptxGenJS](https://github.com/gitbrent/PptxGenJS) (higher hz is
82
99
 
83
100
  **Large Files — Create + toBuffer**
84
101
 
85
- | Scenario | @office-open/pptx | PptxGenJS (DEFLATE) | Speedup |
86
- | ---------------------- | ----------------: | ------------------: | -------: |
87
- | 10 slides × 10 shapes | 493 ops/s | 475 ops/s | **1.0x** |
88
- | 50×10 table | 450 ops/s | 243 ops/s | **1.9x** |
89
- | 20 slides full | 450 ops/s | 343 ops/s | **1.3x** |
102
+ | Scenario | @office-open/pptx | PptxGenJS (DEFLATE) | Speedup |
103
+ | --------------------- | ----------------: | ------------------: | -------: |
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};