@office-open/docx 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dolan, Demo Macro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @office-open/docx
2
+
3
+ ![npm version](https://img.shields.io/npm/v/@office-open/docx)
4
+ ![npm downloads](https://img.shields.io/npm/dw/@office-open/docx)
5
+ ![npm license](https://img.shields.io/npm/l/@office-open/docx)
6
+
7
+ > Generate .docx files with a nice declarative API. Works for Node.js and on the Browser.
8
+
9
+ ## Features
10
+
11
+ - **Document Generation** - Create Word documents with sections, headers, footers, and page numbers
12
+ - **Paragraphs & Text** - Rich text support with bold, italic, underline, strikethrough, and more
13
+ - **Tables** - Full table support with merged cells, borders, and styles
14
+ - **Images** - Inline and floating images with sizing, positioning, and wrapping
15
+ - **Hyperlinks** - External and internal hyperlinks with custom styling
16
+ - **Headers & Footers** - First, last, even/odd page headers and footers
17
+ - **Lists** - Numbered and bulleted lists with multiple levels and custom formats
18
+ - **Styles** - Paragraph, character, and table styles with inheritance
19
+ - **Table of Contents** - Auto-generated table of contents with custom styling
20
+ - **Footnotes & Endnotes** - Comprehensive footnote and endnote support
21
+ - **Charts** - Bar, line, pie, area, and scatter charts with customization
22
+ - **Math Equations** - Full mathematical equation support via MathML
23
+ - **SmartArt** - Built-in SmartArt graphic generation
24
+ - **Bibliography** - Source management and citation support
25
+ - **Comments** - Document comments with author and date tracking
26
+ - **Track Revisions** - Insertions, deletions, and formatting changes
27
+ - **Content Controls** - Structured document tags (SDT) for form-like documents
28
+ - **Text Boxes** - Floating text boxes with content and styling
29
+ - **Checkboxes** - Form checkbox support in documents
30
+ - **DrawingML** - Shapes with fills, shadows, effects, and transformations
31
+ - **Custom Fonts** - Font embedding and custom font tables
32
+ - **Template Patching** - Patch existing DOCX templates via placeholder replacement
33
+ - **Settings** - Comprehensive document settings and compatibility options
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ # Install with npm
39
+ $ npm install @office-open/docx
40
+
41
+ # Install with pnpm
42
+ $ pnpm add @office-open/docx
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ```typescript
48
+ import { Document, Paragraph, TextRun, Packer } from "@office-open/docx";
49
+ import { writeFileSync } from "node:fs";
50
+
51
+ const doc = new Document({
52
+ sections: [
53
+ {
54
+ children: [
55
+ new Paragraph({
56
+ children: [
57
+ new TextRun("Hello World"),
58
+ new TextRun({
59
+ text: " - Bold text",
60
+ bold: true,
61
+ }),
62
+ ],
63
+ }),
64
+ ],
65
+ },
66
+ ],
67
+ });
68
+
69
+ const buffer = await Packer.toBuffer(doc);
70
+ writeFileSync("My Document.docx", buffer);
71
+ ```
72
+
73
+ ## Examples
74
+
75
+ Check the [demo folder](./demo) for 100+ working examples covering every feature.
76
+
77
+ ## Benchmark
78
+
79
+ Performance comparison against original `docx` (9.6.1) package:
80
+
81
+ | Scenario | @office-open/docx | docx | Speedup |
82
+ | ------------------------------------------------------- | ----------------: | -------: | --------: |
83
+ | Simple document (2 paragraphs) | 7,672 hz | 4,334 hz | **1.77x** |
84
+ | Styled paragraphs (20 paragraphs) | 6,301 hz | 4,157 hz | **1.52x** |
85
+ | Table (10x5 cells) | 3,854 hz | 2,595 hz | **1.49x** |
86
+ | Full featured (header/footer/headings/table/paragraphs) | 2,745 hz | 2,366 hz | **1.16x** |
87
+
88
+ ## License
89
+
90
+ - [MIT](LICENSE) © [Demo Macro](https://imst.xyz/)