docx-plus 0.0.0 → 0.0.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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/index.cjs +20144 -0
- package/dist/index.d.cts +3230 -0
- package/dist/index.d.mts +3230 -0
- package/dist/index.iife.js +20141 -0
- package/dist/index.mjs +19816 -0
- package/dist/index.umd.js +20150 -0
- package/package.json +88 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Dolan
|
|
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,95 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./logo/logo-animate.svg" width="100%" height="300" alt="docx-plus">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
[![NPM version][npm-image]][npm-url]
|
|
12
|
+
[![Downloads per month][downloads-image]][downloads-url]
|
|
13
|
+
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
|
|
14
|
+
[![Known Vulnerabilities][snky-image]][snky-url]
|
|
15
|
+
[![PRs Welcome][pr-image]][pr-url]
|
|
16
|
+
[codecov][codecov-image][codecov-url]
|
|
17
|
+
|
|
18
|
+
# docx-plus
|
|
19
|
+
|
|
20
|
+
**docx-plus** is an enhanced fork of [docx](https://github.com/dolanmiu/docx) — a TypeScript/JavaScript library for generating and modifying Word documents (.docx) programmatically with a declarative API.
|
|
21
|
+
|
|
22
|
+
## What's Different from docx?
|
|
23
|
+
|
|
24
|
+
| | docx | docx-plus |
|
|
25
|
+
| --------------------- | ----------------------------------------- | ------------------------------------ |
|
|
26
|
+
| ZIP handling | jszip | **fflate** (faster, smaller) |
|
|
27
|
+
| Data conversion | Manual env detection (`Buffer.from` etc.) | **undio** (universal `toUint8Array`) |
|
|
28
|
+
| Test environment | jsdom | happy-dom |
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```terminal
|
|
33
|
+
npm install --save docx-plus
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import * as docx from "docx-plus";
|
|
38
|
+
// or
|
|
39
|
+
import { Document, Packer, Paragraph, TextRun } from "docx-plus";
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Example
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import * as fs from "fs";
|
|
46
|
+
import { Document, Packer, Paragraph, TextRun } from "docx-plus";
|
|
47
|
+
|
|
48
|
+
const doc = new Document({
|
|
49
|
+
sections: [
|
|
50
|
+
{
|
|
51
|
+
children: [
|
|
52
|
+
new Paragraph({
|
|
53
|
+
children: [
|
|
54
|
+
new TextRun("Hello World"),
|
|
55
|
+
new TextRun({
|
|
56
|
+
text: " - Bold text",
|
|
57
|
+
bold: true,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const buffer = await Packer.toBuffer(doc);
|
|
67
|
+
fs.writeFileSync("My Document.docx", buffer);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
Please refer to the [documentation](https://github.com/DemoMacro/docx-plus#readme) for details on how to use this library, examples and much more!
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
Check the [demo folder](https://github.com/DemoMacro/docx-plus/tree/master/demo) for 90+ working examples covering every feature.
|
|
77
|
+
|
|
78
|
+
## Contributing
|
|
79
|
+
|
|
80
|
+
Contributions are welcome! Please feel free to submit pull requests.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
[npm-image]: https://badge.fury.io/js/docx-plus.svg
|
|
85
|
+
[npm-url]: https://npmjs.org/package/docx-plus
|
|
86
|
+
[downloads-image]: https://img.shields.io/npm/dm/docx-plus.svg
|
|
87
|
+
[downloads-url]: https://npmjs.org/package/docx-plus
|
|
88
|
+
[github-actions-workflow-image]: https://github.com/DemoMacro/docx-plus/workflows/Default/badge.svg?branch=main
|
|
89
|
+
[github-actions-workflow-url]: https://github.com/DemoMacro/docx-plus/actions
|
|
90
|
+
[snky-image]: https://snyk.io/test/github/DemoMacro/docx-plus/badge.svg
|
|
91
|
+
[snky-url]: https://snyk.io/test/github/DemoMacro/docx-plus
|
|
92
|
+
[pr-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
|
93
|
+
[pr-url]: http://makeapullrequest.com
|
|
94
|
+
[codecov-image]: https://codecov.io/gh/DemoMacro/docx-plus/branch/main/graph/badge.svg
|
|
95
|
+
[codecov-url]: https://codecov.io/gh/DemoMacro/docx-plus
|