@office-open/docx 0.8.1 → 0.9.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 +23 -30
- package/dist/context-DkABanLH.mjs +5584 -0
- package/dist/context-DkABanLH.mjs.map +1 -0
- package/dist/core-properties-C79Z-ZPE.d.mts +3511 -0
- package/dist/core-properties-C79Z-ZPE.d.mts.map +1 -0
- package/dist/document-Ch4dyBB4.mjs +4456 -0
- package/dist/document-Ch4dyBB4.mjs.map +1 -0
- package/dist/generate-DQ6qeP58.mjs +490 -0
- package/dist/generate-DQ6qeP58.mjs.map +1 -0
- package/dist/generate.d.mts +10 -0
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +2 -0
- package/dist/index.d.mts +143 -4914
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +233 -26018
- package/dist/index.mjs.map +1 -1
- package/dist/parse-0XGa3h9q.mjs +526 -0
- package/dist/parse-0XGa3h9q.mjs.map +1 -0
- package/dist/parse.d.mts +2 -0
- package/dist/parse.mjs +2 -0
- package/dist/patch/index.d.mts +50 -0
- package/dist/patch/index.d.mts.map +1 -0
- package/dist/patch/index.mjs +272 -0
- package/dist/patch/index.mjs.map +1 -0
- package/package.json +17 -4
- package/dist/chunk-BBjsoOtd.mjs +0 -27
package/README.md
CHANGED
|
@@ -51,28 +51,23 @@ bun add @office-open/docx
|
|
|
51
51
|
## Quick Start
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
|
-
import {
|
|
54
|
+
import { generateDocument } from "@office-open/docx";
|
|
55
55
|
import { writeFileSync } from "node:fs";
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const buffer = await generateDocument({
|
|
58
58
|
sections: [
|
|
59
59
|
{
|
|
60
60
|
children: [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
bold: true,
|
|
67
|
-
}),
|
|
68
|
-
],
|
|
69
|
-
}),
|
|
61
|
+
{
|
|
62
|
+
paragraph: {
|
|
63
|
+
children: ["Hello World", { text: " - Bold text", bold: true }],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
70
66
|
],
|
|
71
67
|
},
|
|
72
68
|
],
|
|
73
69
|
});
|
|
74
70
|
|
|
75
|
-
const buffer = await Packer.toBuffer(doc);
|
|
76
71
|
writeFileSync("My Document.docx", buffer);
|
|
77
72
|
```
|
|
78
73
|
|
|
@@ -82,44 +77,42 @@ Check the [demo folder](./demo) for 100+ working examples covering every feature
|
|
|
82
77
|
|
|
83
78
|
## Benchmark
|
|
84
79
|
|
|
85
|
-
Performance
|
|
80
|
+
Performance vs original `docx` (9.6.1) package (higher ops/s is better, Windows 11 / Node 24).
|
|
86
81
|
|
|
87
|
-
**Default** = XML DEFLATE level 1 (SuperFast, matching MS Office) + media STORE. **All STORE** = no compression (`{ compression: { xml: 0 } }`). **docx** (async) always uses DEFLATE for ALL entries including images (via JSZip, hardcoded, no STORE option).
|
|
82
|
+
**Default** = XML DEFLATE level 1 (SuperFast, matching MS Office) + media STORE. **All STORE** = no compression (`{ compression: { xml: 0 } }`). **docx** (async only) always uses DEFLATE for ALL entries including images (via JSZip, hardcoded, no STORE option).
|
|
88
83
|
|
|
89
84
|
```typescript
|
|
90
85
|
// Default (matches MS Office)
|
|
91
|
-
await
|
|
86
|
+
await generateDocument(options);
|
|
92
87
|
// All STORE (no compression)
|
|
93
|
-
await
|
|
88
|
+
await generateDocument(options, { compression: { xml: 0 } });
|
|
94
89
|
```
|
|
95
90
|
|
|
96
91
|
**Create + toBuffer (end-to-end)**
|
|
97
92
|
|
|
98
93
|
| Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
|
|
99
94
|
| ------------------------------ | -----------: | ------------: | -------------: | --------------: | --------: |
|
|
100
|
-
| Simple (2p + 1 img) |
|
|
101
|
-
| Styled paragraphs (20) + 1 img |
|
|
102
|
-
| Table (10x5) |
|
|
103
|
-
| Full featured + 2 imgs |
|
|
95
|
+
| Simple (2p + 1 img) | 970 ops/s | 521 ops/s | 1,496 ops/s | 1,461 ops/s | 89 ops/s |
|
|
96
|
+
| Styled paragraphs (20) + 1 img | 829 ops/s | 477 ops/s | 1,534 ops/s | 1,610 ops/s | 99 ops/s |
|
|
97
|
+
| Table (10x5) | 1,411 ops/s | 696 ops/s | 3,780 ops/s | 3,644 ops/s | 216 ops/s |
|
|
98
|
+
| Full featured + 2 imgs | 530 ops/s | 353 ops/s | 847 ops/s | 863 ops/s | 54 ops/s |
|
|
104
99
|
|
|
105
100
|
**Large Files — Create + toBuffer**
|
|
106
101
|
|
|
107
102
|
| Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
|
|
108
103
|
| ------------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: |
|
|
109
|
-
| 2000 paragraphs + 20 images |
|
|
110
|
-
| 200x10 table |
|
|
111
|
-
| 20 sections x 100p + 40 images |
|
|
104
|
+
| 2000 paragraphs + 20 images | 35.7 ops/s | 34.3 ops/s | 35.7 ops/s | 35.8 ops/s | 3.0 ops/s |
|
|
105
|
+
| 200x10 table | 246 ops/s | 207 ops/s | 255 ops/s | 256 ops/s | 37.0 ops/s |
|
|
106
|
+
| 20 sections x 100p + 40 images | 18.6 ops/s | 17.1 ops/s | 18.6 ops/s | 19.5 ops/s | 1.8 ops/s |
|
|
112
107
|
|
|
113
108
|
**Large File (~100MB) — Mixed Content**
|
|
114
109
|
|
|
115
|
-
500 styled paragraphs + 38 mixed-size images (1-5MB, 100MB total) + 50x10 table.
|
|
110
|
+
500 styled paragraphs + 38 mixed-size images (1-5MB, 100MB total) + 50x10 table.
|
|
116
111
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
| Default | 0.31 ops/s | 1.1x |
|
|
121
|
-
| docx | 0.29 ops/s | |
|
|
112
|
+
| Scenario | Default sync | Default async | All STORE sync | All STORE async | docx |
|
|
113
|
+
| ------------------------ | -----------: | ------------: | -------------: | --------------: | ---------: |
|
|
114
|
+
| Mixed (500p+38img+50x10) | 4.5 ops/s | 4.6 ops/s | 4.4 ops/s | 4.3 ops/s | 0.30 ops/s |
|
|
122
115
|
|
|
123
116
|
## License
|
|
124
117
|
|
|
125
|
-
- [MIT](LICENSE) © [Demo Macro](https://
|
|
118
|
+
- [MIT](LICENSE) © [Demo Macro](https://www.demomacro.com/)
|