@office-open/pptx 0.7.0 → 0.8.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 +14 -8
- package/dist/index.d.mts +462 -85
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1283 -199
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @office-open/pptx
|
|
2
2
|
|
|
3
|
-
> Generate and parse .pptx
|
|
3
|
+
> Generate and parse .pptx presentations with a declarative TypeScript API. Works in Node.js and browsers.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -26,17 +26,23 @@
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
+
# pnpm
|
|
30
|
+
pnpm add @office-open/pptx
|
|
31
|
+
|
|
29
32
|
# npm
|
|
30
33
|
npm install @office-open/pptx
|
|
31
34
|
|
|
32
|
-
#
|
|
33
|
-
|
|
35
|
+
# yarn
|
|
36
|
+
yarn add @office-open/pptx
|
|
37
|
+
|
|
38
|
+
# bun
|
|
39
|
+
bun add @office-open/pptx
|
|
34
40
|
```
|
|
35
41
|
|
|
36
42
|
## Quick Start
|
|
37
43
|
|
|
38
44
|
```typescript
|
|
39
|
-
import { Presentation, Shape, Packer, Paragraph,
|
|
45
|
+
import { Presentation, Shape, Packer, Paragraph, TextRun } from "@office-open/pptx";
|
|
40
46
|
import { writeFileSync } from "node:fs";
|
|
41
47
|
|
|
42
48
|
const pres = new Presentation({
|
|
@@ -44,7 +50,7 @@ const pres = new Presentation({
|
|
|
44
50
|
{
|
|
45
51
|
children: [
|
|
46
52
|
new Shape({
|
|
47
|
-
|
|
53
|
+
textBody: { children: [new Paragraph({ children: [new TextRun("Hello World")] })] },
|
|
48
54
|
fill: "4472C4",
|
|
49
55
|
x: 100,
|
|
50
56
|
y: 100,
|
|
@@ -62,16 +68,16 @@ writeFileSync("presentation.pptx", buffer);
|
|
|
62
68
|
|
|
63
69
|
## Parsing
|
|
64
70
|
|
|
65
|
-
Read existing `.pptx` files and re-create them as `
|
|
71
|
+
Read existing `.pptx` files and re-create them as `PresentationOptions`:
|
|
66
72
|
|
|
67
73
|
```typescript
|
|
68
74
|
import { parsePresentation, Presentation, Packer } from "@office-open/pptx";
|
|
69
75
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
70
76
|
|
|
71
|
-
const
|
|
77
|
+
const opts = parsePresentation(new Uint8Array(readFileSync("input.pptx")));
|
|
72
78
|
|
|
73
79
|
// Modify parsed data, then re-generate
|
|
74
|
-
const pres = new Presentation(
|
|
80
|
+
const pres = new Presentation(opts);
|
|
75
81
|
const buffer = await Packer.toBuffer(pres);
|
|
76
82
|
writeFileSync("output.pptx", buffer);
|
|
77
83
|
```
|