Compare commits

..

400 Commits
5.1.1 ... 6.0.0

Author SHA1 Message Date
9cf7f3cf54 Version bump 2021-03-21 03:19:18 +00:00
77afb55167 Update StackBlitz links 2021-03-21 03:16:39 +00:00
e86997576f Update README.md 2021-03-21 02:14:03 +00:00
a67e306737 Update README.md 2021-03-20 02:17:57 +00:00
48ea634e08 Update README.md 2021-03-20 02:16:28 +00:00
ea29f515b0 Merge pull request #841 from dolanmiu/feat/workflow-updates
Add workflow and issue template
2021-03-20 01:57:55 +00:00
41d27cb78c Fix demo 2021-03-20 01:27:35 +00:00
ff45c182ce Fix demo 2021-03-20 01:20:14 +00:00
0519ed6d09 Add workflow and issue template 2021-03-20 00:37:09 +00:00
f41e19c251 Merge pull request #840 from dolanmiu/feat/declarative-add-section
Make .addSection fully declarative
2021-03-19 23:52:15 +00:00
329a70c312 Fix demo 2021-03-19 21:40:53 +00:00
419fef5759 Fix demo 2021-03-19 21:09:58 +00:00
3299c557a0 Make .addSection fully declarative 2021-03-19 20:53:56 +00:00
4783812044 Merge pull request #834 from dolanmiu/feat/simpler-images
Make adding images declarative and simple
2021-03-18 04:06:09 +00:00
6e21cdbf17 Fix demos 2021-03-18 03:28:29 +00:00
caf188caae Make adding images declarative and simple 2021-03-18 02:48:37 +00:00
c8db70b3b7 Merge pull request #831 from dolanmiu/dependabot/npm_and_yarn/types/node-14.14.35
build(deps): bump @types/node from 14.14.34 to 14.14.35
2021-03-16 10:17:58 +00:00
eb0479d80b Merge pull request #830 from dolanmiu/dependabot/npm_and_yarn/nanoid-3.1.22
build(deps): bump nanoid from 3.1.21 to 3.1.22
2021-03-16 10:17:46 +00:00
181d56ca80 build(deps): bump @types/node from 14.14.34 to 14.14.35
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.34 to 14.14.35.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-16 07:55:36 +00:00
b1d1b9e9b7 build(deps): bump nanoid from 3.1.21 to 3.1.22
Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.21 to 3.1.22.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.1.21...3.1.22)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-16 07:54:44 +00:00
28685a8761 Add spacing to table float 2021-03-16 03:21:05 +00:00
ecd1596682 Merge pull request #829 from dolanmiu/feat/even-odd-headers
#251 Turning off default headers by default
2021-03-16 03:04:19 +00:00
6746f81da5 Fix tests 2021-03-16 02:26:05 +00:00
c7075d740f #251 Turning off default headers by default 2021-03-16 01:23:23 +00:00
0faac01f6b Merge pull request #828 from dolanmiu/feat/even-odd-headers
Feat/even odd headers
2021-03-16 01:16:34 +00:00
bdfaee2cb3 Update demo 2021-03-16 01:02:33 +00:00
131183ae19 #613 #439 Even and odd headers 2021-03-16 00:57:27 +00:00
8b2aa58198 Merge pull request #827 from dolanmiu/feat/spacing
Add enum to lineRule and create demo
2021-03-15 19:43:35 +00:00
4fe2973473 Add enum to lineRule and create demo 2021-03-15 19:23:40 +00:00
93ec9eed7a Add titlePage to first page header 2021-03-15 19:02:04 +00:00
ba5cb1483b Merge pull request #825 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.20.32
build(deps-dev): bump typedoc from 0.20.30 to 0.20.32
2021-03-15 13:08:23 +00:00
1436f4d4b2 Merge pull request #824 from dolanmiu/dependabot/npm_and_yarn/types/node-14.14.34
build(deps): bump @types/node from 14.14.33 to 14.14.34
2021-03-15 13:08:06 +00:00
107e6ce1d9 build(deps-dev): bump typedoc from 0.20.30 to 0.20.32
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.20.30 to 0.20.32.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.20.30...v0.20.32)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-15 09:14:01 +00:00
2d5e08588c build(deps): bump @types/node from 14.14.33 to 14.14.34
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.33 to 14.14.34.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-15 09:12:26 +00:00
24f95aee8b Add custom bullet point example 2021-03-15 03:46:34 +00:00
c5e9e3b2a0 Fix documentation 2021-03-15 03:02:39 +00:00
0b85e07701 Fix documentation 2021-03-15 02:58:26 +00:00
40b3bc0b90 Merge pull request #822 from dolanmiu/feat/rotating-images
#815 Rotation and flipping images
2021-03-15 02:56:08 +00:00
bd40b11ce4 #815 Rotation and flipping images 2021-03-15 02:41:37 +00:00
a3febae8a3 Inline single use interfaces 2021-03-15 00:11:39 +00:00
18ce200cdb Merge pull request #821 from dolanmiu/feat/text-frame
#269 Text Frame (Text Box)
2021-03-14 18:17:44 +00:00
cc32a7b2d3 Add text frame documentation 2021-03-14 18:12:52 +00:00
e7eca14e1e Fix prettier issues 2021-03-14 17:03:50 +00:00
7f86385b09 #269 Text Frame (Text Box) 2021-03-14 17:00:42 +00:00
2fa8df7cf4 Add more tests 2021-03-14 00:44:12 +00:00
f0e50dd21f Add more tests 2021-03-13 22:43:21 +00:00
0bc36d924f Write tests 2021-03-13 22:10:00 +00:00
4bc0421055 Add tests 2021-03-13 20:23:15 +00:00
cc9a966f53 Improve tests 2021-03-13 19:53:36 +00:00
8aa804db18 Add style to styles demo 2021-03-13 19:52:08 +00:00
b3ffa60f14 Merge pull request #819 from dolanmiu/feat/widow-control
#750 Add widow control
2021-03-13 04:19:31 +00:00
8724fbe7a7 #750 Add widow control 2021-03-13 04:07:44 +00:00
2391375ac0 Merge pull request #817 from dolanmiu/dependabot/npm_and_yarn/nanoid-3.1.21
build(deps): bump nanoid from 3.1.20 to 3.1.21
2021-03-12 11:12:06 +00:00
12817957f4 build(deps): bump nanoid from 3.1.20 to 3.1.21
Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.20 to 3.1.21.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.1.20...3.1.21)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-12 07:57:39 +00:00
58f7e5a9a3 Merge pull request #816 from dolanmiu/feat/restart-numbered-lists
#548 #508 Restart numbered lists
2021-03-12 04:04:59 +00:00
0b88cb0ca5 #548 #508 Restart numbered lists 2021-03-12 03:58:05 +00:00
dbaa493ebd Merge pull request #763 from netbymatt/master
Allow styles and headings with numbering
2021-03-11 19:42:30 +00:00
4b5d2d98f9 add tests for numbering paragraph styles 2021-03-11 11:11:46 -06:00
9864cdea16 Merge pull request #814 from dolanmiu/feat/use-context-in-prep-xml
Use context in prep xml
2021-03-11 01:17:14 +00:00
566ac03f9a Use context in prep xml 2021-03-11 01:06:55 +00:00
cf6c4998d0 Merge pull request #813 from dolanmiu/dependabot/npm_and_yarn/types/node-14.14.33
build(deps): bump @types/node from 14.14.32 to 14.14.33
2021-03-10 16:55:09 +00:00
0891e2a8c3 build(deps): bump @types/node from 14.14.32 to 14.14.33
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.32 to 14.14.33.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-10 07:55:14 +00:00
48d9e75707 Merge pull request #511 from dolanmiu/feature/separator
Restart page numbering
2021-03-09 23:11:15 +00:00
cd501bba0a Add tests 2021-03-09 22:59:50 +00:00
57f80e636e Move demos to unique number 2021-03-09 22:57:51 +00:00
89c2e14979 Merge branch 'master' of github.com:dolanmiu/docx into feature/separator
# Conflicts:
#	src/file/document/body/section-properties/section-properties.ts
2021-03-09 22:37:37 +00:00
8c2ba7a452 Merge pull request #810 from dolanmiu/dependabot/npm_and_yarn/docsify-cli-4.4.3
build(deps-dev): bump docsify-cli from 4.4.2 to 4.4.3
2021-03-09 15:20:49 +00:00
cd232496e2 build(deps-dev): bump docsify-cli from 4.4.2 to 4.4.3
Bumps [docsify-cli](https://github.com/docsifyjs/docsify-cli) from 4.4.2 to 4.4.3.
- [Release notes](https://github.com/docsifyjs/docsify-cli/releases)
- [Changelog](https://github.com/docsifyjs/docsify-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docsifyjs/docsify-cli/compare/v4.4.2...v4.4.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-09 08:18:46 +00:00
0cdb1a9286 Add rimraf to build 2021-03-09 03:00:30 +00:00
7ebef8b3b5 #800 Use new typedoc config 2021-03-09 02:23:22 +00:00
e98fe5921c #713 Update chinese demo and refactor 2021-03-09 01:37:22 +00:00
98253c3445 Update tslint rules 2021-03-08 23:17:10 +00:00
9bda9e8375 #801 Add example to offset header and footer 2021-03-08 22:51:46 +00:00
bf4498061a Merge pull request #808 from dolanmiu/dependabot/npm_and_yarn/elliptic-6.5.4
build(deps): [security] bump elliptic from 6.5.3 to 6.5.4
2021-03-08 18:46:15 +00:00
13d0f33af6 build(deps): [security] bump elliptic from 6.5.3 to 6.5.4
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.3 to 6.5.4. **This update includes a security fix.**
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.3...v6.5.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-08 17:18:15 +00:00
d4bc89d141 Merge pull request #806 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.20.30
build(deps-dev): bump typedoc from 0.20.29 to 0.20.30
2021-03-08 10:09:10 +00:00
0c42298dce Merge pull request #805 from dolanmiu/dependabot/npm_and_yarn/types/node-14.14.32
build(deps): bump @types/node from 14.14.31 to 14.14.32
2021-03-08 10:08:59 +00:00
f997515af4 Merge pull request #804 from dolanmiu/dependabot/npm_and_yarn/types/sinon-9.0.11
build(deps-dev): bump @types/sinon from 9.0.10 to 9.0.11
2021-03-08 10:08:49 +00:00
624afb8fba build(deps-dev): bump typedoc from 0.20.29 to 0.20.30
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.20.29 to 0.20.30.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.20.29...v0.20.30)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-08 08:50:22 +00:00
71f8bcffe7 build(deps): bump @types/node from 14.14.31 to 14.14.32
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.31 to 14.14.32.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-08 08:50:02 +00:00
e8bdeed63f build(deps-dev): bump @types/sinon from 9.0.10 to 9.0.11
Bumps [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) from 9.0.10 to 9.0.11.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-08 08:49:43 +00:00
2b7ca92ade Merge pull request #484 from dolanmiu/feat/right-indent
Multiple paragraphs in footnotes
2021-03-08 04:43:08 +00:00
fdf0764245 Alter coverage limits 2021-03-08 04:36:53 +00:00
993782129c Simplify for loop 2021-03-08 04:33:15 +00:00
65302dd39b Increase coverage limit 2021-03-08 04:22:20 +00:00
a0d8911e18 Add tests 2021-03-08 04:18:26 +00:00
2d4a452d2e Merge branch 'master' into feat/right-indent
# Conflicts:
#	demo/21-bookmarks.ts
#	package-lock.json
#	src/file/core-properties/properties.ts
#	src/file/file.spec.ts
#	src/file/file.ts
#	src/file/footnotes/footnote/footnote.spec.ts
#	src/file/footnotes/footnote/footnote.ts
#	src/file/footnotes/footnotes.ts
2021-03-08 03:40:11 +00:00
3f2ad04d65 Merge pull request #438 from ramonmata/add-table-option-styleId
Allows specify XML StyleId to be applied in a Table
2021-03-07 22:40:07 +00:00
283c42cb55 Remove unused method 2021-03-07 21:53:16 +00:00
0ec3b64ad7 Add tests 2021-03-07 21:45:59 +00:00
b972f1789e Fix tests 2021-03-07 21:43:30 +00:00
90495d08a6 Merge branch 'master' into add-table-option-styleId
# Conflicts:
#	src/file/table/table.ts
2021-03-07 21:40:42 +00:00
5fc28cb67d Move custom properties to properties 2021-03-07 21:27:38 +00:00
bb6abe5e09 Update README.md 2021-03-07 20:53:25 +00:00
d1a8f983d3 Merge pull request #802 from dolanmiu/dependabot/npm_and_yarn/typescript-4.2.3
build(deps-dev): bump typescript from 4.2.2 to 4.2.3
2021-03-05 10:16:24 +00:00
e169e01002 build(deps-dev): bump typescript from 4.2.2 to 4.2.3
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.2 to 4.2.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-05 07:59:54 +00:00
e5da573041 Clean up table with improved demo 2021-03-05 03:03:02 +00:00
9557015c6c Merge pull request #798 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.20.29
build(deps-dev): bump typedoc from 0.19.0 to 0.20.29
2021-03-04 11:34:23 +00:00
512d81649f build(deps-dev): bump typedoc from 0.19.0 to 0.20.29
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.19.0 to 0.20.29.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.19.0...v0.20.29)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-04 07:51:09 +00:00
fc1e0dad3f Merge branch 'master' of github.com:dolanmiu/docx 2021-03-04 03:25:50 +00:00
ec22720244 Update README.md 2021-03-04 03:21:03 +00:00
9743dfa8cc Improve docs 2021-03-04 03:10:20 +00:00
805bd94a25 Merge pull request #779 from dolanmiu/dependabot/npm_and_yarn/types/node-14.14.31
build(deps): bump @types/node from 14.6.2 to 14.14.31
2021-03-04 03:09:36 +00:00
c3faf3bbd8 Merge pull request #796 from dolanmiu/feat/table-work
#732 Add line between columns (separate)
2021-03-04 03:09:27 +00:00
5b3427cada Merge pull request #770 from dolanmiu/dependabot/npm_and_yarn/types/chai-4.2.15
build(deps-dev): bump @types/chai from 3.5.2 to 4.2.15
2021-03-04 03:05:09 +00:00
df7a90d3c1 build(deps): bump @types/node from 14.6.2 to 14.14.31
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.6.2 to 14.14.31.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-04 03:03:02 +00:00
f3f65da207 #732 Add line between columns (separate) 2021-03-04 03:02:07 +00:00
9326a0a998 build(deps-dev): bump @types/chai from 3.5.2 to 4.2.15
Bumps [@types/chai](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/chai) from 3.5.2 to 4.2.15.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/chai)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-04 03:00:34 +00:00
909a86df7f Merge pull request #737 from dolanmiu/dependabot/npm_and_yarn/types/sinon-9.0.10
build(deps-dev): bump @types/sinon from 9.0.4 to 9.0.10
2021-03-04 02:57:40 +00:00
a5da9f44e8 build(deps-dev): bump @types/sinon from 9.0.4 to 9.0.10
Bumps [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) from 9.0.4 to 9.0.10.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-04 02:25:09 +00:00
2f732e7378 Merge pull request #795 from dolanmiu/feat/table-work
Visual Right to Left Table
2021-03-04 02:17:50 +00:00
31269c85d2 Merge pull request #565 from SoapyD/height_branch
table-row height correction
2021-03-04 02:13:32 +00:00
95556e57df Write documentation on vidi visual 2021-03-04 02:08:09 +00:00
2aa93e6105 #751 Add bidi visual - Visual Right to Left 2021-03-04 02:02:28 +00:00
a026e5bd1f Make table internals declarative 2021-03-04 01:42:58 +00:00
9327f2bfa1 Fix compiler tests 2021-03-04 01:30:42 +00:00
603dd36458 Merge pull request #789 from dolanmiu/feat/compat-mode
#627 Add footnotes relationships
2021-03-02 00:43:00 +00:00
53ababf3a7 Merge pull request #605 from kalda341/custom-properties
Allow custom text properties to be included
2021-03-02 00:40:32 +00:00
3e58910bfc Use document wrapper component 2021-03-02 00:06:11 +00:00
736ca6a46d Merge branch 'master' into custom-properties 2021-03-02 00:01:03 +00:00
f90e84a88d #627 Add footnotes relationships 2021-03-01 23:35:52 +00:00
a79b1e36dc Merge pull request #787 from dolanmiu/dependabot/npm_and_yarn/docsify-4.12.0
build(deps): bump docsify from 4.11.6 to 4.12.0
2021-03-01 21:38:01 +00:00
dd503996a0 build(deps): bump docsify from 4.11.6 to 4.12.0
Bumps [docsify](https://github.com/docsifyjs/docsify) from 4.11.6 to 4.12.0.
- [Release notes](https://github.com/docsifyjs/docsify/releases)
- [Changelog](https://github.com/docsifyjs/docsify/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/docsifyjs/docsify/compare/v4.11.6...v4.12.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 19:48:23 +00:00
694ac22dad Merge pull request #786 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.19.0
build(deps-dev): bump typedoc from 0.16.11 to 0.19.0
2021-03-01 17:07:15 +00:00
8435ece00d build(deps-dev): bump typedoc from 0.16.11 to 0.19.0
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.16.11 to 0.19.0.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.16.11...v0.19.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-01 11:54:10 +00:00
cdd22efd79 Merge pull request #785 from dolanmiu/feat/compat-mode
Feat/compat mode
2021-03-01 03:39:11 +00:00
c6e9696be0 #532 Make hyperlinks work on the Header and Footer 2021-03-01 03:28:35 +00:00
655b40d418 Work on moving Document into its own wrapper 2021-02-28 16:04:21 +00:00
60664a2a83 Merge pull request #784 from dolanmiu/feat/compat-mode
#773 Better hyperlink and bookmark syntax
2021-02-28 15:53:21 +00:00
e750735fa4 Add bookmark in footer 2021-02-28 13:09:43 +00:00
0de7116b78 #773 Better hyperlink and bookmark syntax
Allow for images to be hyperlinked as well
2021-02-27 19:23:29 +00:00
45b1f6f9a3 Merge pull request #783 from dolanmiu/feat/compat-mode
Feat/compat mode
2021-02-27 02:06:25 +00:00
4159be5644 Add readonly 2021-02-27 01:42:29 +00:00
10455a534f #332 Compatability mode 2021-02-27 01:40:55 +00:00
84f48446df Merge pull request #781 from khalilmansouri/fix/documentation
Fix documentation typo
2021-02-24 14:08:15 +00:00
32ceaa415e Fix documentation typo 2021-02-24 13:30:40 +01:00
5e06d73f45 Merge pull request #780 from dolanmiu/feat/section-type
#339 Add Section Type
2021-02-23 00:01:14 +00:00
bfd0f0c7bb Fix linting 2021-02-22 21:12:38 +00:00
858a994d13 #339 Add Section Type 2021-02-22 21:04:02 +00:00
bb2f77aa67 Merge pull request #775 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.2.1
build(deps-dev): bump @types/mocha from 8.2.0 to 8.2.1
2021-02-18 22:25:40 +00:00
48c1559a77 build(deps-dev): bump @types/mocha from 8.2.0 to 8.2.1
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.2.0 to 8.2.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-18 07:58:12 +00:00
a6f77d01ca Merge pull request #769 from dolanmiu/dependabot/npm_and_yarn/jszip-3.6.0
build(deps): bump jszip from 3.5.0 to 3.6.0
2021-02-10 22:51:27 +00:00
4dafa62e17 build(deps): bump jszip from 3.5.0 to 3.6.0
Bumps [jszip](https://github.com/Stuk/jszip) from 3.5.0 to 3.6.0.
- [Release notes](https://github.com/Stuk/jszip/releases)
- [Changelog](https://github.com/Stuk/jszip/blob/master/CHANGES.md)
- [Commits](https://github.com/Stuk/jszip/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-10 07:52:30 +00:00
49314ea9d0 fix prettier whitespace 2021-02-04 14:48:57 -06:00
acaaf98e20 Fix spacing 2021-02-03 15:21:15 -06:00
0e2bfe9e3f Allow styles and headings with numbering 2021-02-03 14:53:29 -06:00
d6f363b275 Version bump 2021-01-31 04:54:26 +00:00
118ea57412 Merge pull request #749 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.26
build(deps-dev): bump @types/webpack from 4.41.25 to 4.41.26
2021-01-28 10:18:02 +00:00
7c8be4c8a7 Merge pull request #757 from arran4/jszip-supports-more-datatypes
Added more data types for JSZip to consider using
2021-01-28 10:17:48 +00:00
fa9021596f Merge pull request #759 from dolanmiu/dependabot/npm_and_yarn/sinon-9.2.4
build(deps-dev): bump sinon from 9.2.2 to 9.2.4
2021-01-28 10:15:40 +00:00
3ccf4bdfe3 Ran npm run style.fix added "line_ending" configuration to .editorconfig to match the results 2021-01-26 15:09:12 +11:00
f2480673ec build(deps-dev): bump sinon from 9.2.2 to 9.2.4
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.2.2 to 9.2.4.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v9.2.2...v9.2.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-25 08:20:27 +00:00
e93b8032d8 Buffer is required as it was originally there too 2021-01-22 16:48:41 +11:00
5de2d8c7fb Minor change 2021-01-22 16:45:39 +11:00
e355fd3d2e build(deps-dev): bump @types/webpack from 4.41.25 to 4.41.26
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.41.25 to 4.41.26.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-01-12 08:20:34 +00:00
d41ef99c85 Merge pull request #739 from dolanmiu/feat/convenience-functions
Add zIndex property to floating
2020-12-25 02:26:04 +00:00
5ec18d6e01 Add tests and simplify 2020-12-25 02:15:40 +00:00
b4cd3a319c Add documentation 2020-12-25 00:30:58 +00:00
d894bfa167 Add test 2020-12-25 00:29:27 +00:00
d74db948ba Add zIndex property to floating 2020-12-25 00:07:57 +00:00
3ef26c747b Merge pull request #736 from dolanmiu/feat/convenience-functions
Use LevelFormat string enum rather than strings
2020-12-24 17:45:09 +00:00
38c8220e9e Use LevelFormat string enum rather than strings 2020-12-24 04:26:45 +00:00
86f8259b33 Merge pull request #735 from dolanmiu/feat/convenience-functions
Add Convenience functions
2020-12-24 03:44:54 +00:00
502db14bba Add Convenience functions 2020-12-24 03:37:43 +00:00
ef12ada5d7 Add parent to numbered list 2020-12-24 01:50:05 +00:00
977b2b302d Merge pull request #734 from dolanmiu/feat/strong-style
Add declarative break()
2020-12-24 00:21:07 +00:00
17d02a3d1c Fix demos 2020-12-24 00:00:24 +00:00
6100ff4c4e Add declarative break() 2020-12-23 23:31:28 +00:00
8bb73fb25e Merge pull request #729 from dolanmiu/feat/strong-style
Adding TableBorders.NONE convenience object
2020-12-23 00:28:34 +00:00
d6cce4ae15 Adding TableBorders.NONE convenience object 2020-12-22 23:42:02 +00:00
058304d16b Merge pull request #728 from dolanmiu/feat/strong-style
Add strong default style
2020-12-22 22:17:24 +00:00
345d34a2e1 Merge pull request #720 from dolanmiu/dependabot/npm_and_yarn/sinon-9.2.2
build(deps-dev): bump sinon from 9.2.1 to 9.2.2
2020-12-22 21:11:07 +00:00
3839a49d47 Merge pull request #726 from dolanmiu/dependabot/npm_and_yarn/prompt-1.1.0
build(deps-dev): bump prompt from 1.0.0 to 1.1.0
2020-12-22 21:10:57 +00:00
0afe0929a3 Add strong default style 2020-12-22 21:08:10 +00:00
a14a1fbd10 Update character style demo 2020-12-22 20:56:06 +00:00
52f0a6958a build(deps-dev): bump prompt from 1.0.0 to 1.1.0
Bumps [prompt](https://github.com/flatiron/prompt) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/flatiron/prompt/releases)
- [Changelog](https://github.com/flatiron/prompt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/flatiron/prompt/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-22 08:14:29 +00:00
8bdde98db1 build(deps-dev): bump sinon from 9.2.1 to 9.2.2
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.2.1 to 9.2.2.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/commits/v9.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-15 08:16:05 +00:00
19fc900045 Merge pull request #708 from dolanmiu/dependabot/npm_and_yarn/ts-node-9.1.1
build(deps-dev): bump ts-node from 9.1.0 to 9.1.1
2020-12-15 02:01:08 +00:00
6bdd9b882a Merge pull request #711 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.2.0
build(deps-dev): bump @types/mocha from 8.0.4 to 8.2.0
2020-12-15 02:00:53 +00:00
0d97d428fa Merge pull request #715 from dolanmiu/dependabot/npm_and_yarn/types/request-promise-4.1.47
build(deps-dev): bump @types/request-promise from 4.1.46 to 4.1.47
2020-12-15 02:00:08 +00:00
a0b42d7bdb Merge pull request #717 from dolanmiu/dependabot/npm_and_yarn/ini-1.3.8
build(deps): bump ini from 1.3.5 to 1.3.8
2020-12-15 01:59:54 +00:00
69ba312a96 build(deps): bump ini from 1.3.5 to 1.3.8
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.8)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-11 22:47:35 +00:00
a0c13214e6 build(deps-dev): bump @types/request-promise from 4.1.46 to 4.1.47
Bumps [@types/request-promise](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/request-promise) from 4.1.46 to 4.1.47.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/request-promise)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-11 08:22:49 +00:00
4c8829df28 build(deps-dev): bump @types/mocha from 8.0.4 to 8.2.0
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.0.4 to 8.2.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-09 08:04:12 +00:00
3ee3e95410 build(deps-dev): bump ts-node from 9.1.0 to 9.1.1
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 9.1.0 to 9.1.1.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v9.1.0...v9.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-08 08:49:26 +00:00
806deeaf78 Merge pull request #705 from dolanmiu/dependabot/npm_and_yarn/ts-node-9.1.0
build(deps-dev): bump ts-node from 9.0.0 to 9.1.0
2020-12-04 16:52:27 +00:00
feb121707d build(deps-dev): bump ts-node from 9.0.0 to 9.1.0
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 9.0.0 to 9.1.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v9.0.0...v9.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-12-03 08:01:46 +00:00
31c7f034ec Merge pull request #697 from devoidfury/master
Add defaultStyles option to overwrite the core default styles
2020-11-30 23:58:42 +00:00
30ab92652c move file options.defaultStyles to options.styles.default 2020-11-30 10:25:58 -06:00
0407548113 Merge pull request #702 from dolanmiu/dependabot/npm_and_yarn/prettier-2.2.1
build(deps-dev): bump prettier from 2.2.0 to 2.2.1
2020-11-30 14:48:17 +00:00
277845626c build(deps-dev): bump prettier from 2.2.0 to 2.2.1
Bumps [prettier](https://github.com/prettier/prettier) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.2.0...2.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-30 08:29:40 +00:00
b2af8b970e Merge pull request #693 from dolanmiu/dependabot/npm_and_yarn/prettier-2.2.0
build(deps-dev): bump prettier from 2.1.2 to 2.2.0
2020-11-29 20:16:38 +00:00
542866e18b Merge pull request #699 from dolanmiu/dependabot/npm_and_yarn/highlight.js-9.18.5
build(deps): [security] bump highlight.js from 9.18.1 to 9.18.5
2020-11-29 20:16:26 +00:00
f54192809f build(deps): [security] bump highlight.js from 9.18.1 to 9.18.5
Bumps [highlight.js](https://github.com/highlightjs/highlight.js) from 9.18.1 to 9.18.5. **This update includes a security fix.**
- [Release notes](https://github.com/highlightjs/highlight.js/releases)
- [Changelog](https://github.com/highlightjs/highlight.js/blob/9.18.5/CHANGES.md)
- [Commits](https://github.com/highlightjs/highlight.js/compare/9.18.1...9.18.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-24 23:10:41 +00:00
f3ba62fd88 bugfix path 2020-11-24 13:36:43 -06:00
8d4a07302b Add defaultStyles option to overwrite the core default styles (Heading 1-6, document, hyperlinks, etc) 2020-11-24 13:30:26 -06:00
d504231124 build(deps-dev): bump prettier from 2.1.2 to 2.2.0
Bumps [prettier](https://github.com/prettier/prettier) from 2.1.2 to 2.2.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.2...2.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-20 11:14:03 +00:00
173b1e118c Merge pull request #690 from dolanmiu/dependabot/npm_and_yarn/docsify-cli-4.4.2
build(deps-dev): bump docsify-cli from 4.4.1 to 4.4.2
2020-11-17 11:50:18 +00:00
ffba276f0d build(deps-dev): bump docsify-cli from 4.4.1 to 4.4.2
Bumps [docsify-cli](https://github.com/docsifyjs/docsify-cli) from 4.4.1 to 4.4.2.
- [Release notes](https://github.com/docsifyjs/docsify-cli/releases)
- [Changelog](https://github.com/docsifyjs/docsify-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/docsifyjs/docsify-cli/compare/v4.4.1...v4.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-17 11:13:13 +00:00
b210608e56 Merge pull request #685 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.0.4
build(deps-dev): bump @types/mocha from 8.0.3 to 8.0.4
2020-11-16 12:53:20 +00:00
74353104dc Merge pull request #687 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.25
build(deps-dev): bump @types/webpack from 4.41.24 to 4.41.25
2020-11-16 12:53:09 +00:00
825136d1c9 Version bump 2020-11-15 23:04:27 +00:00
b2fea471f1 Add workaround to include file in build 2020-11-15 23:03:44 +00:00
e9adb8b0ed build(deps-dev): bump @types/webpack from 4.41.24 to 4.41.25
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.41.24 to 4.41.25.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-12 08:27:51 +00:00
5d6bc039d0 build(deps-dev): bump @types/mocha from 8.0.3 to 8.0.4
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.0.3 to 8.0.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-11 07:56:26 +00:00
27638063c8 Update README.md 2020-11-06 02:08:09 +00:00
f6a4d78ab7 Add checks when submitting PR 2020-11-06 01:51:59 +00:00
4061e31400 Merge pull request #679 from dolanmiu/feat/re-name
Re-name paragraph styles
2020-11-06 01:47:49 +00:00
74db67689f Re-name paragraph styles 2020-11-06 00:27:57 +00:00
2213eb28cb Add Github Actions badge 2020-11-05 02:44:05 +00:00
d1b45d416b Fix spacing issue 2020-11-05 00:33:54 +00:00
f72f7e7514 Add build files to demo workflow 2020-11-05 00:17:55 +00:00
0165cfb3e5 Fix typo 2020-11-05 00:11:02 +00:00
ef747486c0 Remove comments 2020-11-04 23:40:59 +00:00
e0b2f59c2f Add initial GitHub Actions workflow 2020-11-04 23:36:28 +00:00
82bdb301f9 Version bump 2020-11-04 02:52:28 +00:00
c7ea26e422 Add tests 2020-11-04 01:28:46 +00:00
34b2029efe Change API of track revisions to declarative 2020-11-04 00:00:16 +00:00
37e610d2b3 Fix typo 2020-10-30 00:13:52 +00:00
4882235d20 Merge pull request #673 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.24
build(deps-dev): bump @types/webpack from 4.41.23 to 4.41.24
2020-10-29 23:56:22 +00:00
1552ebde11 build(deps-dev): bump @types/webpack from 4.41.23 to 4.41.24
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.41.23 to 4.41.24.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-29 22:54:05 +00:00
d263d0c8a5 Merge pull request #669 from dolanmiu/feat/background-color
Add shading to paragraph
2020-10-29 01:57:28 +00:00
610b2388bb Fix linting 2020-10-29 00:39:45 +00:00
bcb16cef9b Merge pull request #672 from dolanmiu/dependabot/npm_and_yarn/sinon-9.2.1
build(deps-dev): bump sinon from 9.2.0 to 9.2.1
2020-10-28 19:42:18 +00:00
0f3afd94f3 build(deps-dev): bump sinon from 9.2.0 to 9.2.1
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.2.0 to 9.2.1.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-28 15:28:10 +00:00
60eb686d05 Add shading to paragraph 2020-10-28 01:05:31 +00:00
7f5e43fba9 Merge pull request #667 from dolanmiu/feat/background-color
Background color for document
2020-10-27 02:45:19 +00:00
ed52ef358b Background color for document 2020-10-27 01:54:40 +00:00
214afab711 Merge branch 'master' of github.com:dolanmiu/docx 2020-10-24 21:38:30 +01:00
18a1677588 Add documentation reference 2020-10-24 21:38:20 +01:00
cae372e9ad Merge pull request #664 from dolanmiu/dependabot/npm_and_yarn/shortid-2.2.16
build(deps): bump shortid from 2.2.15 to 2.2.16
2020-10-24 21:03:53 +01:00
ea5f9a48ab Fix cantSplit documentation 2020-10-24 20:24:10 +01:00
dcf755e756 build(deps): bump shortid from 2.2.15 to 2.2.16
Bumps [shortid](https://github.com/dylang/shortid) from 2.2.15 to 2.2.16.
- [Release notes](https://github.com/dylang/shortid/releases)
- [Changelog](https://github.com/dylang/shortid/blob/master/CHANGELOG.md)
- [Commits](https://github.com/dylang/shortid/compare/2.2.15...2.2.16)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-24 00:40:43 +00:00
d445c21ea1 Merge pull request #662 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.23
build(deps-dev): bump @types/webpack from 4.41.22 to 4.41.23
2020-10-22 16:51:33 +01:00
6db0449ed0 build(deps-dev): bump @types/webpack from 4.41.22 to 4.41.23
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.41.22 to 4.41.23.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-21 11:55:53 +00:00
ae37b1980f Update Prettier 2020-10-16 16:20:04 +01:00
96f76906c4 Merge pull request #381 from dolanmiu/feat/math
MathML
2020-10-13 03:08:43 +01:00
19d9619785 Add more math documentation 2020-10-13 03:00:14 +01:00
5be195fd91 Turn math component into array 2020-10-13 02:06:27 +01:00
e36e9e1cf4 Add initial math documentation 2020-10-13 01:23:27 +01:00
102d6aa55c Add prepForXml test 2020-10-12 22:48:38 +01:00
daea8d2868 Make fractions take math component 2020-10-12 22:13:03 +01:00
700a74fd4c More math components 2020-10-10 13:41:26 +01:00
32a84a5ad0 Merge branch 'master' into feat/math 2020-10-08 10:25:45 +01:00
3c9f9474ce Merge pull request #653 from dolanmiu/dependabot/npm_and_yarn/sinon-9.2.0
build(deps-dev): bump sinon from 9.1.0 to 9.2.0
2020-10-07 11:49:11 +01:00
1e10686315 Merge pull request #644 from branzillacorp/track-revisions
basic support for track revisions
2020-10-07 11:48:47 +01:00
cae6405d9a improved signature for deleted text runs, added demo 54 and added documentation for change tracking 2020-10-07 11:44:23 +02:00
a884ce94e5 build(deps-dev): bump sinon from 9.1.0 to 9.2.0
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.1.0 to 9.2.0.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v9.1.0...v9.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-07 08:55:47 +00:00
065c17de74 style fixes 2020-10-06 11:05:52 +02:00
09db2c528a added InsertedTextRun and DeletedTextRun for Revision Tracking 2020-10-06 11:05:52 +02:00
2adfe532dd add more unit tests for trackRevision settings 2020-10-06 11:05:52 +02:00
6cbe40cecb add settings option to add trackRevisions 2020-10-06 11:05:52 +02:00
6b9467393e Merge pull request #651 from dolanmiu/dependabot/npm_and_yarn/sinon-9.1.0
build(deps-dev): bump sinon from 9.0.3 to 9.1.0
2020-10-05 22:31:28 +01:00
5125e77431 build(deps-dev): bump sinon from 9.0.3 to 9.1.0
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.0.3 to 9.1.0.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v9.0.3...v9.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-05 19:38:42 +00:00
ab68ae0092 Merge pull request #640 from dolanmiu/dependabot/npm_and_yarn/prettier-2.1.2
build(deps-dev): bump prettier from 2.1.1 to 2.1.2
2020-09-26 17:40:57 +01:00
38079b6171 build(deps-dev): bump prettier from 2.1.1 to 2.1.2
Bumps [prettier](https://github.com/prettier/prettier) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.1...2.1.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-21 18:43:32 +00:00
d584290f3d Merge pull request #635 from dolanmiu/dependabot/npm_and_yarn/node-fetch-2.6.1
build(deps): [security] bump node-fetch from 2.6.0 to 2.6.1
2020-09-13 03:01:42 +01:00
9b9baa9b4a Merge pull request #636 from netbymatt/master
Fix row height option documentation
2020-09-13 03:01:30 +01:00
c258310560 Merge pull request #1 from netbymatt/netbymatt-patch-1
Fix row height option
2020-09-11 21:10:45 -05:00
af0bf5ced5 Fix row height option 2020-09-11 21:10:10 -05:00
57c480a6c6 build(deps): [security] bump node-fetch from 2.6.0 to 2.6.1
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1. **This update includes a security fix.**
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-11 16:44:55 +00:00
25f7423533 Merge pull request #633 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.22
build(deps-dev): bump @types/webpack from 4.41.21 to 4.41.22
2020-09-08 12:44:14 +01:00
0c068bb03b build(deps-dev): bump @types/webpack from 4.41.21 to 4.41.22
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.41.21 to 4.41.22.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-09-07 18:39:58 +00:00
1822473abc Merge branch 'master' of github.com:dolanmiu/docx 2020-09-05 18:52:05 +01:00
93a7d607b2 Update PSD 2020-09-05 18:51:50 +01:00
d45213636c Add Clippy to readme 2020-09-05 18:41:24 +01:00
e196d9d917 Add Clippy the mascot 2020-09-05 18:40:40 +01:00
cf88e50afd Merge pull request #630 from dolanmiu/dependabot/npm_and_yarn/prettier-2.1.1
build(deps-dev): bump prettier from 2.1.0 to 2.1.1
2020-08-31 22:06:05 +01:00
64e5814c31 Merge pull request #631 from dolanmiu/dependabot/npm_and_yarn/types/node-14.6.2
build(deps): bump @types/node from 14.6.0 to 14.6.2
2020-08-31 22:05:54 +01:00
37251c84f8 build(deps): bump @types/node from 14.6.0 to 14.6.2
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.6.0 to 14.6.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-31 19:37:11 +00:00
a576098639 build(deps-dev): bump prettier from 2.1.0 to 2.1.1
Bumps [prettier](https://github.com/prettier/prettier) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.1.0...2.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-31 19:36:39 +00:00
2450fe83ce Merge pull request #624 from dolanmiu/dependabot/npm_and_yarn/ts-node-9.0.0
build(deps-dev): bump ts-node from 8.10.2 to 9.0.0
2020-08-27 01:13:34 +01:00
e1004440d2 Merge pull request #625 from dolanmiu/dependabot/npm_and_yarn/prettier-2.1.0
build(deps-dev): bump prettier from 2.0.5 to 2.1.0
2020-08-27 01:13:15 +01:00
491c7abd1c build(deps-dev): bump prettier from 2.0.5 to 2.1.0
Bumps [prettier](https://github.com/prettier/prettier) from 2.0.5 to 2.1.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.0.5...2.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-24 18:36:24 +00:00
364ce6d856 build(deps-dev): bump ts-node from 8.10.2 to 9.0.0
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 8.10.2 to 9.0.0.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v8.10.2...v9.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-24 18:35:48 +00:00
ffb6b73bb7 Merge pull request #618 from dolanmiu/dependabot/npm_and_yarn/dot-prop-4.2.1
build(deps): [security] bump dot-prop from 4.2.0 to 4.2.1
2020-08-21 23:55:11 +01:00
6041c39a26 Merge pull request #619 from dolanmiu/dependabot/npm_and_yarn/types/node-14.6.0
build(deps): bump @types/node from 14.0.27 to 14.6.0
2020-08-21 23:54:59 +01:00
c54f0a52f6 Merge pull request #621 from RayBB/patch-1
remove broken examples link
2020-08-21 23:54:42 +01:00
6b87d9c038 Merge pull request #620 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.0.3
build(deps-dev): bump @types/mocha from 8.0.2 to 8.0.3
2020-08-21 23:54:21 +01:00
1285304f97 remove broken examples link 2020-08-19 10:54:27 -10:00
58fae6b201 build(deps-dev): bump @types/mocha from 8.0.2 to 8.0.3
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.0.2 to 8.0.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-18 08:30:15 +00:00
dc1f3aebe9 build(deps): bump @types/node from 14.0.27 to 14.6.0
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.0.27 to 14.6.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-18 08:29:38 +00:00
8a189161f2 build(deps): [security] bump dot-prop from 4.2.0 to 4.2.1
Bumps [dot-prop](https://github.com/sindresorhus/dot-prop) from 4.2.0 to 4.2.1. **This update includes a security fix.**
- [Release notes](https://github.com/sindresorhus/dot-prop/releases)
- [Commits](https://github.com/sindresorhus/dot-prop/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-18 08:28:30 +00:00
6667595627 Merge pull request #615 from dolanmiu/dependabot/npm_and_yarn/sinon-9.0.3
build(deps-dev): bump sinon from 9.0.2 to 9.0.3
2020-08-13 01:27:02 +01:00
33befaab09 Merge pull request #616 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.0.2
build(deps-dev): bump @types/mocha from 8.0.1 to 8.0.2
2020-08-12 22:52:13 +01:00
c91f135c28 build(deps-dev): bump @types/mocha from 8.0.1 to 8.0.2
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.0.1 to 8.0.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-12 08:37:49 +00:00
08f9926e60 build(deps-dev): bump sinon from 9.0.2 to 9.0.3
Bumps [sinon](https://github.com/sinonjs/sinon) from 9.0.2 to 9.0.3.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-11 08:38:15 +00:00
f323b293fb Merge pull request #606 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.0.1
build(deps-dev): bump @types/mocha from 8.0.0 to 8.0.1
2020-08-08 01:36:47 +01:00
adc91929b0 Merge pull request #609 from LeovR/patch-1
Fix comment regarding output file name
2020-08-08 01:36:34 +01:00
c63cba5a0c Merge pull request #610 from dolanmiu/dependabot/npm_and_yarn/prismjs-1.21.0
build(deps): [security] bump prismjs from 1.20.0 to 1.21.0
2020-08-08 01:36:01 +01:00
e65e7d6a32 Add custom properties demo 2020-08-08 11:01:21 +12:00
7a48da440b build(deps): [security] bump prismjs from 1.20.0 to 1.21.0
Bumps [prismjs](https://github.com/PrismJS/prism) from 1.20.0 to 1.21.0. **This update includes a security fix.**
- [Release notes](https://github.com/PrismJS/prism/releases)
- [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PrismJS/prism/compare/v1.20.0...v1.21.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-07 22:43:32 +00:00
05dda37b71 Fix comment regarding output file name 2020-08-06 08:56:02 +00:00
fc87a73259 Remove unnecessary properties getter 2020-08-04 09:15:20 +12:00
ec4c4fb5c4 Run updated prettier 2020-08-04 08:50:56 +12:00
ee43585210 build(deps-dev): bump @types/mocha from 8.0.0 to 8.0.1
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-03 09:48:31 +00:00
870c222dd5 Allow custom text properties to be included 2020-08-03 17:08:04 +12:00
a6eb8e01df Merge pull request #604 from dolanmiu/feat/prettier-update
Update tslint to v6
2020-08-01 18:04:47 +01:00
8c45c30753 Merge pull request #598 from dolanmiu/dependabot/npm_and_yarn/rimraf-3.0.2
build(deps-dev): bump rimraf from 2.6.3 to 3.0.2
2020-08-01 17:58:31 +01:00
d18cfbc26f Update tslint to v6 2020-08-01 17:58:16 +01:00
f4af5f9e33 Merge pull request #603 from dolanmiu/feat/prettier-update
Update prettier
2020-08-01 17:55:38 +01:00
69adbbc1c1 Bump node version 2020-08-01 17:49:25 +01:00
4f6a9f734c Update prettier 2020-08-01 17:40:57 +01:00
8b78f2d200 Version bump 2020-08-01 17:28:11 +01:00
26a3fa6946 Merge pull request #596 from SpringMT/master
feat: Add decimalFullWidth numbering type
2020-08-01 17:25:12 +01:00
f955a18936 build(deps-dev): bump rimraf from 2.6.3 to 3.0.2
Bumps [rimraf](https://github.com/isaacs/rimraf) from 2.6.3 to 3.0.2.
- [Release notes](https://github.com/isaacs/rimraf/releases)
- [Changelog](https://github.com/isaacs/rimraf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/isaacs/rimraf/compare/v2.6.3...v3.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-01 01:59:37 +00:00
ee1a7818b6 Merge pull request #600 from dolanmiu/dependabot/npm_and_yarn/ts-node-8.10.2
build(deps-dev): bump ts-node from 7.0.1 to 8.10.2
2020-08-01 02:57:50 +01:00
8e455f1097 Merge pull request #601 from dolanmiu/dependabot/npm_and_yarn/nyc-15.1.0
build(deps-dev): bump nyc from 14.1.1 to 15.1.0
2020-08-01 02:56:06 +01:00
827c46cf47 build(deps-dev): bump nyc from 14.1.1 to 15.1.0
Bumps [nyc](https://github.com/istanbuljs/nyc) from 14.1.1 to 15.1.0.
- [Release notes](https://github.com/istanbuljs/nyc/releases)
- [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-31 09:08:10 +00:00
61cbee829d build(deps-dev): bump ts-node from 7.0.1 to 8.10.2
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 7.0.1 to 8.10.2.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](https://github.com/TypeStrong/ts-node/compare/v7.0.1...v8.10.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-31 09:06:34 +00:00
f0ad1e9194 feat: Add decimalFullWidth numbering type 2020-07-31 16:36:56 +09:00
bbd339f0e4 Merge pull request #571 from dolanmiu/dependabot/npm_and_yarn/sinon-9.0.2
Bump sinon from 5.1.1 to 9.0.2
2020-07-30 13:23:18 +01:00
858af64dc3 Improve coverage threshold 2020-07-30 13:07:48 +01:00
01e34c1b28 Bump sinon from 5.1.1 to 9.0.2
Bumps [sinon](https://github.com/sinonjs/sinon) from 5.1.1 to 9.0.2.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v5.1.1...v9.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-30 10:48:07 +00:00
41acb475a9 Update documentation 2020-07-30 11:42:55 +01:00
20978f8c24 Merge pull request #578 from dolanmiu/dependabot/npm_and_yarn/types/request-promise-4.1.46
Bump @types/request-promise from 4.1.44 to 4.1.46
2020-07-30 10:09:50 +01:00
265a3dbe21 Merge pull request #592 from dolanmiu/dependabot/npm_and_yarn/types/jszip-3.4.1
Bump @types/jszip from 3.1.6 to 3.4.1
2020-07-30 10:09:21 +01:00
627f5b4bf0 Merge pull request #593 from dolanmiu/dependabot/npm_and_yarn/types/node-14.0.27
Bump @types/node from 14.0.23 to 14.0.27
2020-07-30 10:08:55 +01:00
1538c1aaeb Merge pull request #594 from dolanmiu/dependabot/npm_and_yarn/types/webpack-4.41.21
Bump @types/webpack from 4.4.34 to 4.41.21
2020-07-30 10:08:32 +01:00
839661e5f8 Bump @types/webpack from 4.4.34 to 4.41.21
Bumps [@types/webpack](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/webpack) from 4.4.34 to 4.41.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/webpack)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-30 08:50:39 +00:00
fff6244597 Bump @types/node from 14.0.23 to 14.0.27
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.0.23 to 14.0.27.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-30 08:49:24 +00:00
b2280f64a1 Bump @types/jszip from 3.1.6 to 3.4.1
Bumps [@types/jszip](https://github.com/Stuk/jszip) from 3.1.6 to 3.4.1.
- [Release notes](https://github.com/Stuk/jszip/releases)
- [Changelog](https://github.com/Stuk/jszip/blob/master/CHANGES.md)
- [Commits](https://github.com/Stuk/jszip/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-30 08:48:47 +00:00
21d53c41d0 Bump @types/request-promise from 4.1.44 to 4.1.46
Bumps [@types/request-promise](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/request-promise) from 4.1.44 to 4.1.46.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/request-promise)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-30 01:44:26 +00:00
6e94bbb5e5 Merge pull request #588 from dolanmiu/dependabot/npm_and_yarn/typedoc-0.16.11
Bump typedoc from 0.11.1 to 0.16.11
2020-07-30 02:41:09 +01:00
7d655cd3f7 Merge pull request #589 from dolanmiu/dependabot/npm_and_yarn/shelljs-0.8.4
Bump shelljs from 0.7.8 to 0.8.4
2020-07-30 02:40:43 +01:00
00821677c8 Merge pull request #591 from dolanmiu/dependabot/npm_and_yarn/elliptic-6.5.3
[Security] Bump elliptic from 6.5.0 to 6.5.3
2020-07-30 02:40:28 +01:00
784de3e430 [Security] Bump elliptic from 6.5.0 to 6.5.3
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.0 to 6.5.3. **This update includes a security fix.**
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.0...v6.5.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-29 21:32:19 +00:00
3213c4838d Bump shelljs from 0.7.8 to 0.8.4
Bumps [shelljs](https://github.com/shelljs/shelljs) from 0.7.8 to 0.8.4.
- [Release notes](https://github.com/shelljs/shelljs/releases)
- [Changelog](https://github.com/shelljs/shelljs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/shelljs/shelljs/compare/v0.7.8...v0.8.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-28 08:43:57 +00:00
1b9bc8eb1d Bump typedoc from 0.11.1 to 0.16.11
Bumps [typedoc](https://github.com/TypeStrong/TypeDoc) from 0.11.1 to 0.16.11.
- [Release notes](https://github.com/TypeStrong/TypeDoc/releases)
- [Commits](https://github.com/TypeStrong/TypeDoc/compare/v0.11.1...v0.16.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-28 08:43:10 +00:00
bf58d0b864 Merge pull request #581 from dolanmiu/dependabot/npm_and_yarn/docsify-cli-4.4.1
Bump docsify-cli from 4.3.0 to 4.4.1
2020-07-27 19:38:06 +01:00
28ca8392ed Merge pull request #577 from dolanmiu/dependabot/npm_and_yarn/request-2.88.2
Bump request from 2.88.0 to 2.88.2
2020-07-27 19:37:53 +01:00
5238c55bc2 Bump docsify-cli from 4.3.0 to 4.4.1
Bumps [docsify-cli](https://github.com/QingWei-Li/docsify-cli) from 4.3.0 to 4.4.1.
- [Release notes](https://github.com/QingWei-Li/docsify-cli/releases)
- [Changelog](https://github.com/docsifyjs/docsify-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/QingWei-Li/docsify-cli/compare/v4.3.0...v4.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 09:10:52 +00:00
901f10c387 Bump request from 2.88.0 to 2.88.2
Bumps [request](https://github.com/request/request) from 2.88.0 to 2.88.2.
- [Release notes](https://github.com/request/request/releases)
- [Changelog](https://github.com/request/request/blob/master/CHANGELOG.md)
- [Commits](https://github.com/request/request/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-27 09:10:49 +00:00
defa22ffe5 Merge pull request #585 from dolanmiu/dependabot/npm_and_yarn/request-promise-4.2.6
Bump request-promise from 4.2.4 to 4.2.6
2020-07-27 10:08:50 +01:00
84919c0cc0 Update README.md 2020-07-27 09:56:30 +01:00
1e8ca123b0 Bump request-promise from 4.2.4 to 4.2.6
Bumps [request-promise](https://github.com/request/request-promise) from 4.2.4 to 4.2.6.
- [Release notes](https://github.com/request/request-promise/releases)
- [Commits](https://github.com/request/request-promise/compare/v4.2.4...v4.2.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-22 08:57:50 +00:00
3ae7c6aedf Merge pull request #568 from dolanmiu/dependabot/npm_and_yarn/jszip-3.5.0
Bump jszip from 3.2.2 to 3.5.0
2020-07-18 03:00:56 +01:00
6a3ed4bbf8 Merge pull request #567 from dolanmiu/dependabot/npm_and_yarn/handlebars-4.7.6
[Security] Bump handlebars from 4.5.3 to 4.7.6
2020-07-18 02:56:33 +01:00
e632d323c9 Merge pull request #570 from dolanmiu/dependabot/npm_and_yarn/types/mocha-8.0.0
Bump @types/mocha from 2.2.48 to 8.0.0
2020-07-18 02:56:09 +01:00
d2b35ab8f2 Merge pull request #566 from dolanmiu/dependabot/npm_and_yarn/types/node-14.0.23
Bump @types/node from 14.0.5 to 14.0.23
2020-07-18 02:55:32 +01:00
e60f39df41 Merge pull request #572 from dolanmiu/dependabot/npm_and_yarn/lodash-4.17.19
[Security] Bump lodash from 4.17.15 to 4.17.19
2020-07-18 02:55:09 +01:00
076431e04d Merge pull request #574 from dolanmiu/dependabot/npm_and_yarn/types/sinon-9.0.4
Bump @types/sinon from 4.3.3 to 9.0.4
2020-07-18 02:54:47 +01:00
75ab44403c Merge pull request #575 from dolanmiu/dependabot/npm_and_yarn/glob-7.1.6
Bump glob from 7.1.4 to 7.1.6
2020-07-18 02:54:28 +01:00
e2d6097819 Bump glob from 7.1.4 to 7.1.6
Bumps [glob](https://github.com/isaacs/node-glob) from 7.1.4 to 7.1.6.
- [Release notes](https://github.com/isaacs/node-glob/releases)
- [Changelog](https://github.com/isaacs/node-glob/blob/master/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v7.1.4...v7.1.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 08:43:39 +00:00
ab12ff1257 Bump @types/sinon from 4.3.3 to 9.0.4
Bumps [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/sinon) from 4.3.3 to 9.0.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/sinon)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 08:42:58 +00:00
25a0212f4e [Security] Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. **This update includes a security fix.**
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-17 08:41:22 +00:00
a8993f14d6 Bump @types/mocha from 2.2.48 to 8.0.0
Bumps [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha) from 2.2.48 to 8.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 20:26:36 +00:00
1834cd86da Bump jszip from 3.2.2 to 3.5.0
Bumps [jszip](https://github.com/Stuk/jszip) from 3.2.2 to 3.5.0.
- [Release notes](https://github.com/Stuk/jszip/releases)
- [Changelog](https://github.com/Stuk/jszip/blob/master/CHANGES.md)
- [Commits](https://github.com/Stuk/jszip/compare/v3.2.2...v3.5.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 20:25:38 +00:00
437de27ed8 [Security] Bump handlebars from 4.5.3 to 4.7.6
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.5.3 to 4.7.6. **This update includes a security fix.**
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.5.3...v4.7.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 20:25:17 +00:00
96f08482da Bump @types/node from 14.0.5 to 14.0.23
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.0.5 to 14.0.23.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-07-16 20:24:56 +00:00
edec2eca7a Add another React example 2020-07-16 16:08:50 +01:00
9202524d83 Fix Vue.js stylistics 2020-07-16 14:15:47 +01:00
0461907533 Add VueJS example 2020-07-16 14:13:55 +01:00
6b3d1d5579 modifications make to table-row files to correct table-row height property. Code was previously using height.height ini setHeight but should instead be using value. 2020-07-16 12:37:24 +00:00
445a2896d2 Add React example 2020-07-16 12:35:47 +01:00
e2d8f1b6b1 Merge pull request #562 from wangfengming/master
Feature: refine paragraph/run properties options
2020-07-15 10:30:24 +01:00
7baa696a76 :feat: coverage ignore file src/import-dotx/import-dotx.ts 2020-07-15 14:11:59 +08:00
3f7ca6bbff :test: document defaults & numbering suffix 2020-07-15 14:11:26 +08:00
36e1c5fe6a :feat: refined defaults 2020-07-15 14:10:37 +08:00
75a03f1576 :test: update test for complex script 2020-07-15 12:46:46 +08:00
437e83ab78 :feat: refine paragraph/run properties options 2020-07-14 15:42:45 +08:00
b8232f7a02 Version bump 2020-07-11 19:34:29 +01:00
49eadb0efc Merge pull request #559 from wangfengming/master
:fix: `rowSpan` can't work when column index out of range
2020-07-09 01:29:06 +01:00
40dc90e585 :fix: insert the continue cell properly 2020-07-08 12:32:01 +08:00
0de302d192 :typo: update comments 2020-07-08 11:26:24 +08:00
80bab95f6c :fix: rowSpan can't work when column index out of range 2020-07-08 10:55:15 +08:00
ba3d551c9f Version bump 2020-06-29 01:17:13 +01:00
d14fe31f97 Merge pull request #553 from wangfengming/master
Fix: `rowSpan` does not work correctly
2020-06-24 16:39:57 +01:00
057f41e355 :test: more test cases 2020-06-22 12:34:08 +08:00
8c9b61b37a :fix: handle rowSpan by convert between the virtual column index and the root index 2020-06-22 12:25:51 +08:00
11e54b3e2c :fix: handle cell that has both columnSpan and rowSpan 2020-06-20 21:36:35 +08:00
fa7cb0bef1 :test: add test case for columnSpan and rowSpan 2020-06-20 21:01:23 +08:00
3977c8ab3b :fix: rowSpan continue cell should has the same border to the first row cell 2020-06-20 20:20:22 +08:00
e8f92efe05 Merge pull request #2 from dolanmiu/master
merge from origin
2020-06-20 20:05:20 +08:00
994df8531b :fix: rowSpan does not work correctly 2020-06-20 19:47:46 +08:00
3cdf96ee0c Version bump 2020-06-17 14:34:27 +01:00
e2f55d52e9 Merge pull request #550 from wangfengming/feature/enhance-font
Feature/enhance font
2020-06-13 20:38:22 +01:00
d6fa33035a :doc: update demo 53-chinese.ts 2020-06-07 14:58:59 +08:00
f11bca728f :typo: update comment for the demo 2020-06-07 12:46:21 +08:00
596761d78d :doc: doc and demo for "Font for eastAsia" 2020-06-07 12:39:17 +08:00
8a3c8d4664 :test: Font for eastAsia 2020-06-07 12:38:31 +08:00
fdfce79e87 :feat: Font for eastAsia 2020-06-07 12:38:03 +08:00
88340aa336 Merge pull request #1 from dolanmiu/master
merge from origin
2020-06-03 19:04:55 +08:00
d0f53fdd4b Merge branch 'master' of github.com:dolanmiu/docx
# Conflicts:
#	package-lock.json
2020-05-28 18:40:44 +01:00
d657f61e11 Update node types 2020-05-28 18:38:55 +01:00
3ea106bd22 Merge pull request #546 from wangfengming/feature/emphasis-mark
Feature/emphasis mark
2020-05-22 13:29:25 +01:00
538264dec5 :demo: support emphasis mark 2020-05-22 12:56:02 +08:00
6bcd1c2c24 :doc: support emphasis mark 2020-05-22 12:32:40 +08:00
120c3a7bbe :feat: support emphasis mark 2020-05-22 12:22:45 +08:00
5bca7d155f Restart page numbering
Add separator option
2020-02-28 18:44:41 +00:00
db7c4da609 Add ability to add multiple text runs to a bookmark 2020-01-01 22:54:42 +00:00
9c11653313 Multiple paragraphs in footnotes 2020-01-01 20:22:42 +00:00
9aab68a8f8 Merge branch 'master' into feat/math
# Conflicts:
#	src/file/paragraph/index.ts
#	src/file/paragraph/paragraph.ts
2019-11-01 02:43:14 +00:00
2100b7b7d2 Updated custom styles 2019-10-24 20:18:52 -05:00
2cf1cce06d Adds demo to show XML StyleId applied to a table 2019-10-24 13:46:39 -05:00
4ca44d335d Adds setStyle to spec 2019-10-21 13:09:44 -05:00
358d578cd7 Moves setStyle to be the first set property
This allows other settings as width to be overriden
2019-10-21 13:09:04 -05:00
c61d24d8d4 Allows user to specify style id for Tables
Allows user to specify the style Id which will be added in the form of:
<w:tblStyle w:val="TableGrid"/>

As specified in table Structure in http://officeopenxml.com/WPtable.php
2019-10-21 11:40:05 -05:00
4f8d435e16 Add Math Summation 2019-08-20 20:40:40 +01:00
a1b9be453b Add math run and fraction 2019-08-15 00:47:55 +01:00
413 changed files with 16995 additions and 6382 deletions

View File

@ -7,6 +7,7 @@ indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
[*.md]
max_line_length = off

9
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,9 @@
# Thank you for raising an issue to `docx`
Please do not raise an issue unless it is an **issue**.
- Is your issue a feature request? Are you giving ideas to the community? Are you asking for help? Please raise a ticket in the `Discussions` section:
https://github.com/dolanmiu/docx/discussions
- Is your issue a previously asked? Please respond to that thread instead

134
.github/workflows/default.yml vendored Normal file
View File

@ -0,0 +1,134 @@
name: Default
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: build
path: build
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm ci
- name: Test
run: npm run test.coverage
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm ci
- name: Lint
run: npm run lint
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm ci
- name: Prettier
run: npm run style
demos:
name: Run Demos
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm ci
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Run demos
run: |
npm run ts-node -- ./demo/1-basic.ts
npm run ts-node -- ./demo/2-declaritive-styles.ts
npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
npm run ts-node -- ./demo/4-basic-table.ts
npm run ts-node -- ./demo/5-images.ts
npm run ts-node -- ./demo/6-page-borders.ts
npm run ts-node -- ./demo/7-landscape.ts
npm run ts-node -- ./demo/8-header-footer.ts
npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
npm run ts-node -- ./demo/10-my-cv.ts
npm run ts-node -- ./demo/11-declaritive-styles-2.ts
npm run ts-node -- ./demo/12-scaling-images.ts
npm run ts-node -- ./demo/13-xml-styles.ts
npm run ts-node -- ./demo/14-page-numbers.ts
npm run ts-node -- ./demo/15-page-break-before.ts
npm run ts-node -- ./demo/16-multiple-sections.ts
npm run ts-node -- ./demo/17-footnotes.ts
npm run ts-node -- ./demo/18-image-from-buffer.ts
npm run ts-node -- ./demo/19-export-to-base64.ts
npm run ts-node -- ./demo/20-table-cell-borders.ts
npm run ts-node -- ./demo/21-bookmarks.ts
npm run ts-node -- ./demo/22-right-to-left-text.ts
npm run ts-node -- ./demo/23-base64-images.ts
npm run ts-node -- ./demo/24-images-to-table-cell.ts
npm run ts-node -- ./demo/25-table-xml-styles.ts
npm run ts-node -- ./demo/26-paragraph-borders.ts
npm run ts-node -- ./demo/27-declaritive-styles-3.ts
npm run ts-node -- ./demo/28-table-of-contents.ts
npm run ts-node -- ./demo/29-numbered-lists.ts
npm run ts-node -- ./demo/30-template-document.ts
npm run ts-node -- ./demo/31-tables.ts
npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
npm run ts-node -- ./demo/33-sequential-captions.ts
npm run ts-node -- ./demo/34-floating-tables.ts
npm run ts-node -- ./demo/35-hyperlinks.ts
npm run ts-node -- ./demo/36-image-to-table-cell.ts
npm run ts-node -- ./demo/37-images-to-header-and-footer.ts
npm run ts-node -- ./demo/38-text-wrapping.ts
npm run ts-node -- ./demo/39-page-numbers.ts
npm run ts-node -- ./demo/40-line-numbers.ts
npm run ts-node -- ./demo/41-merge-table-cells-2.ts
npm run ts-node -- ./demo/42-restart-page-numbers.ts
npm run ts-node -- ./demo/43-images-to-table-cell-2.ts
npm run ts-node -- ./demo/44-multiple-columns.ts
npm run ts-node -- ./demo/45-highlighting-text.ts
npm run ts-node -- ./demo/46-shading-text.ts
npm run ts-node -- ./demo/47-number-of-total-pages-section.ts
npm run ts-node -- ./demo/48-vertical-align.ts
npm run ts-node -- ./demo/49-table-borders.ts
npm run ts-node -- ./demo/50-readme-demo.ts
npm run ts-node -- ./demo/51-character-styles.ts
npm run ts-node -- ./demo/52-japanese.ts
npm run ts-node -- ./demo/53-chinese.ts
npm run ts-node -- ./demo/54-custom-properties.ts
npm run ts-node -- ./demo/55-math.ts
npm run ts-node -- ./demo/56-background-color.ts
npm run ts-node -- ./demo/57-add-parent-numbered-lists.ts
npm run ts-node -- ./demo/58-section-types.ts
npm run ts-node -- ./demo/59-header-footer-margins.ts
npm run ts-node -- ./demo/60-track-revisions.ts
npm run ts-node -- ./demo/61-text-frame.ts
npm run ts-node -- ./demo/62-paragraph-spacing.ts
npm run ts-node -- ./demo/63-odd-even-header-footer.ts

2
.nvmrc
View File

@ -1 +1 @@
v8
v10

11
.nycrc
View File

@ -1,14 +1,15 @@
{
"check-coverage": true,
"lines": 93.53,
"functions": 89.63,
"branches": 88.57,
"statements": 93.34,
"lines": 98.86,
"functions": 97.86,
"branches": 95.86,
"statements": 98.86,
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.spec.ts"
"src/**/*.spec.ts",
"src/import-dotx/import-dotx.ts"
],
"reporter": [
"lcov",

View File

@ -1,6 +1,6 @@
language: node_js
node_js:
- 9
- 10
install:
- npm install
- npm install -g codecov

View File

@ -11,6 +11,7 @@
[![NPM version][npm-image]][npm-url]
[![Downloads per month][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![Known Vulnerabilities][snky-image]][snky-url]
[![Chat on Gitter][gitter-image]][gitter-url]
@ -18,7 +19,7 @@
[![codecov][codecov-image]][codecov-url]
<p align="center">
<img src="https://i.imgur.com/TCH0YzD.png" alt="drawing" width="800"/>
<img src="https://i.imgur.com/tBO0XBR.png" alt="drawing"/>
</p>
# Demo
@ -32,7 +33,16 @@ Here are examples of `docx` being used with basic `HTML/JS` in a browser environ
Here is an example of `docx` working in `Angular`:
* https://stackblitz.com/edit/angular-afvxtz
* https://stackblitz.com/edit/angular-docx
Here is an example of `docx` working in `React`:
* https://stackblitz.com/edit/react-docx
* https://stackblitz.com/edit/react-docx-images (adding images to Word Document)
Here is an example of `docx` working in `Vue.js`:
* https://stackblitz.com/edit/vuejs-docx
## Node
@ -50,7 +60,7 @@ Press `endpoint` on the `RunKit` website:
* https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
More [here](https://docx.js.org/#/examples) and [here](https://github.com/dolanmiu/docx/tree/master/demo)
More [here](https://github.com/dolanmiu/docx/tree/master/demo)
# How to use & Documentation
@ -58,7 +68,7 @@ Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/
# Examples
Check the `examples` section in the [documentation](https://docx.js.org/#/examples) and the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
# Contributing
@ -74,8 +84,10 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
[<img src="https://i.imgur.com/1LjuK2M.png" alt="drawing" height="50"/>](https://turbopatent.com/)
[<img src="https://i.imgur.com/dHMg0wF.gif" alt="drawing" height="50"/>](http://www.madisoncres.com/)
[<img src="https://i.imgur.com/QEZXU5b.png" alt="drawing" height="50"/>](https://www.beekast.com/)
[<img src="https://imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
[<img src="https://i.imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
[<img src="https://i.imgur.com/fn1xccG.png" alt="drawing" height="50"/>](http://www.ativer.com.br/)
[<img src="https://i.imgur.com/cmykN7c.png" alt="drawing" />](https://www.arity.co/)
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
...and many more!
@ -93,6 +105,8 @@ Made with 💖
[downloads-url]: https://npmjs.org/package/docx
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
[travis-url]: https://travis-ci.org/dolanmiu/docx
[github-actions-workflow-image]: https://github.com/dolanmiu/docx/workflows/Default/badge.svg
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/dolanmiu/docx
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg

View File

@ -3,24 +3,26 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
properties: {},
children: [
new Paragraph({
const doc = new Document({
sections: [
{
properties: {},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
}),
},
],
});

View File

@ -129,70 +129,76 @@ const achievements = [
class DocumentCreator {
// tslint:disable-next-line: typedef
public create([experiences, educations, skills, achivements]): Document {
const document = new Document();
const document = new Document({
sections: [
{
children: [
new Paragraph({
text: "Dolan Miu",
heading: HeadingLevel.TITLE,
}),
this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL),
this.createHeading("Education"),
...educations
.map((education) => {
const arr: Paragraph[] = [];
arr.push(
this.createInstitutionHeader(
education.schoolName,
`${education.startDate.year} - ${education.endDate.year}`,
),
);
arr.push(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
document.addSection({
children: [
new Paragraph({
text: "Dolan Miu",
heading: HeadingLevel.TITLE,
}),
this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL),
this.createHeading("Education"),
...educations
.map((education) => {
const arr: Paragraph[] = [];
arr.push(
this.createInstitutionHeader(education.schoolName, `${education.startDate.year} - ${education.endDate.year}`),
);
arr.push(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
bulletPoints.forEach((bulletPoint) => {
arr.push(this.createBullet(bulletPoint));
});
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
bulletPoints.forEach((bulletPoint) => {
arr.push(this.createBullet(bulletPoint));
});
return arr;
})
.reduce((prev, curr) => prev.concat(curr), []),
this.createHeading("Experience"),
...experiences
.map((position) => {
const arr: Paragraph[] = [];
return arr;
})
.reduce((prev, curr) => prev.concat(curr), []),
this.createHeading("Experience"),
...experiences
.map((position) => {
const arr: Paragraph[] = [];
arr.push(
this.createInstitutionHeader(
position.company.name,
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
),
);
arr.push(this.createRoleText(position.title));
arr.push(
this.createInstitutionHeader(
position.company.name,
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
),
);
arr.push(this.createRoleText(position.title));
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
bulletPoints.forEach((bulletPoint) => {
arr.push(this.createBullet(bulletPoint));
});
bulletPoints.forEach((bulletPoint) => {
arr.push(this.createBullet(bulletPoint));
});
return arr;
})
.reduce((prev, curr) => prev.concat(curr), []),
this.createHeading("Skills, Achievements and Interests"),
this.createSubHeading("Skills"),
this.createSkillList(skills),
this.createSubHeading("Achievements"),
...this.createAchivementsList(achivements),
this.createSubHeading("Interests"),
this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."),
this.createHeading("References"),
new Paragraph(
"Dr. Dean Mohamedally Director of Postgraduate Studies Department of Computer Science, University College London Malet Place, Bloomsbury, London WC1E d.mohamedally@ucl.ac.uk",
),
new Paragraph("More references upon request"),
new Paragraph({
text: "This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
alignment: AlignmentType.CENTER,
}),
return arr;
})
.reduce((prev, curr) => prev.concat(curr), []),
this.createHeading("Skills, Achievements and Interests"),
this.createSubHeading("Skills"),
this.createSkillList(skills),
this.createSubHeading("Achievements"),
...this.createAchivementsList(achivements),
this.createSubHeading("Interests"),
this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."),
this.createHeading("References"),
new Paragraph(
"Dr. Dean Mohamedally Director of Postgraduate Studies Department of Computer Science, University College London Malet Place, Bloomsbury, London WC1E d.mohamedally@ucl.ac.uk",
),
new Paragraph("More references upon request"),
new Paragraph({
text:
"This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
alignment: AlignmentType.CENTER,
}),
],
},
],
});
@ -204,7 +210,10 @@ class DocumentCreator {
alignment: AlignmentType.CENTER,
children: [
new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`),
new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break(),
new TextRun({
text: "Address: 58 Elm Avenue, Kent ME4 6ER, UK",
break: 1,
}),
],
});
}

View File

@ -3,10 +3,11 @@
import * as fs from "fs";
import {
AlignmentType,
convertInchesToTwip,
Document,
Footer,
HeadingLevel,
Media,
ImageRun,
Packer,
Paragraph,
Table,
@ -16,15 +17,43 @@ import {
UnderlineType,
} from "../build";
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 1.")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 2.")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 3.")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 4.")],
}),
],
}),
],
});
const doc = new Document({
styles: {
paragraphStyles: [
{
id: "Heading1",
name: "Heading 1",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
default: {
heading1: {
run: {
font: "Calibri",
size: 52,
@ -40,12 +69,7 @@ const doc = new Document({
spacing: { line: 340 },
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
heading2: {
run: {
font: "Calibri",
size: 26,
@ -55,12 +79,7 @@ const doc = new Document({
spacing: { line: 340 },
},
},
{
id: "Heading3",
name: "Heading 3",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
heading3: {
run: {
font: "Calibri",
size: 26,
@ -70,12 +89,7 @@ const doc = new Document({
spacing: { line: 276 },
},
},
{
id: "Heading4",
name: "Heading 4",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
heading4: {
run: {
font: "Calibri",
size: 26,
@ -85,6 +99,8 @@ const doc = new Document({
alignment: AlignmentType.JUSTIFIED,
},
},
},
paragraphStyles: [
{
id: "normalPara",
name: "Normal Para",
@ -128,7 +144,7 @@ const doc = new Document({
},
paragraph: {
spacing: { line: 276 },
indent: { left: 720 },
indent: { left: convertInchesToTwip(0.5) },
},
},
{
@ -139,122 +155,113 @@ const doc = new Document({
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
},
},
{
id: "ListParagraph",
name: "List Paragraph",
basedOn: "Normal",
quickFormat: true,
},
],
},
});
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 1.")],
sections: [
{
properties: {
page: {
margin: {
top: 700,
right: 700,
bottom: 700,
left: 700,
},
},
},
footers: {
default: new Footer({
children: [
new Paragraph({
text: "1",
style: "normalPara",
alignment: AlignmentType.RIGHT,
}),
],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 2.")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 3.")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Test cell 4.")],
}),
],
}),
],
});
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
doc.addSection({
properties: {
top: 700,
right: 700,
bottom: 700,
left: 700,
},
footers: {
default: new Footer({
},
children: [
new Paragraph({
text: "1",
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
text: "HEADING",
heading: HeadingLevel.HEADING_1,
alignment: AlignmentType.CENTER,
}),
new Paragraph({
text: "Ref. :",
style: "normalPara",
alignment: AlignmentType.RIGHT,
}),
new Paragraph({
text: "Date :",
style: "normalPara",
}),
new Paragraph({
text: "To,",
style: "normalPara",
}),
new Paragraph({
text: "The Superindenting Engineer,(O &M)",
style: "normalPara",
}),
new Paragraph({
text: "Sub : ",
style: "normalPara",
}),
new Paragraph({
text: "Ref. : ",
style: "normalPara",
}),
new Paragraph({
text: "Sir,",
style: "normalPara",
}),
new Paragraph({
text: "BRIEF DESCRIPTION",
style: "normalPara",
}),
table,
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
text: "Test",
style: "normalPara2",
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
text: "Test 2",
style: "normalPara2",
}),
],
}),
},
children: [
new Paragraph(image),
new Paragraph({
text: "HEADING",
heading: HeadingLevel.HEADING_1,
alignment: AlignmentType.CENTER,
}),
new Paragraph({
text: "Ref. :",
style: "normalPara",
}),
new Paragraph({
text: "Date :",
style: "normalPara",
}),
new Paragraph({
text: "To,",
style: "normalPara",
}),
new Paragraph({
text: "The Superindenting Engineer,(O &M)",
style: "normalPara",
}),
new Paragraph({
text: "Sub : ",
style: "normalPara",
}),
new Paragraph({
text: "Ref. : ",
style: "normalPara",
}),
new Paragraph({
text: "Sir,",
style: "normalPara",
}),
new Paragraph({
text: "BRIEF DESCRIPTION",
style: "normalPara",
}),
table,
new Paragraph(image1),
new Paragraph({
text: "Test",
style: "normalPara2",
}),
new Paragraph(image2),
new Paragraph({
text: "Test 2",
style: "normalPara2",
}),
},
],
});

View File

@ -1,17 +1,60 @@
// Scaling images
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Media, Packer, Paragraph } from "../build";
import { Document, ImageRun, Packer, Paragraph } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 50, 50);
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 100, 100);
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 250, 250);
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 400, 400);
doc.addSection({
children: [new Paragraph("Hello World"), new Paragraph(image), new Paragraph(image2), new Paragraph(image3), new Paragraph(image4)],
const doc = new Document({
sections: [
{
children: [
new Paragraph("Hello World"),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 50,
height: 50,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 250,
height: 250,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 400,
height: 400,
},
}),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -7,23 +7,24 @@ const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
const doc = new Document({
title: "Title",
externalStyles: styles,
});
doc.addSection({
children: [
new Paragraph({
text: "Cool Heading Text",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: 'This is a custom named style from the template "MyFancyStyle"',
style: "MyFancyStyle",
}),
new Paragraph("Some normal text"),
new Paragraph({
text: "MyFancyStyle again",
style: "MyFancyStyle",
}),
sections: [
{
children: [
new Paragraph({
text: "Cool Heading Text",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: 'This is a custom named style from the template "MyFancyStyle"',
style: "MyFancyStyle",
}),
new Paragraph("Some normal text"),
new Paragraph({
text: "MyFancyStyle again",
style: "MyFancyStyle",
}),
],
},
],
});

View File

@ -1,44 +1,77 @@
// Page numbers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
const doc = new Document({
sections: [
{
properties: {
titlePage: true,
},
headers: {
default: new Header({
children: [
new TextRun("My Title "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("My Title "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
],
}),
first: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
first: new Header({
children: [
new TextRun("First Page Header "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("First Page Header "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("My Title "),
new TextRun({
children: ["Footer - Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
first: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("First Page Footer "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("First Page"), new PageBreak()],
}),
new Paragraph("Second Page"),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("First Page"), new PageBreak()],
}),
new Paragraph("Second Page"),
},
],
});

View File

@ -3,15 +3,17 @@
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
children: [
new Paragraph("Hello World"),
new Paragraph({
text: "Hello World on another page",
pageBreakBefore: true,
}),
const doc = new Document({
sections: [
{
children: [
new Paragraph("Hello World"),
new Paragraph({
text: "Hello World on another page",
pageBreakBefore: true,
}),
],
},
],
});

View File

@ -3,119 +3,142 @@
import * as fs from "fs";
import { Document, Footer, Header, Packer, PageNumber, PageNumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
const doc = new Document();
const doc = new Document({
sections: [
{
children: [new Paragraph("Hello World")],
},
{
properties: {
page: {
pageNumbers: {
start: 1,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: new Header({
children: [new Paragraph("First Default Header on another page")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer on another page")],
}),
},
doc.addSection({
children: [new Paragraph("Hello World")],
});
doc.addSection({
headers: {
default: new Header({
children: [new Paragraph("First Default Header on another page")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer on another page")],
}),
},
properties: {
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
children: [new Paragraph("hello")],
});
doc.addSection({
headers: {
default: new Header({
children: [new Paragraph("Second Default Header on another page")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer on another page")],
}),
},
size: {
orientation: PageOrientation.LANDSCAPE,
},
properties: {
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
children: [new Paragraph("hello in landscape")],
});
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
children: [new Paragraph("hello")],
},
{
properties: {
page: {
size: {
orientation: PageOrientation.LANDSCAPE,
},
pageNumbers: {
start: 1,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: new Header({
children: [new Paragraph("Second Default Header on another page")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer on another page")],
}),
},
children: [new Paragraph("hello in landscape")],
},
{
properties: {
page: {
size: {
orientation: PageOrientation.PORTRAIT,
},
},
},
headers: {
default: new Header({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
new Paragraph({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
}),
],
}),
],
}),
],
}),
},
size: {
orientation: PageOrientation.PORTRAIT,
},
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
});
},
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
},
{
properties: {
page: {
size: {
orientation: PageOrientation.PORTRAIT,
},
pageNumbers: {
formatType: PageNumberFormat.UPPER_ROMAN,
},
},
},
headers: {
default: new Header({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
new Paragraph({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
}),
],
}),
],
}),
],
}),
},
properties: {
pageNumberFormatType: PageNumberFormat.UPPER_ROMAN,
orientation: PageOrientation.PORTRAIT,
},
children: [
new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
),
],
});
doc.addSection({
headers: {
default: new Header({
},
children: [
new Paragraph({
new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
),
],
},
{
properties: {
page: {
size: {
orientation: PageOrientation.PORTRAIT,
},
pageNumbers: {
start: 25,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: new Header({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
new Paragraph({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
children: [
new Paragraph(
"Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section.",
),
],
}),
},
size: {
orientation: PageOrientation.PORTRAIT,
},
properties: {
pageNumberFormatType: PageNumberFormat.DECIMAL,
pageNumberStart: 25,
},
children: [
new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."),
},
],
});

View File

@ -4,49 +4,49 @@ import * as fs from "fs";
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
footnotes: [
new Paragraph("Foo"),
new Paragraph("Test"),
new Paragraph("My amazing reference"),
new Paragraph("Foo1"),
new Paragraph("Test1"),
new Paragraph("My amazing reference1"),
],
});
doc.addSection({
children: [
new Paragraph({
footnotes: {
1: { children: [new Paragraph("Foo"), new Paragraph("Bar")] },
2: { children: [new Paragraph("Test")] },
3: { children: [new Paragraph("My amazing reference")] },
4: { children: [new Paragraph("Foo1")] },
5: { children: [new Paragraph("Test1")] },
6: { children: [new Paragraph("My amazing reference1")] },
},
sections: [
{
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(1)],
new Paragraph({
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(1)],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(2)],
}),
],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(2)],
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
}),
],
}),
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
}),
],
});
doc.addSection({
children: [
new Paragraph({
},
{
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(4)],
new Paragraph({
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(4)],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(5)],
}),
],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(5)],
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(6)],
}),
],
}),
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(6)],
}),
},
],
});

View File

@ -1,19 +1,27 @@
// Insert image from a buffer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Media, Packer, Paragraph } from "../build";
const doc = new Document();
import { Document, ImageRun, Packer, Paragraph } from "../build";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyAjHSAjHR4hHR4hHR4hHx8iHyAjHyAjHyAjHSAhHR4hHR4hHR4hHx8jHyAjHyAjHyAjHyC9S2xeAAAA7nRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFxgZGhscHR4fICEiIyQlJicoKSorLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZISUpLTE1OUFFSU1RVVllaW1xdXmBhYmNkZWZnaGprbG1ub3Byc3R1dnd4eXp8fn+AgYKDhIWGiImKi4yNj5CRkpOUlZaXmJmam5ydnp+goaKjpKaoqqusra6vsLGys7S1tri5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+fkZpVQAABcBJREFUGBntwftjlQMcBvDnnLNL22qzJjWlKLHFVogyty3SiFq6EZliqZGyhnSxsLlMRahYoZKRFcul5dKFCatYqWZaNKvWtrPz/A2+7/b27qRzec/lPfvl/XxgMplMJpPJZDKZAtA9HJ3ppnIez0KnSdtC0RCNznHdJrbrh85wdSlVVRaEXuoGamYi5K5430HNiTiEWHKJg05eRWgNfKeV7RxbqUhGKPV/207VupQ8is0IoX5vtFC18SqEHaK4GyHTZ2kzVR8PBTCO4oANIZL4ShNVZcOhKKeYg9DoWdhI1ec3os2VFI0JCIUez5+i6st0qJZRrEAIJCw+QdW223BG/EmKwTBc/IJ/qfp2FDrkUnwFo8U9dZyqnaPhxLqfYjyM1S3vb6p+GGOBszsojoTDSDFz6qj66R4LzvYJxVMwUNRjf1H1ywQr/megg2RzLximy8waqvbda8M5iijegVEiHjlM1W/3h+FcXesphsMY4dMOUnUgOxyuPEzxPQwRNvV3qg5Nj4BreyimwADWe/dRVTMjEm6MoGLzGwtystL6RyOY3qSqdlYU3FpLZw1VW0sK5943MvUCKwJ1noNtjs6Ohge76Zq9ZkfpigU5WWkDYuCfbs1U5HWFR8/Qq4a9W0uK5k4ZmdrTCl8spGIePLPlbqqsc1Afe83O0hULc8alDYiBd7ZyitYMeBfR55rR2fOKP6ioPk2dGvZ+UVI0d8rtqT2tcCexlqK2F3wRn5Q+YVbBqrLKOupkr9lZujAOrmS0UpTb4JeIPkNHZ+cXr6uoPk2vyuBSPhWLEKj45PQJuQWryyqP0Z14uGLdROHIRNBEXDR09EP5r62rOHCazhrD4VKPwxTH+sIA3ZPTJ+YuWV22n+IruHFDC8X2CBjnPoolcGc2FYUwzmsUWXDHsoGKLBhmN0VvuBVfTVE/AAbpaid5CB4MbaLY1QXGuIViLTyZQcVyGGMuxWPwaA0Vk2GI9RRp8Ci2iuLkIBjhT5LNUfAspZFiTwyC72KK7+DNg1SsRvCNp3gZXq2k4iEEXSHFJHgVXUlxejCCbTvFAHiXdIJiXxyCK7KJ5FHoMZGK9xBcwyg2QpdlVMxEUM2iyIMuXXZQNF+HswxMsSAAJRQjoE//eoqDCXBSTO6f1xd+O0iyNRY6jaWi1ALNYCocZROj4JdEikroVkjFk9DcStXxpdfCD2MoXodu4RUU9ptxxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
const image = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100, 100);
doc.addSection({
children: [
new Paragraph({
children: [image],
}),
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [
new ImageRun({
data: Buffer.from(imageBase64Data, "base64"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
},
],
});

View File

@ -3,23 +3,25 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
children: [
new Paragraph({
const doc = new Document({
sections: [
{
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo",
bold: true,
}),
new TextRun({
text: "\tBar",
bold: true,
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo",
bold: true,
}),
new TextRun({
text: "\tBar",
bold: true,
}),
],
}),
],
}),
},
],
});

View File

@ -1,20 +1,25 @@
// Example on how to customise the look at feel using Styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, TextRun, UnderlineType } from "../build";
import {
AlignmentType,
convertInchesToTwip,
Document,
HeadingLevel,
LevelFormat,
Packer,
Paragraph,
TextRun,
UnderlineType,
} from "../build";
const doc = new Document({
creator: "Clippy",
title: "Sample Document",
description: "A brief example of using docx",
styles: {
paragraphStyles: [
{
id: "Heading1",
name: "Heading 1",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
default: {
heading1: {
run: {
size: 28,
bold: true,
@ -27,12 +32,7 @@ const doc = new Document({
},
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
heading2: {
run: {
size: 26,
bold: true,
@ -48,6 +48,13 @@ const doc = new Document({
},
},
},
listParagraph: {
run: {
color: "#FF0000",
},
},
},
paragraphStyles: [
{
id: "aside",
name: "Aside",
@ -59,7 +66,7 @@ const doc = new Document({
},
paragraph: {
indent: {
left: 720,
left: convertInchesToTwip(0.5),
},
spacing: {
line: 276,
@ -75,12 +82,6 @@ const doc = new Document({
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
},
},
{
id: "ListParagraph",
name: "List Paragraph",
basedOn: "Normal",
quickFormat: true,
},
],
},
numbering: {
@ -90,7 +91,7 @@ const doc = new Document({
levels: [
{
level: 0,
format: "lowerLetter",
format: LevelFormat.LOWER_LETTER,
text: "%1)",
alignment: AlignmentType.LEFT,
},
@ -98,74 +99,91 @@ const doc = new Document({
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "Test heading1, bold and italicized",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph("Some simple content"),
new Paragraph({
text: "Test heading2 with double red underline",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph({
text: "Option1",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
text: "Option5 -- override 2 to 5",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
text: "Option3",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
sections: [
{
children: [
new TextRun({
text: "Some monospaced content",
font: {
name: "Monospace",
new Paragraph({
text: "Test heading1, bold and italicized",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph("Some simple content"),
new Paragraph({
text: "Test heading2 with double red underline",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph({
text: "Option1",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
style: "aside",
}),
new Paragraph({
text: "Option5 -- override 2 to 5",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
],
}),
new Paragraph({
text: "An aside, in light gray italics and indented",
style: "aside",
}),
new Paragraph({
text: "This is normal, but well-spaced text",
style: "wellSpaced",
}),
new Paragraph({
children: [
new TextRun({
text: "This is a bold run,",
bold: true,
new Paragraph({
text: "Option3",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new TextRun(" switching to normal "),
new TextRun({
text: "and then underlined ",
underline: {},
new Paragraph({
children: [
new TextRun({
text: "Some monospaced content",
font: {
name: "Monospace",
},
}),
],
}),
new TextRun({
text: "and back to normal.",
new Paragraph({
text: "An aside, in light gray italics and indented",
style: "aside",
}),
new Paragraph({
text: "This is normal, but well-spaced text",
style: "wellSpaced",
}),
new Paragraph({
children: [
new TextRun({
text: "This is a bold run,",
bold: true,
}),
new TextRun(" switching to normal "),
new TextRun({
text: "and then underlined ",
underline: {},
}),
new TextRun({
text: "and then emphasis-mark ",
emphasisMark: {},
}),
new TextRun({
text: "and back to normal.",
}),
],
}),
new Paragraph({
style: "Strong",
children: [
new TextRun({
text: "Strong Style",
}),
new TextRun({
text: " - Very strong.",
}),
],
}),
],
}),
},
],
});

View File

@ -3,101 +3,105 @@
import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
const doc = new Document({
sections: [
{
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("Hello")],
borders: {
top: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "red",
},
bottom: {
style: BorderStyle.DOUBLE,
size: 3,
color: "blue",
},
left: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "green",
},
right: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "#ff8000",
},
},
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("Hello")],
borders: {
top: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "red",
},
bottom: {
style: BorderStyle.DOUBLE,
size: 3,
color: "blue",
},
left: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "green",
},
right: {
style: BorderStyle.DASH_DOT_STROKED,
size: 3,
color: "#ff8000",
},
},
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
},
],
});
doc.addSection({ children: [table] });
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -1,7 +1,7 @@
// This demo shows how to create bookmarks then link to them with internal hyperlinks
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Bookmark, Document, HeadingLevel, HyperlinkRef, HyperlinkType, Packer, PageBreak, Paragraph } from "../build";
import { Bookmark, Document, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun } from "../build";
const LOREM_IPSUM =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mi velit, convallis convallis scelerisque nec, faucibus nec leo. Phasellus at posuere mauris, tempus dignissim velit. Integer et tortor dolor. Duis auctor efficitur mattis. Vivamus ut metus accumsan tellus auctor sollicitudin venenatis et nibh. Cras quis massa ac metus fringilla venenatis. Proin rutrum mauris purus, ut suscipit magna consectetur id. Integer consectetur sollicitudin ante, vitae faucibus neque efficitur in. Praesent ultricies nibh lectus. Mauris pharetra id odio eget iaculis. Duis dictum, risus id pellentesque rutrum, lorem quam malesuada massa, quis ullamcorper turpis urna a diam. Cras vulputate metus vel massa porta ullamcorper. Etiam porta condimentum nulla nec tristique. Sed nulla urna, pharetra non tortor sed, sollicitudin molestie diam. Maecenas enim leo, feugiat eget vehicula id, sollicitudin vitae ante.";
@ -10,28 +10,53 @@ const doc = new Document({
creator: "Clippy",
title: "Sample Document",
description: "A brief example of using docx with bookmarks and internal hyperlinks",
hyperlinks: {
myAnchorId: {
text: "Hyperlink",
type: HyperlinkType.INTERNAL,
sections: [
{
footers: {
default: new Footer({
children: [
new Paragraph({
children: [
new InternalHyperlink({
child: new TextRun({
text: "Click here!",
style: "Hyperlink",
}),
anchor: "myAnchorId",
}),
],
}),
],
}),
},
children: [
new Paragraph({
heading: HeadingLevel.HEADING_1,
children: [
new Bookmark({
id: "myAnchorId",
children: [new TextRun("Lorem Ipsum")],
}),
],
}),
new Paragraph("\n"),
new Paragraph(LOREM_IPSUM),
new Paragraph({
children: [new PageBreak()],
}),
new Paragraph({
children: [
new InternalHyperlink({
child: new TextRun({
text: "Anchor Text",
style: "Hyperlink",
}),
anchor: "myAnchorId",
}),
],
}),
],
},
},
});
doc.addSection({
children: [
new Paragraph({
heading: HeadingLevel.HEADING_1,
children: [new Bookmark("myAnchorId", "Lorem Ipsum")],
}),
new Paragraph("\n"),
new Paragraph(LOREM_IPSUM),
new Paragraph({
children: [new PageBreak()],
}),
new Paragraph({
children: [new HyperlinkRef("myAnchorId")],
}),
],
});

View File

@ -1,41 +1,68 @@
// This demo shows right to left for special languages
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "../build";
const doc = new Document();
doc.addSection({
children: [
new Paragraph({
bidirectional: true,
const doc = new Document({
sections: [
{
children: [
new TextRun({
text: "שלום עולם",
rightToLeft: true,
new Paragraph({
bidirectional: true,
children: [
new TextRun({
text: "שלום עולם",
rightToLeft: true,
}),
],
}),
new Paragraph({
bidirectional: true,
children: [
new TextRun({
text: "שלום עולם",
bold: true,
rightToLeft: true,
}),
],
}),
new Paragraph({
bidirectional: true,
children: [
new TextRun({
text: "שלום עולם",
italics: true,
rightToLeft: true,
}),
],
}),
new Table({
visuallyRightToLeft: true,
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("שלום עולם")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("שלום עולם")],
}),
],
}),
],
}),
],
}),
new Paragraph({
bidirectional: true,
children: [
new TextRun({
text: "שלום עולם",
bold: true,
rightToLeft: true,
}),
],
}),
new Paragraph({
bidirectional: true,
children: [
new TextRun({
text: "שלום עולם",
italics: true,
rightToLeft: true,
}),
],
}),
},
],
});

View File

@ -1,29 +1,83 @@
// This demo adds an image to the Media cache, and then insert to the document afterwards
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Media, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png"));
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"));
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/parrots.bmp"));
const image5 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
import { Document, ImageRun, Packer, Paragraph, TextRun } from "../build";
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyAjHSAjHR4hHR4hHR4hHx8iHyAjHyAjHyAjHSAhHR4hHR4hHR4hHx8jHyAjHyAjHyAjHyC9S2xeAAAA7nRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFxgZGhscHR4fICEiIyQlJicoKSorLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZISUpLTE1OUFFSU1RVVllaW1xdXmBhYmNkZWZnaGprbG1ub3Byc3R1dnd4eXp8fn+AgYKDhIWGiImKi4yNj5CRkpOUlZaXmJmam5ydnp+goaKjpKaoqqusra6vsLGys7S1tri5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+fkZpVQAABcBJREFUGBntwftjlQMcBvDnnLNL22qzJjWlKLHFVogyty3SiFq6EZliqZGyhnSxsLlMRahYoZKRFcul5dKFCatYqWZaNKvWtrPz/A2+7/b27qRzec/lPfvl/XxgMplMJpPJZDKZAtA9HJ3ppnIez0KnSdtC0RCNznHdJrbrh85wdSlVVRaEXuoGamYi5K5430HNiTiEWHKJg05eRWgNfKeV7RxbqUhGKPV/207VupQ8is0IoX5vtFC18SqEHaK4GyHTZ2kzVR8PBTCO4oANIZL4ShNVZcOhKKeYg9DoWdhI1ec3os2VFI0JCIUez5+i6st0qJZRrEAIJCw+QdW223BG/EmKwTBc/IJ/qfp2FDrkUnwFo8U9dZyqnaPhxLqfYjyM1S3vb6p+GGOBszsojoTDSDFz6qj66R4LzvYJxVMwUNRjf1H1ywQr/megg2RzLximy8waqvbda8M5iijegVEiHjlM1W/3h+FcXesphsMY4dMOUnUgOxyuPEzxPQwRNvV3qg5Nj4BreyimwADWe/dRVTMjEm6MoGLzGwtystL6RyOY3qSqdlYU3FpLZw1VW0sK5943MvUCKwJ1noNtjs6Ohge76Zq9ZkfpigU5WWkDYuCfbs1U5HWFR8/Qq4a9W0uK5k4ZmdrTCl8spGIePLPlbqqsc1Afe83O0hULc8alDYiBd7ZyitYMeBfR55rR2fOKP6ioPk2dGvZ+UVI0d8rtqT2tcCexlqK2F3wRn5Q+YVbBqrLKOupkr9lZujAOrmS0UpTb4JeIPkNHZ+cXr6uoPk2vyuBSPhWLEKj45PQJuQWryyqP0Z14uGLdROHIRNBEXDR09EP5r62rOHCazhrD4VKPwxTH+sIA3ZPTJ+YuWV22n+IruHFDC8X2CBjnPoolcGc2FYUwzmsUWXDHsoGKLBhmN0VvuBVfTVE/AAbpaid5CB4MbaLY1QXGuIViLTyZQcVyGGMuxWPwaA0Vk2GI9RRp8Ci2iuLkIBjhT5LNUfAspZFiTwyC72KK7+DNg1SsRvCNp3gZXq2k4iEEXSHFJHgVXUlxejCCbTvFAHiXdIJiXxyCK7KJ5FHoMZGK9xBcwyg2QpdlVMxEUM2iyIMuXXZQNF+HswxMsSAAJRQjoE//eoqDCXBSTO6f1xd+O0iyNRY6jaWi1ALNYCocZROj4JdEikroVkjFk9DcStXxpdfCD2MoXodu4RUU9ptxxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
const image6 = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100, 100);
doc.addSection({
children: [
new Paragraph({
children: [new TextRun("Hello World"), image5],
}),
new Paragraph(image),
new Paragraph(image2),
new Paragraph(image3),
new Paragraph(image4),
new Paragraph(image6),
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new ImageRun({
data: fs.readFileSync("./demo/images/parrots.bmp"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/dog.png"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/cat.jpg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/parrots.bmp"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: Buffer.from(imageBase64Data, "base64"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
},
],
});

View File

@ -1,85 +1,97 @@
// Add image to table cell
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Media, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const table = new Table({
rows: [
new TableRow({
const doc = new Document({
sections: [
{
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("Hello")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph(image)],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("Hello")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
},
],
});
doc.addSection({
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,51 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
// Create a table and pass the XML Style
const table = new Table({
style: "MyCustomTableStyle",
width: {
size: 9070,
type: WidthType.DXA,
},
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Header Colum 1")],
}),
new TableCell({
children: [new Paragraph("Header Colum 2")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Column Content 3")],
}),
new TableCell({
children: [new Paragraph("Column Content 2")],
}),
],
}),
],
});
const doc = new Document({
title: "Title",
externalStyles: styles,
sections: [
{
children: [table],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -3,28 +3,30 @@
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
children: [
new Paragraph("No border!"),
new Paragraph({
text: "I have borders on my top and bottom sides!",
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
}),
const doc = new Document({
sections: [
{
children: [
new Paragraph("No border!"),
new Paragraph({
text: "I have borders on my top and bottom sides!",
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
}),
],
},
],
});

View File

@ -1,7 +1,7 @@
// Custom styles using JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build";
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build";
const doc = new Document({
styles: {
@ -17,7 +17,7 @@ const doc = new Document({
},
paragraph: {
indent: {
left: 720,
left: convertInchesToTwip(0.5),
},
spacing: {
line: 276,
@ -47,18 +47,19 @@ const doc = new Document({
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "Hello",
style: "myWonkyStyle",
}),
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_2,
}),
sections: [
{
children: [
new Paragraph({
text: "Hello",
style: "myWonkyStyle",
}),
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_2,
}),
],
},
],
});

View File

@ -3,6 +3,11 @@
import * as fs from "fs";
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "../build";
// WordprocessingML docs for TableOfContents can be found here:
// http://officeopenxml.com/WPtableOfContents.php
// Let's define the properties for generate a TOC for heading 1-5 and MySpectacularStyle,
// making the entries be hyperlinks for the paragraph
const doc = new File({
styles: {
paragraphStyles: [
@ -19,43 +24,38 @@ const doc = new File({
},
],
},
});
// WordprocessingML docs for TableOfContents can be found here:
// http://officeopenxml.com/WPtableOfContents.php
// Let's define the properties for generate a TOC for heading 1-5 and MySpectacularStyle,
// making the entries be hyperlinks for the paragraph
doc.addSection({
children: [
new TableOfContents("Summary", {
hyperlink: true,
headingStyleRange: "1-5",
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
}),
new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a little text very nicely written.'"),
new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a other text very nicely written.'"),
new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph("I'm a another text very nicely written.'"),
new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,
}),
sections: [
{
children: [
new TableOfContents("Summary", {
hyperlink: true,
headingStyleRange: "1-5",
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
}),
new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a little text very nicely written.'"),
new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}),
new Paragraph("I'm a other text very nicely written.'"),
new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph("I'm a another text very nicely written.'"),
new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,
}),
],
},
],
});

View File

@ -1,7 +1,8 @@
// Numbered lists
// The lists can also be restarted by specifying the instance number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Packer, Paragraph } from "../build";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
const doc = new Document({
numbering: {
@ -10,12 +11,12 @@ const doc = new Document({
levels: [
{
level: 0,
format: "upperRoman",
format: LevelFormat.UPPER_ROMAN,
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
},
},
},
@ -26,89 +27,256 @@ const doc = new Document({
levels: [
{
level: 0,
format: "decimal",
format: LevelFormat.DECIMAL,
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
},
},
},
],
reference: "my-number-numbering-reference",
},
{
levels: [
{
level: 0,
format: LevelFormat.DECIMAL_ZERO,
text: "[%1]",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
},
},
},
],
reference: "padded-numbering-reference",
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "line with contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line with contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line without contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line without contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "Step 1 - Add sugar",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 2 - Add wheat",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 3 - Put in oven",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
sections: [
{
children: [
new Paragraph({
text: "line with contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line with contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: true,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line without contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "line without contextual spacing",
numbering: {
reference: "my-crazy-reference",
level: 0,
},
contextualSpacing: false,
spacing: {
before: 200,
},
}),
new Paragraph({
text: "Step 1 - Add sugar",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 2 - Add wheat",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 3 - Put in oven",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Next",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
instance: 2,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
instance: 2,
},
}),
new Paragraph({
text: "Next",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
instance: 3,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
instance: 3,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
instance: 3,
},
}),
new Paragraph({
text: "Next",
heading: HeadingLevel.HEADING_2,
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "test",
numbering: {
reference: "padded-numbering-reference",
level: 0,
},
}),
],
},
],
});

View File

@ -1,7 +1,7 @@
// Numbering and bullet points example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Packer, Paragraph } from "../build";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
const doc = new Document({
numbering: {
@ -11,40 +11,40 @@ const doc = new Document({
levels: [
{
level: 0,
format: "upperRoman",
format: LevelFormat.UPPER_ROMAN,
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
},
},
},
{
level: 1,
format: "decimal",
format: LevelFormat.DECIMAL,
text: "%2.",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 1440, hanging: 980 },
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.68) },
},
},
},
{
level: 2,
format: "lowerLetter",
format: LevelFormat.LOWER_LETTER,
text: "%3)",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 2160, hanging: 1700 },
indent: { left: convertInchesToTwip(1.5), hanging: convertInchesToTwip(1.18) },
},
},
},
{
level: 3,
format: "upperLetter",
format: LevelFormat.UPPER_LETTER,
text: "%4)",
alignment: AlignmentType.START,
style: {
@ -55,85 +55,199 @@ const doc = new Document({
},
],
},
{
reference: "my-unique-bullet-points",
levels: [
{
level: 0,
format: LevelFormat.BULLET,
text: "\u1F60",
alignment: AlignmentType.LEFT,
style: {
paragraph: {
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.25) },
},
},
},
{
level: 1,
format: LevelFormat.BULLET,
text: "\u00A5",
alignment: AlignmentType.LEFT,
style: {
paragraph: {
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.25) },
},
},
},
{
level: 2,
format: LevelFormat.BULLET,
text: "\u273F",
alignment: AlignmentType.LEFT,
style: {
paragraph: {
indent: { left: 2160, hanging: convertInchesToTwip(0.25) },
},
},
},
{
level: 3,
format: LevelFormat.BULLET,
text: "\u267A",
alignment: AlignmentType.LEFT,
style: {
paragraph: {
indent: { left: 2880, hanging: convertInchesToTwip(0.25) },
},
},
},
{
level: 4,
format: LevelFormat.BULLET,
text: "\u2603",
alignment: AlignmentType.LEFT,
style: {
paragraph: {
indent: { left: 3600, hanging: convertInchesToTwip(0.25) },
},
},
},
],
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "Hey you",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
text: "What's up fam",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "Hello World 2",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "Yeah boi",
numbering: {
reference: "my-crazy-numbering",
level: 2,
},
}),
new Paragraph({
text: "Hey you",
bullet: {
level: 0,
},
}),
new Paragraph({
text: "What's up fam",
bullet: {
level: 1,
},
}),
new Paragraph({
text: "Hello World 2",
bullet: {
level: 2,
},
}),
new Paragraph({
text: "Yeah boi",
bullet: {
level: 3,
},
}),
new Paragraph({
text: "101 MSXFM",
numbering: {
reference: "my-crazy-numbering",
level: 3,
},
}),
new Paragraph({
text: "back to level 1",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "back to level 0",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
sections: [
{
children: [
new Paragraph({
text: "Hey you",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
text: "What's up fam",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "Hello World 2",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "Yeah boi",
numbering: {
reference: "my-crazy-numbering",
level: 2,
},
}),
new Paragraph({
text: "Hey you",
bullet: {
level: 0,
},
}),
new Paragraph({
text: "What's up fam",
bullet: {
level: 1,
},
}),
new Paragraph({
text: "Hello World 2",
bullet: {
level: 2,
},
}),
new Paragraph({
text: "Yeah boi",
bullet: {
level: 3,
},
}),
new Paragraph({
text: "101 MSXFM",
numbering: {
reference: "my-crazy-numbering",
level: 3,
},
}),
new Paragraph({
text: "back to level 1",
numbering: {
reference: "my-crazy-numbering",
level: 1,
},
}),
new Paragraph({
text: "back to level 0",
numbering: {
reference: "my-crazy-numbering",
level: 0,
},
}),
new Paragraph({
text: "Custom Bullet points",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "What's up fam",
numbering: {
reference: "my-unique-bullet-points",
level: 0,
},
}),
new Paragraph({
text: "Hey you",
numbering: {
reference: "my-unique-bullet-points",
level: 0,
},
}),
new Paragraph({
text: "What's up fam",
numbering: {
reference: "my-unique-bullet-points",
level: 1,
},
}),
new Paragraph({
text: "Hello World 2",
numbering: {
reference: "my-unique-bullet-points",
level: 2,
},
}),
new Paragraph({
text: "Yeah boi",
numbering: {
reference: "my-unique-bullet-points",
level: 3,
},
}),
new Paragraph({
text: "my Awesome numbering",
numbering: {
reference: "my-unique-bullet-points",
level: 4,
},
}),
new Paragraph({
text: "Back to level 1",
numbering: {
reference: "my-unique-bullet-points",
level: 1,
},
}),
],
},
],
});

View File

@ -12,16 +12,21 @@ fs.readFile(filePath, (err, data) => {
}
importDotx.extract(data).then((templateDocument) => {
const doc = new Document(undefined, {
template: templateDocument,
});
doc.addSection({
properties: {
titlePage: templateDocument.titlePageIsDefined,
const doc = new Document(
{
sections: [
{
properties: {
titlePage: templateDocument.titlePageIsDefined,
},
children: [new Paragraph("Hello World")],
},
],
},
children: [new Paragraph("Hello World")],
});
{
template: templateDocument,
},
);
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);

View File

@ -3,74 +3,76 @@
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
const doc = new Document({
sections: [
{
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
}),
new TableCell({
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
}),
new TableCell({
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({
text:
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
heading: HeadingLevel.HEADING_1,
}),
],
}),
new TableCell({
children: [
new Paragraph({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
],
}),
],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({
text:
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
heading: HeadingLevel.HEADING_1,
}),
],
}),
new TableCell({
children: [
new Paragraph({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
],
}),
},
],
});
doc.addSection({
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -2,9 +2,20 @@
// Also includes an example on how to center tables
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, ShadingType, Table, TableCell, TableRow, WidthType } from "../build";
const doc = new Document();
import {
AlignmentType,
BorderStyle,
convertInchesToTwip,
Document,
HeadingLevel,
Packer,
Paragraph,
ShadingType,
Table,
TableCell,
TableRow,
WidthType,
} from "../build";
const table = new Table({
rows: [
@ -37,10 +48,10 @@ const table2 = new Table({
new TableCell({
children: [new Paragraph("World")],
margins: {
top: 1000,
bottom: 1000,
left: 1000,
right: 1000,
top: convertInchesToTwip(0.69),
bottom: convertInchesToTwip(0.69),
left: convertInchesToTwip(0.69),
right: convertInchesToTwip(0.69),
},
columnSpan: 3,
}),
@ -64,7 +75,7 @@ const table2 = new Table({
size: 100,
type: WidthType.AUTO,
},
columnWidths: [1000, 1000, 1000],
columnWidths: [convertInchesToTwip(0.69), convertInchesToTwip(0.69), convertInchesToTwip(0.69)],
});
const table3 = new Table({
@ -119,14 +130,14 @@ const table3 = new Table({
}),
],
width: {
size: 7000,
size: convertInchesToTwip(4.86),
type: WidthType.DXA,
},
margins: {
top: 400,
bottom: 400,
right: 400,
left: 400,
top: convertInchesToTwip(0.27),
bottom: convertInchesToTwip(0.27),
right: convertInchesToTwip(0.27),
left: convertInchesToTwip(0.27),
},
});
@ -184,7 +195,7 @@ const table5 = new Table({
new TableRow({
children: [
new TableCell({
children: [],
children: [new Paragraph("1,0")],
}),
new TableCell({
children: [new Paragraph("1,2")],
@ -195,10 +206,10 @@ const table5 = new Table({
new TableRow({
children: [
new TableCell({
children: [],
children: [new Paragraph("2,0")],
}),
new TableCell({
children: [],
children: [new Paragraph("2,1")],
}),
],
}),
@ -209,23 +220,187 @@ const table5 = new Table({
},
});
doc.addSection({
children: [
table,
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
const borders = {
top: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
bottom: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
left: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
right: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
};
const table6 = new Table({
rows: [
new TableRow({
children: [
new TableCell({
borders,
children: [new Paragraph("0,0")],
rowSpan: 2,
}),
new TableCell({
borders,
children: [new Paragraph("0,1")],
}),
],
}),
table2,
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
new TableRow({
children: [
new TableCell({
borders,
children: [new Paragraph("1,1")],
rowSpan: 2,
}),
],
}),
table3,
new Paragraph("Merging columns"),
table4,
new Paragraph("More Merging columns"),
table5,
new TableRow({
children: [
new TableCell({
borders,
children: [new Paragraph("2,0")],
}),
],
}),
],
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
});
const table7 = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("0,0")],
}),
new TableCell({
children: [new Paragraph("0,1")],
}),
new TableCell({
children: [new Paragraph("0,2")],
rowSpan: 2,
}),
new TableCell({
children: [new Paragraph("0,3")],
rowSpan: 3,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("1,0")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("2,0")],
columnSpan: 2,
}),
new TableCell({
children: [new Paragraph("2,2")],
rowSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("3,0")],
}),
new TableCell({
children: [new Paragraph("3,1")],
}),
new TableCell({
children: [new Paragraph("3,3")],
}),
],
}),
],
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
});
const table8 = new Table({
rows: [
new TableRow({
children: [
new TableCell({ children: [new Paragraph("1,1")] }),
new TableCell({ children: [new Paragraph("1,2")] }),
new TableCell({ children: [new Paragraph("1,3")] }),
new TableCell({ children: [new Paragraph("1,4")], rowSpan: 4, borders }),
],
}),
new TableRow({
children: [
new TableCell({ children: [new Paragraph("2,1")] }),
new TableCell({ children: [new Paragraph("2,2")] }),
new TableCell({ children: [new Paragraph("2,3")], rowSpan: 3 }),
],
}),
new TableRow({
children: [
new TableCell({ children: [new Paragraph("3,1")] }),
new TableCell({ children: [new Paragraph("3,2")], rowSpan: 2 }),
],
}),
new TableRow({
children: [new TableCell({ children: [new Paragraph("4,1")] })],
}),
],
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
});
const doc = new Document({
sections: [
{
children: [
table,
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
}),
table2,
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
}),
table3,
new Paragraph("Merging columns 1"),
table4,
new Paragraph("Merging columns 2"),
table5,
new Paragraph("Merging columns 3"),
table6,
new Paragraph("Merging columns 4"),
table7,
new Paragraph("Merging columns 5"),
table8,
],
},
],
});

View File

@ -3,42 +3,44 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build";
const doc = new Document();
doc.addSection({
children: [
new Paragraph({
const doc = new Document({
sections: [
{
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Caption"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Caption"),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Caption"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Caption"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Label"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 3->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 2->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 4->"),
new SequentialIdentifier("Label"),
],
}),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Label"),
new TextRun(" text after sequencial caption 2->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 1->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 3->"),
new SequentialIdentifier("Label"),
],
}),
new Paragraph({
children: [
new TextRun("Hello World 2->"),
new SequentialIdentifier("Another"),
new TextRun(" text after sequencial caption 4->"),
new SequentialIdentifier("Label"),
],
}),
},
],
});

View File

@ -16,8 +16,6 @@ import {
WidthType,
} from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
@ -45,6 +43,10 @@ const table = new Table({
relativeHorizontalPosition: RelativeHorizontalPosition.RIGHT,
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
overlap: OverlapType.NEVER,
leftFromText: 1000,
rightFromText: 2000,
topFromText: 1500,
bottomFromText: 30,
},
width: {
size: 4535,
@ -53,8 +55,12 @@ const table = new Table({
layout: TableLayoutType.FIXED,
});
doc.addSection({
children: [table],
const doc = new Document({
sections: [
{
children: [table],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -1,33 +1,101 @@
// Example on how to add hyperlinks to websites
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HyperlinkRef, HyperlinkType, Packer, Paragraph, Media } from "../build";
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
hyperlinks: {
myCoolLink: {
link: "http://www.example.com",
text: "Hyperlink",
type: HyperlinkType.EXTERNAL,
},
myOtherLink: {
link: "http://www.google.com",
text: "Google Link",
type: HyperlinkType.EXTERNAL,
footnotes: {
1: {
children: [
new Paragraph({
children: [
new TextRun("Click here for the "),
new ExternalHyperlink({
child: new TextRun({
text: "Footnotes external hyperlink",
style: "Hyperlink",
}),
link: "http://www.example.com",
}),
],
}),
],
},
},
});
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
doc.addSection({
children: [
new Paragraph({
children: [new HyperlinkRef("myCoolLink")],
}),
new Paragraph({
children: [image1, new HyperlinkRef("myOtherLink")],
}),
sections: [
{
footers: {
default: new Footer({
children: [
new Paragraph({
children: [
new TextRun("Click here for the "),
new ExternalHyperlink({
child: new TextRun({
text: "Footer external hyperlink",
style: "Hyperlink",
}),
link: "http://www.example.com",
}),
],
}),
],
}),
},
headers: {
default: new Footer({
children: [
new Paragraph({
children: [
new TextRun("Click here for the "),
new ExternalHyperlink({
child: new TextRun({
text: "Header external hyperlink",
style: "Hyperlink",
}),
link: "http://www.google.com",
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [
new ExternalHyperlink({
child: new TextRun({
text: "Anchor Text",
style: "Hyperlink",
}),
link: "http://www.example.com",
}),
new FootnoteReferenceRun(1),
],
}),
new Paragraph({
children: [
new ExternalHyperlink({
child: new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
link: "http://www.google.com",
}),
new ExternalHyperlink({
child: new TextRun({
text: "BBC News Link",
style: "Hyperlink",
}),
link: "https://www.bbc.co.uk/news",
}),
],
}),
],
},
],
});

View File

@ -1,10 +1,7 @@
// Add image to table cell in a header and body
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Header, Media, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const table = new Table({
rows: [
@ -30,7 +27,19 @@ const table = new Table({
children: [],
}),
new TableCell({
children: [new Paragraph(image)],
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
@ -58,13 +67,17 @@ const table = new Table({
});
// Adding same table in the body and in the header
doc.addSection({
headers: {
default: new Header({
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [table],
}),
},
children: [table],
}),
},
children: [table],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -1,20 +1,53 @@
// Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Header, Media, Packer, Paragraph } from "../build";
import { Document, Header, ImageRun, Packer, Paragraph } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
doc.addSection({
headers: {
default: new Header({
children: [new Paragraph(image), new Paragraph(image1), new Paragraph(image2)],
}),
},
children: [new Paragraph("Hello World")],
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -2,41 +2,50 @@
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
// import { Document, Packer, Paragraph } from "../build";
import { Document, Media, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 2014400,
const doc = new Document({
sections: [
{
children: [
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
),
new Paragraph(
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
),
new Paragraph(
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
},
floating: {
horizontalPosition: {
offset: 2014400,
},
verticalPosition: {
offset: 2014400,
},
wrap: {
type: TextWrappingType.SQUARE,
side: TextWrappingSide.BOTH_SIDES,
},
margins: {
top: 201440,
bottom: 201440,
},
},
}),
],
}),
],
},
verticalPosition: {
offset: 2014400,
},
wrap: {
type: TextWrappingType.SQUARE,
side: TextWrappingSide.BOTH_SIDES,
},
margins: {
top: 201440,
bottom: 201440,
},
},
});
doc.addSection({
children: [
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
),
new Paragraph(
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
),
new Paragraph(
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
),
new Paragraph(image),
],
});

View File

@ -3,64 +3,70 @@
import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, PageNumberFormat, Paragraph, TextRun } from "../build";
const doc = new Document({});
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
const doc = new Document({
sections: [
{
properties: {
page: {
pageNumbers: {
start: 1,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: new Header({
children: [
new TextRun("Foo Bar corp. "),
new TextRun({
children: ["Page Number ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
new Paragraph({
children: [
new TextRun("Foo Bar corp. "),
new TextRun({
children: ["Page Number ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
}),
],
}),
],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
},
footers: {
default: new Footer({
children: [
new TextRun("Foo Bar corp. "),
new TextRun({
children: ["Page Number: ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun("Foo Bar corp. "),
new TextRun({
children: ["Page Number: ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("Hello World 1"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 2"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 3"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 4"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 5"), new PageBreak()],
}),
],
}),
},
properties: {
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
children: [
new Paragraph({
children: [new TextRun("Hello World 1"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 2"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 3"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 4"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 5"), new PageBreak()],
}),
},
],
});

View File

@ -1,11 +1,93 @@
// Example of how you would create a table and add data to it
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
const table = new Table({
columnWidths: [3505, 5505],
rows: [
new TableRow({
children: [
new TableCell({
width: {
size: 3505,
type: WidthType.DXA,
},
children: [new Paragraph("Hello")],
}),
new TableCell({
width: {
size: 5505,
type: WidthType.DXA,
},
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
width: {
size: 3505,
type: WidthType.DXA,
},
children: [],
}),
new TableCell({
width: {
size: 5505,
type: WidthType.DXA,
},
children: [new Paragraph("World")],
}),
],
}),
],
});
const table2 = new Table({
columnWidths: [4505, 4505],
rows: [
new TableRow({
children: [
new TableCell({
width: {
size: 4505,
type: WidthType.DXA,
},
children: [new Paragraph("Hello")],
}),
new TableCell({
width: {
size: 4505,
type: WidthType.DXA,
},
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
width: {
size: 4505,
type: WidthType.DXA,
},
children: [],
}),
new TableCell({
width: {
size: 4505,
type: WidthType.DXA,
},
children: [new Paragraph("World")],
}),
],
}),
],
});
const table3 = new Table({
rows: [
new TableRow({
children: [
@ -30,8 +112,19 @@ const table = new Table({
],
});
doc.addSection({
children: [table],
const doc = new Document({
sections: [
{
children: [
new Paragraph({ text: "Table with skewed widths" }),
table,
new Paragraph({ text: "Table with equal widths" }),
table2,
new Paragraph({ text: "Table without setting widths" }),
table3,
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -3,24 +3,28 @@
import * as fs from "fs";
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
properties: {
lineNumberCountBy: 1,
lineNumberRestart: LineNumberRestartFormat.CONTINUOUS,
},
children: [
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph(
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
),
new Paragraph(
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
),
const doc = new Document({
sections: [
{
properties: {
lineNumbers: {
countBy: 1,
restart: LineNumberRestartFormat.CONTINUOUS,
},
},
children: [
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph(
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
),
new Paragraph(
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
),
],
},
],
});

View File

@ -3,8 +3,6 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
@ -252,8 +250,12 @@ const table2 = new Table({
],
});
doc.addSection({
children: [table, new Paragraph(""), table2],
const doc = new Document({
sections: [
{
children: [table, new Paragraph(""), table2],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -0,0 +1,93 @@
// Page numbers - Start from 0 on a new section
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "../build";
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("My Title "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
first: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("First Page Header "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("First Page"), new PageBreak()],
}),
new Paragraph("Second Page"),
],
},
{
properties: {
page: {
pageNumbers: {
start: 1,
separator: PageNumberSeparator.EM_DASH,
},
},
},
headers: {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("My Title "),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
first: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun("First Page Header of Second section"),
new TextRun({
children: ["Page ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("Third Page"), new PageBreak()],
}),
new Paragraph("Fourth Page"),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -3,8 +3,6 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
@ -75,8 +73,12 @@ const table = new Table({
],
});
doc.addSection({
children: [table],
const doc = new Document({
sections: [
{
children: [table],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -3,35 +3,51 @@
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
properties: {
column: {
space: 708,
count: 2,
const doc = new Document({
sections: [
{
properties: {
column: {
space: 708,
count: 2,
},
},
children: [
new Paragraph("This text will be split into 2 columns on a page."),
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
),
],
},
},
children: [
new Paragraph("This text will be split into 2 columns on a page."),
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
),
],
});
doc.addSection({
properties: {
column: {
space: 708,
count: 3,
{
properties: {
column: {
space: 708,
count: 3,
},
},
children: [
new Paragraph("This text will be split into 3 columns on a page."),
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
),
],
},
{
properties: {
column: {
space: 708,
count: 2,
separate: true,
},
},
children: [
new Paragraph("This text will be split into 2 columns on a page."),
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
),
],
},
},
children: [
new Paragraph("This text will be split into 3 columns on a page."),
new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
),
],
});

View File

@ -3,31 +3,33 @@
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new TextRun({
text: "Hello World",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
highlight: "yellow",
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun({
text: "Hello World",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
highlight: "yellow",
}),
],
}),
],
}),
],
}),
},
children: [],
},
children: [],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -3,35 +3,62 @@
import * as fs from "fs";
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
const doc = new Document();
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.RIGHT,
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new TextRun({
text: "Hello World",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
new Paragraph({
alignment: AlignmentType.RIGHT,
children: [
new TextRun({
text: "Hello World",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF",
fill: "FF0000",
},
}),
],
}),
new Paragraph({
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
type: ShadingType.DIAGONAL_CROSS,
color: "00FFFF",
fill: "FF0000",
},
children: [
new TextRun({
text: "Hello World for entire paragraph",
}),
],
}),
],
}),
},
children: [
new Paragraph({
children: [
new TextRun({
emboss: true,
text: "Embossed text - hello world",
}),
new TextRun({
imprint: true,
text: "Imprinted text - hello world",
}),
],
}),
],
}),
},
children: [],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -3,8 +3,6 @@
import * as fs from "fs";
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, PageNumberFormat, Paragraph, TextRun } from "../build";
const doc = new Document();
const header = new Header({
children: [
new Paragraph({
@ -26,39 +24,50 @@ const footer = new Footer({
children: [new Paragraph("Foo Bar corp. ")],
});
doc.addSection({
headers: {
default: header,
},
footers: {
default: footer,
},
properties: {
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
children: [
new Paragraph({
children: [new TextRun("Section 1"), new PageBreak(), new TextRun("Section 1"), new PageBreak()],
}),
],
});
doc.addSection({
headers: {
default: header,
},
footers: {
default: footer,
},
properties: {
pageNumberStart: 1,
pageNumberFormatType: PageNumberFormat.DECIMAL,
},
children: [
new Paragraph({
children: [new TextRun("Section 2"), new PageBreak(), new TextRun("Section 2"), new PageBreak()],
}),
const doc = new Document({
sections: [
{
properties: {
page: {
pageNumbers: {
start: 1,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: header,
},
footers: {
default: footer,
},
children: [
new Paragraph({
children: [new TextRun("Section 1"), new PageBreak(), new TextRun("Section 1"), new PageBreak()],
}),
],
},
{
properties: {
page: {
pageNumbers: {
start: 1,
formatType: PageNumberFormat.DECIMAL,
},
},
},
headers: {
default: header,
},
footers: {
default: footer,
},
children: [
new Paragraph({
children: [new TextRun("Section 2"), new PageBreak(), new TextRun("Section 2"), new PageBreak()],
}),
],
},
],
});

View File

@ -3,26 +3,28 @@
import * as fs from "fs";
import { Document, Packer, Paragraph, SectionVerticalAlignValue, TextRun } from "../build";
const doc = new Document();
doc.addSection({
properties: {
verticalAlign: SectionVerticalAlignValue.CENTER,
},
children: [
new Paragraph({
const doc = new Document({
sections: [
{
properties: {
verticalAlign: SectionVerticalAlignValue.CENTER,
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
}),
},
],
});

View File

@ -1,15 +1,47 @@
// Add custom borders to the table itself
// Add custom borders and no-borders to the table itself
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
const doc = new Document();
import {
BorderStyle,
Document,
HeadingLevel,
Packer,
Paragraph,
Table,
TableBorders,
TableCell,
TableRow,
TextDirection,
VerticalAlign,
} from "../build";
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
borders: {
top: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
bottom: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
left: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
right: {
style: BorderStyle.DASH_SMALL_GAP,
size: 1,
color: "red",
},
},
children: [new Paragraph("Hello")],
}),
new TableCell({
@ -30,7 +62,105 @@ const table = new Table({
],
});
doc.addSection({ children: [table] });
// Using the no-border convenience object. It is the same as writing this manually:
// const borders = {
// top: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// bottom: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// left: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// right: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// insideHorizontal: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// insideVertical: {
// style: BorderStyle.NONE,
// size: 0,
// color: "auto",
// },
// };
const noBorderTable = new Table({
borders: TableBorders.NONE,
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({}), new Paragraph({})],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
}),
new TableCell({
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({
text:
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
heading: HeadingLevel.HEADING_1,
}),
],
}),
new TableCell({
children: [
new Paragraph({
text: "This text should be in the middle of the cell",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from bottom to top",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Text above should be vertical from top to bottom",
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
],
}),
],
});
const doc = new Document({
sections: [{ children: [table, new Paragraph("Hello"), noBorderTable] }],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);

View File

@ -1,59 +1,133 @@
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
// import { Document, Packer, Paragraph } from "../build";
import {
Document,
HorizontalPositionAlign,
HorizontalPositionRelativeFrom,
Media,
ImageRun,
Packer,
Paragraph,
VerticalPositionAlign,
VerticalPositionRelativeFrom,
} from "../build";
const doc = new Document();
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png").toString("base64"));
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"));
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/parrots.bmp"));
const image5 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const image6 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 1014400,
const doc = new Document({
sections: [
{
children: [
new Paragraph("Hello World"),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/dog.png").toString("base64"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/cat.jpg"),
transformation: {
width: 100,
height: 100,
flip: {
vertical: true,
},
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/parrots.bmp"),
transformation: {
width: 150,
height: 150,
flip: {
horizontal: true,
},
rotation: 225,
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
flip: {
horizontal: true,
vertical: true,
},
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
rotation: 45,
},
floating: {
zIndex: 10,
horizontalPosition: {
offset: 1014400,
},
verticalPosition: {
offset: 1014400,
},
},
}),
],
}),
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/cat.jpg"),
transformation: {
width: 200,
height: 200,
},
floating: {
zIndex: 5,
horizontalPosition: {
relative: HorizontalPositionRelativeFrom.PAGE,
align: HorizontalPositionAlign.RIGHT,
},
verticalPosition: {
relative: VerticalPositionRelativeFrom.PAGE,
align: VerticalPositionAlign.BOTTOM,
},
},
}),
],
}),
],
},
verticalPosition: {
offset: 1014400,
},
},
});
const image7 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"), 200, 200, {
floating: {
horizontalPosition: {
relative: HorizontalPositionRelativeFrom.PAGE,
align: HorizontalPositionAlign.RIGHT,
},
verticalPosition: {
relative: VerticalPositionRelativeFrom.PAGE,
align: VerticalPositionAlign.BOTTOM,
},
},
});
doc.addSection({
children: [
new Paragraph("Hello World"),
new Paragraph(image1),
new Paragraph(image2),
new Paragraph(image3),
new Paragraph(image4),
new Paragraph(image5),
new Paragraph(image6),
new Paragraph(image7),
],
});

View File

@ -1,19 +1,26 @@
// Simple example to add text to a document
// The demo on the README.md
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Media, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
const doc = new Document();
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph(image1)],
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
@ -38,21 +45,47 @@ const table = new Table({
],
}),
new TableCell({
children: [new Paragraph(image1)],
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/image1.jpeg"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
],
});
doc.addSection({
children: [
new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}),
table,
new Paragraph(image2),
const doc = new Document({
sections: [
{
children: [
new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}),
table,
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
},
],
});

View File

@ -15,20 +15,41 @@ const doc = new Document({
italics: true,
},
},
{
id: "strong",
name: "Strong",
basedOn: "Normal",
run: {
bold: true,
},
},
],
},
});
doc.addSection({
children: [
new Paragraph({
sections: [
{
children: [
new TextRun({
text: "Foo bar",
style: "myRedStyle",
new Paragraph({
children: [
new TextRun({
text: "Foo bar",
style: "myRedStyle",
}),
],
}),
new Paragraph({
children: [
new TextRun({
text: "First Word",
style: "strong",
}),
new TextRun({
text:
" - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
}),
],
}),
],
}),
},
],
});

View File

@ -18,17 +18,18 @@ const doc = new Document({
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "KFCを食べるのが好き",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "こんにちは",
}),
sections: [
{
children: [
new Paragraph({
text: "KFCを食べるのが好き",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "こんにちは",
}),
],
},
],
});

91
demo/53-chinese.ts Normal file
View File

@ -0,0 +1,91 @@
// Chinese text - Chinese text need to use a Chinese font. And ascii text need to use a ascii font.
// Different from the `52-japanese.ts`.
// `52-japanese.ts` will set all characters to use Japanese font.
// `53-chinese.ts` will set Chinese characters to use Chinese font, and set ascii characters to use ascii font.
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
styles: {
default: {
document: {
run: {
font: {
ascii: "minorHAnsi",
eastAsia: "minorEastAsia",
cs: "minorBidi",
hAnsi: "minorHAnsi",
},
},
},
},
paragraphStyles: [
{
id: "Normal",
name: "Normal",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: {
ascii: "minorHAnsi", // Can also use minorHAnsi
eastAsia: "minorEastAsia", // Can also use minorEastAsia
cs: "minorBidi",
hAnsi: "minorHAnsi",
},
},
},
],
},
sections: [
{
children: [
new Paragraph({
text: "中文和英文 Chinese and English",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "中文和英文 Chinese and English",
}),
new Paragraph({
children: [
new TextRun({
text: "中文和英文 Chinese and English",
font: { eastAsia: "SimSun" }, // set eastAsia to "SimSun".
// The ascii characters will use the default font ("Times") specified in paragraphStyles
}),
],
}),
new Paragraph({
text: `店様付旅母正役基社発破班。発治治京岡局本因追意金紀統責郵滴尽。立功日庁重天富評界明済不着法返祉経正引行。載区列防新目治日群付無人道言越名。界安無死専体風木人教録覧訃。女問堂容県作先芸便効証帯債土全極的日。能山中岡仕関攻井季接店線幌温後率事阜止。成間路行究今式歌像祉帯式媛読徹。安行息古入出文侵監株登部席内文第珍鶴問用。
編竹入俳多応日氏陸福芸北供動。情績拠僧肺軍油能認郷翌南対韓短東食束兵晶。政予任習口佐所当止市告号。悩申無式立医毎部観潟訴菱権。発臼背郎上予配光記芸注然出。梨場株以政囲下球品材県動政押婚面見。米共試使落帳遅毅間三子開。問与大八地芸第線体架辺今死。押構草齢戦重最変社豪記目盗連報準周込。系貸劇様重鷲始能質村異社学動導勤。
残様的荻仲刺局標績供質球就雄。考和母問者役尊紙推新経革個事編安観。益学北日著楽車山勢流泉四犯投台戒設対臨百。危謄初治穴委済本索労刊回。月写政覧女事棋違年終索情響白子泉転企堀社。江遊著西高開面毎分芸責成創査全判調目止懇。原育会夏作売望人転乱融抜心。制川供健水示囲阜厚高右断季人役。持面必日暮気管像冬間影図健行格阪。
来入工速会健評下町慮大貸社一見園外申憶。服豊舞入面沢交使奥見記写意岩。北観提女刊液城共五擦相売田合是由読。回歳売苦定記点郎意増賛治北渡本応。受送文携村陸情静了申注際。順負子研済老上変女産第内無費携投展達。東初乗回動合語学待聴暮沢流全場導敷記賞次。更物中備著後渡売第部時禁新田木下昨。備護起織服久権意全海馬適応。
幸速団供地信討川安矛場消学年。去茂玉東今要出約元教負限載始今簡。編掲証的情仕渡室手映法部始。紙反語清阪曜税受知選謝個印観聞。教人超死準無者参生撤技真価椿景破市見国。左需臓道力趣暮際丁高会近部敗岡力当社。壊態毒期波超長写島断兆国世行共絞私報。反野番点図択女撃脱案情王援。減属考論月院催者門料約覧市戦。
山部午金査投立集争教殺巣作世動北部応。通負考隙問粛中帯閉要程規化小。橋棋互界時引就現省竹去子無系容米。竹転起日本新田強済購書区庁集作容同会窓教。文公神転待究挙登投川選囲針能楽路断出歌。祥新現寄公史真玉属元始員金抜関前百衝能。国眺暮囲世嘘面外営国内報夜九掲事春葉。来月刊台先良理著自供法投。通渡請当月学安首一押実展介況。
法優分独込右得里記域目順供進乗。憂婚転峰大写医投社曲題任能務熱県展覧港専。栄余歯真著改追事作果石芸。青感将南便再転領鈴投提鉄索競虎師体物想。牲打迎達携度開技書催掲安去変念座。革混疑生採就枢当住回県組北意寛。爆新和級掲交象温十賛展木開有結日。新海辺小除京物興量写界裁上。文師建関面取質也底沼画者図空医心無季。
高館湯転名気業以際置講詰方活礎組調軽際。発変東作訪乃小化理利提目気。極季本問号面帯勤戦行新禁情堀郎携。座所転再祥業必変昌今歩佐王立抗後養崩。支物猪躍芸整縦焦供防続相護治時語朝分刊定。綿田幸崎責本欲間載神調崎答志政報与速美載。飯治止稿原先明画森群進見情幕。女民館終調質並伝車慌供科。支田国傷自動献疑討医足公成公主断的望。
責開児食福実帰治師今策今。水重寺圧医観送連東者秒途。選央力律式開作掲写様階組戦写型紙。式国販時天遣国出難共前次領体康稲住転。査見保重議原速群者内月正連。爾天膨装芸別巨平運数準三浜念載創県奈飛提。素京発揮田談気党示見象定電類代級。善返跡国有話権入猛府週亡辞馬脳。関残主祐雪塚去集村完海関文受載表川護照立。
発闘美慎健育旅布容広互無秋認天歌媛芸。転器合読県増認会賞倒点系。食気母服絵知去祝芸車報熱勝。能貿月更障文的欠賞現覇声敏施会。懲病写昼法族業律記聡生開緊楽暮護。東地二員者説盟治害討面提。第北乗査庭年近的禁疑報方店記必迷都流通。聞有力前愛院梨野関業前訳本清滋補。蒲読火死勝広保会婚際気二由保国。用君込村需起相点選紙拡氏訃不。`,
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,27 @@
// Custom Properties
// Custom properties are incredibly useful if you want to be able to apply quick parts or custom cover pages
// to the document in Word after the document has been generated. Standard properties (such as creator, title
// and subject) cover typical use cases, but sometimes custom properties are required.
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer } from "../build";
const doc = new Document(
// Standard properties
{
creator: "Creator",
title: "Title",
subject: "Subject",
description: "Description",
customProperties: [
{ name: "Subtitle", value: "Subtitle" },
{ name: "Address", value: "Address" },
],
sections: [],
},
);
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

296
demo/55-math.ts Normal file
View File

@ -0,0 +1,296 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
Math,
MathAngledBrackets,
MathCurlyBrackets,
MathFraction,
MathFunction,
MathPreSubSuperScript,
MathRadical,
MathRoundBrackets,
MathRun,
MathSquareBrackets,
MathSubScript,
MathSubSuperScript,
MathSum,
MathSuperScript,
Packer,
Paragraph,
TextRun,
} from "../build";
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
children: [
new Math({
children: [
new MathRun("2+2"),
new MathFraction({
numerator: [new MathRun("hi")],
denominator: [new MathRun("2")],
}),
],
}),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathFraction({
numerator: [
new MathRun("1"),
new MathRadical({
children: [new MathRun("2")],
}),
],
denominator: [new MathRun("2")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSum({
children: [new MathRun("test")],
}),
new MathSum({
children: [
new MathSuperScript({
children: [new MathRun("e")],
superScript: [new MathRun("2")],
}),
],
subScript: [new MathRun("i")],
}),
new MathSum({
children: [
new MathRadical({
children: [new MathRun("i")],
}),
],
subScript: [new MathRun("i")],
superScript: [new MathRun("10")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSuperScript({
children: [new MathRun("test")],
superScript: [new MathRun("hello")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
children: [new MathRun("test")],
subScript: [new MathRun("hello")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
children: [new MathRun("x")],
subScript: [
new MathSuperScript({
children: [new MathRun("y")],
superScript: [new MathRun("2")],
}),
],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubSuperScript({
children: [new MathRun("test")],
superScript: [new MathRun("hello")],
subScript: [new MathRun("world")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathPreSubSuperScript({
children: [new MathRun("test")],
superScript: [new MathRun("hello")],
subScript: [new MathRun("world")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
subScript: [new MathRun("4")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
children: [
new MathRadical({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
degree: [new MathRun("4")],
}),
],
subScript: [new MathRun("x")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathRadical({
children: [new MathRun("4")],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathFunction({
name: [
new MathSuperScript({
children: [new MathRun("cos")],
superScript: [new MathRun("-1")],
}),
],
children: [new MathRun("100")],
}),
new MathRun("×"),
new MathFunction({
name: [new MathRun("sin")],
children: [new MathRun("360")],
}),
new MathRun("= x"),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathRoundBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
new MathSquareBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
new MathCurlyBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
new MathAngledBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathFraction({
numerator: [
new MathRadical({
children: [new MathRun("4")],
}),
],
denominator: [new MathRun("2a")],
}),
],
}),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,34 @@
// Change background colour of whole document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
background: {
color: "C45911",
},
sections: [
{
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,89 @@
// Numbered lists - Add parent number in sub number
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
const doc = new Document({
numbering: {
config: [
{
levels: [
{
level: 0,
format: LevelFormat.DECIMAL,
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: convertInchesToTwip(0.5), hanging: 260 },
},
},
},
{
level: 1,
format: LevelFormat.DECIMAL,
text: "%1.%2",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 1.25 * convertInchesToTwip(0.5), hanging: 1.25 * 260 },
},
run: {
bold: true,
size: 18,
font: "Times New Roman",
},
},
},
],
reference: "my-number-numbering-reference",
},
],
},
sections: [
{
children: [
new Paragraph({
text: "How to make cake",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "Step 1 - Add sugar",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 2 - Add wheat",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "Step 2a - Stir the wheat in a circle",
numbering: {
reference: "my-number-numbering-reference",
level: 1,
},
}),
new Paragraph({
text: "Step 3 - Put in oven",
numbering: {
reference: "my-number-numbering-reference",
level: 0,
},
}),
new Paragraph({
text: "How to make cake",
heading: HeadingLevel.HEADING_1,
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

91
demo/58-section-types.ts Normal file
View File

@ -0,0 +1,91 @@
// Usage of different Section Types
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun, SectionType } from "../build";
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
],
},
{
properties: {
type: SectionType.CONTINUOUS,
},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
],
},
{
properties: {
type: SectionType.ODD_PAGE,
},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
],
},
{
properties: {
type: SectionType.EVEN_PAGE,
},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
],
},
{
properties: {
type: SectionType.NEXT_PAGE,
},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,54 @@
// Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build";
const doc = new Document({
sections: [
{
properties: {
page: {
margin: {
header: 100,
footer: 50,
},
},
},
headers: {
default: new Header({
children: [
new Paragraph({
text: "Header text",
indent: {
left: -400,
},
}),
new Paragraph({
text: "Some more header text",
indent: {
left: -600,
},
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
text: "Footer text",
indent: {
left: -400,
},
}),
],
}),
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -3,35 +3,41 @@
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addSection({
margins: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
children: [
new Paragraph({
const doc = new Document({
sections: [
{
properties: {
page: {
margin: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
},
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo bar",
bold: true,
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph("Foo bar"),
new Paragraph("Github is the best"),
],
}),
new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph("Foo bar"),
new Paragraph("Github is the best"),
},
],
});

151
demo/60-track-revisions.ts Normal file
View File

@ -0,0 +1,151 @@
// Track Revisions aka. "Track Changes"
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
DeletedTextRun,
Document,
Footer,
FootnoteReferenceRun,
InsertedTextRun,
Packer,
PageNumber,
Paragraph,
ShadingType,
TextRun,
} from "../build";
/*
For reference, see
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.insertedrun
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.deletedrun
The method `addTrackRevisions()` adds an element `<w:trackRevisions />` to the `settings.xml` file. This specifies that the application shall track *new* revisions made to the existing document.
See also https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.trackrevisions
Note that this setting enables to track *new changes* after teh file is generated, so this example will still show inserted and deleted text runs when you remove it.
*/
const paragraph = new Paragraph({
children: [
new TextRun("This is a simple demo "),
new TextRun({
text: "on how to ",
}),
new InsertedTextRun({
text: "mark a text as an insertion ",
id: 0,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
}),
new DeletedTextRun({
text: "or a deletion.",
id: 1,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
}),
],
});
const doc = new Document({
footnotes: {
1: {
children: [
new Paragraph({
children: [
new TextRun("This is a footnote"),
new DeletedTextRun({
text: " with some extra text which was deleted",
id: 0,
author: "Firstname Lastname",
date: "2020-10-06T09:05:00Z",
}),
new InsertedTextRun({
text: " and new content",
id: 1,
author: "Firstname Lastname",
date: "2020-10-06T09:05:00Z",
}),
],
}),
],
},
},
features: {
trackRevisions: true,
},
sections: [
{
properties: {},
children: [
paragraph,
new Paragraph({
children: [
new TextRun("This is a demo "),
new DeletedTextRun({
break: 1,
text: "in order",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF",
fill: "FF0000",
},
id: 2,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
}),
new InsertedTextRun({
text: "to show how to ",
bold: false,
id: 3,
author: "Firstname Lastname",
date: "2020-10-06T09:05:00Z",
}),
new TextRun({
bold: true,
children: ["\tuse Inserted and Deleted TextRuns.", new FootnoteReferenceRun(1)],
}),
],
}),
],
footers: {
default: new Footer({
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun("Awesome LLC"),
new TextRun({
children: ["Page Number: ", PageNumber.CURRENT],
}),
new DeletedTextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
id: 4,
author: "Firstname Lastname",
date: "2020-10-06T09:05:00Z",
}),
new InsertedTextRun({
children: [" from ", PageNumber.TOTAL_PAGES],
bold: true,
id: 5,
author: "Firstname Lastname",
date: "2020-10-06T09:05:00Z",
}),
],
}),
],
}),
},
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

73
demo/61-text-frame.ts Normal file
View File

@ -0,0 +1,73 @@
// Text Frame (Text Box) example
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, FrameAnchorType, HorizontalPositionAlign, Packer, Paragraph, TextRun, VerticalPositionAlign } from "../build";
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
frame: {
position: {
x: 1000,
y: 3000,
},
width: 4000,
height: 1000,
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
alignment: {
x: HorizontalPositionAlign.CENTER,
y: VerticalPositionAlign.TOP,
},
},
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
left: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
right: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,36 @@
// Simple example to add text to a document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "../build";
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
spacing: {
after: 5000,
before: 5000,
},
children: [new TextRun("Hello World")],
}),
new Paragraph({
spacing: {
line: 2000,
lineRule: LineRuleType.AUTO,
},
children: [
new TextRun(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed turpis ex, aliquet et faucibus quis, euismod in odio. Fusce gravida tempor nunc sed lacinia. Nulla sed dolor fringilla, fermentum libero ut, egestas ex. Donec pellentesque metus non orci lacinia bibendum. Cras porta ex et mollis hendrerit. Suspendisse id lectus suscipit, elementum lacus eu, convallis felis. Fusce sed bibendum dolor, id posuere ligula. Aliquam eu elit ut urna eleifend vestibulum. Praesent condimentum at turpis sed scelerisque. Suspendisse porttitor metus nec vestibulum egestas. Sed in eros sapien. Morbi efficitur placerat est a consequat. Nunc bibendum porttitor mi nec tempus. Morbi dictum augue porttitor nisi sodales sodales.",
),
],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,71 @@
// Move + offset header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "../build";
const doc = new Document({
evenAndOddHeaderAndFooters: true,
sections: [
{
headers: {
default: new Header({
children: [
new Paragraph({
text: "Odd Header text",
}),
new Paragraph({
text: "Odd - Some more header text",
}),
],
}),
even: new Header({
children: [
new Paragraph({
text: "Even header text",
}),
new Paragraph({
text: "Even - Some more header text",
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
text: "Odd Footer text",
}),
],
}),
even: new Footer({
children: [
new Paragraph({
text: "Even Cool Footer text",
}),
],
}),
},
children: [
new Paragraph({
children: [new TextRun("Hello World 1"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 2"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 3"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 4"), new PageBreak()],
}),
new Paragraph({
children: [new TextRun("Hello World 5"), new PageBreak()],
}),
],
},
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -3,13 +3,19 @@
import * as fs from "fs";
import { Document, Packer, PageOrientation, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
size: {
orientation: PageOrientation.LANDSCAPE,
},
children: [new Paragraph("Hello World")],
const doc = new Document({
sections: [
{
properties: {
page: {
size: {
orientation: PageOrientation.LANDSCAPE,
},
},
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -3,20 +3,22 @@
import * as fs from "fs";
import { Document, Footer, Header, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
headers: {
default: new Header({
children: [new Paragraph("Header text")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer text")],
}),
},
children: [new Paragraph("Hello World")],
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [new Paragraph("Header text")],
}),
},
footers: {
default: new Footer({
children: [new Paragraph("Footer text")],
}),
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

View File

@ -1,33 +1,48 @@
// Add images to header and footer
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Media, Packer, Paragraph } from "../build";
import { Document, Footer, Header, ImageRun, Packer, Paragraph } from "../build";
const doc = new Document();
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
doc.addSection({
headers: {
default: new Header({
children: [
new Paragraph({
children: [image1],
const doc = new Document({
sections: [
{
headers: {
default: new Header({
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
children: [image2],
},
footers: {
default: new Footer({
children: [
new Paragraph({
children: [
new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
}),
],
}),
],
}),
],
}),
},
children: [new Paragraph("Hello World")],
},
children: [new Paragraph("Hello World")],
},
],
});
Packer.toBuffer(doc).then((buffer) => {

File diff suppressed because one or more lines are too long

View File

@ -14,26 +14,28 @@
function generate() {
const doc = new docx.Document();
doc.addSection({
children: [
new docx.Paragraph({
const doc = new Document({
sections: [
{
children: [
new docx.TextRun("Hello World"),
new docx.TextRun({
text: "Foo Bar",
bold: true,
}),
new docx.TextRun({
text: "\tGithub is the best",
bold: true,
new docx.Paragraph({
children: [
new docx.TextRun("Hello World"),
new docx.TextRun({
text: "Foo Bar",
bold: true,
}),
new docx.TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
}),
},
],
});
docx.Packer.toBlob(doc).then((blob) => {
console.log(blob);
saveAs(blob, "example.docx");

View File

@ -1,13 +1,3 @@
<p align="center">
<img alt="clippy the assistant" src="https://i.imgur.com/37uBGhO.gif">
</p>
<p align="center">
Easily generate .docx files with JS/TS. Works for Node and on the Browser. :100:
</p>
---
# Welcome
## Installation
@ -34,28 +24,27 @@ import { ... } from "docx";
import * as fs from "fs";
import { Document, Packer, Paragraph, TextRun } from "docx";
// Create document
const doc = new Document();
// Documents contain sections, you can have multiple sections per document, go here to learn more about sections
// This simple example will only contain one section
doc.addSection({
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
const doc = new Document({
sections: [{
properties: {},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
}),
],
}];
});
// Used to export the file into a .docx file
@ -63,17 +52,11 @@ Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
// Done! A file called 'My First Document.docx' will be in your file system.
// Done! A file called 'My Document.docx' will be in your file system.
```
## Honoured Mentions
[@felipeochoa](https://github.com/felipeochoa)
[@h4buli](https://github.com/h4buli)
<p align="center">
<img alt="clippy the assistant" src="http://i60.tinypic.com/339pvtt.png">
<img alt="clippy the assistant" src="./clippy.png">
</p>
---

10
docs/_coverpage.md Normal file
View File

@ -0,0 +1,10 @@
<img src="https://i.imgur.com/37uBGhO.gif" alt="drawing" style="width:200px;"/>
> Easily generate .docx files with JS/TS. Works for Node and on the Browser. :100:
- Simple, declarative API
- 60+ usage examples
- Battle tested, mature, 98%+ coverage
[GitHub](https://github.com/dolanmiu/docx)
[Get Started](#Welcome)

View File

@ -1,6 +1,6 @@
* [Getting Started](/)
* [Examples](examples.md)
* [Examples](https://github.com/dolanmiu/docx/tree/master/demo)
* API
@ -20,12 +20,17 @@
* [Tab Stops](usage/tab-stops.md)
* [Table of Contents](usage/table-of-contents.md)
* [Page Numbers](usage/page-numbers.md)
* [Change Tracking](usage/change-tracking.md)
* [Math](usage/math.md)
* [Text Frames](usage/text-frames.md)
* Styling
* [Styling with JS](usage/styling-with-js.md)
* [Styling with XML](usage/styling-with-xml.md)
* Exporting
* [Packers](usage/packers.md)
* Utility
* [Convenience functions](usage/convenience-functions.md)
* [Contribution Guidelines](contribution-guidelines.md)

BIN
docs/clippy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
docs/clippy.psd Normal file

Binary file not shown.

View File

@ -1,25 +1,23 @@
# Contribution Guidelines
* Include documentation reference(s) at the top of each file:
- Include documentation reference(s) at the top of each file:
```ts
// http://officeopenxml.com/WPdocument.php
```
* Follow Prettier standards, and consider using the [Prettier VSCode](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugin.
- Follow Prettier standards, and consider using the [Prettier VSCode](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugin.
* Follow the `TSLint` rules
- Follow the `TSLint` rules
## Always think about the user
The number one pillar for contribution to `docx` is to **ALWAYS** think about how the user will use `docx`.
Put yourself in their position, and imagine how they would feel about your feature you wrote.
1. Is it easy to use?
2. Has it been documented well?
3. Is it intuitive?
4. Is it consistent with the rest of the API?
4. Is it declarative?
5. Is it fun to use?
## Good Commit Names
@ -27,6 +25,7 @@ Put yourself in their position, and imagine how they would feel about your featu
Please write good commit messages when making a commit: https://chris.beams.io/posts/git-commit/
**Do not:**
```
c // What?
rtl // Adding acryonyms without explaining anything else is not helpful
@ -35,34 +34,6 @@ demo updated // Getting better, but capitalize the first letter
Unesesary coment removed // Make sure to use correct spelling
```
## No leaky components in API interface
> This mainly applies to the API the end user will consume.
Try to make method parameters of the outside API accept primitives, or `json` objects, so that child components are created **inside** the component, rather than being **injected** in.
This is so that:
1. Imports are much cleaner for the end user, no need for:
```ts
import { ChildComponent } from "./my-feature/sub-component/deeper/.../my-deep.component";
```
2. This is what I consider "leakage". The code is aware of the underlying implementation of the component.
3. It means the end user does not need to import and create the child component to be injected.
**Do not**
`TableFloatProperties` is a class. The outside world would have to `new` up the object, and inject it in like so:
```ts
public float(tableFloatProperties: TableFloatProperties): Table
```
```ts
table.float(new TableFloatProperties(...));
```
**Do**
`ITableFloatOptions` is an interface for a JSON of primitives. The end user would need to pass in a json object and not need to worry about the internals:
@ -71,31 +42,31 @@ This is so that:
public float(tableFloatOptions: ITableFloatOptions): Table
```
## Delcariative API
Make sure the API is declarative, so no _method calling_ or _mutation_. This is a design decision, consistent with the rest of the project. There are benefits to delcariative code over other styles of code, explained here: https://dzone.com/articles/why-declarative-coding-makes-you-a-better-programm
**Do not:**
```ts
table.float({...});
const paragraph = doc.createParagraph();
const text = paragraph.createText();
text.contents = "Hello World";
```
## Add vs Create
**Do**
This is just a guideline, and the rules can sometimes be broken.
* Use `create` if the method `new`'s up an element inside:
```ts
public createParagraph() {
const paragraph = new Paragraph();
this.root.push(paragraph);
}
```
* Use `add` if you add the element into the method as a parameter.
*Note:* This may look like its breaking the previous guideline, but it has semantically different meanings. The previous one is using data to construct an object, whereas this one is simply adding elements into the document:
```ts
public add(paragraph: Paragraph) {
this.root.push(paragraph);
}
```
```ts
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
}];
});
```
## Getters and Setters
@ -107,7 +78,7 @@ public get Level() {
}
```
There is no performance advantage by doing this. It means we don't need to prefix all private variables with the ugly `_`:
This is the convention of this project. There is no performance advantage by doing this. It means we don't need to prefix all private variables with `_`:
**Do not:**
@ -121,30 +92,6 @@ private get _level: string;
private get level: string;
```
## Temporal Methods
Some methods are `non-temporal`, which means regardless of when you call the method, it will have the same affect on the document. For example, setting the width of a table at the end of the document will have the same effect as setting the width at the start:
```ts
table.setWidth(1000); // now removed as of version 5.0.0
```
Whereas some methods are `temporal`, which means depending on the time-frame they are called, it would produce a difference result. For example, moving `createParagraph()` around your code will physically alter the document.
```ts
doc.createParagraph("hello");
```
If a method is `non-temporal`, put it in the objects `constructor`. For example:
```ts
const table = new Table(width: number);
```
`Non-temporal` methods are usually methods which can only be used one time and one time only. For example, `.float()`. It does not make sense to call `.float()` again if its already floating.
I am not sure what the real term is, but this will do.
## Interfaces over type alias
Do not use `type`, but rather use `Interfaces`. `type` cannot be extended, and a class cannot implement it.
@ -152,14 +99,14 @@ Do not use `type`, but rather use `Interfaces`. `type` cannot be extended, and a
> "In general, use what you want ( type alias / interface ) just be consistent"
> "always use interface for public API's definition when authoring a library or 3rd party ambient type definitions"
>
> * https://medium.com/@martin_hotell/interface-vs-type-alias-in-typescript-2-7-2a8f1777af4c
> - https://medium.com/@martin_hotell/interface-vs-type-alias-in-typescript-2-7-2a8f1777af4c
`Interface` is generally preferred over `type`: https://stackoverflow.com/questions/37233735/typescript-interfaces-vs-types
**Do not:**
```ts
type RelationshipFileInfo = { id: number, target: string };
type RelationshipFileInfo = { id: number; target: string };
```
**Do:**
@ -193,26 +140,26 @@ enum WeaponType = {
## Spell correctly, in full and in American English
I am not sure where these habits in software development come from, but I do not believe it is beneficial:
**Do not:**
```ts
readdy // misspelling
perm // abbreviation
conf // abbreviation
cnty // abbreviation
relationFile // abbreviation
colour // U.K. English
readdy; // misspelling
perm; // abbreviation
conf; // abbreviation
cnty; // abbreviation
relationFile; // abbreviation
colour; // U.K. English
```
**Do:**
```ts
ready
permission
config
country
relationshipFile
color
ready;
permission;
config;
country;
relationshipFile;
color;
```
## Keep files small (within reason)

View File

@ -1,219 +0,0 @@
# Examples
> All examples can run independently and can be found in the `/demo` folder of the project
All the examples below can be ran locally, to do so, run the following command:
```sh
npm run demo
```
This command will run the `demo selector app` in the `/demo` folder. It will prompt you to select a demo number, which will run a demo from that folder.
## Simple
A simple hello world of the `docx` library:
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo1.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo1.ts_
## Styles
### Styling with JS
This example shows how to customise the look and feel of a document using JS configuration
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo2.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo2.ts_
### Styling with XML
This example shows how to customise the look and feel of a document using XML configuration
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo13.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo13.ts_
## Numbering
This example shows many levels of numbering
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo3.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo3.ts_
## Table
Example of simple table
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo4.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo4.ts_
### Styling table borders
Styling the borders of a table
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo20.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo20.ts_
## Images
### Add image to the document
Importing Images from file system path
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo5.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo5.ts_
### Add images to header and footer
Example showing how to add image to headers and footers
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo9.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo9.ts_
### Scaling images
Example showing how to scale images
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo12.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo12.ts_
### Add Image to media before adding to document
This is the best way to add an image to a document because you can add the same image in two locations without increasing document size by re-using the same image
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo23.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo23.ts_
### Add image to table
As before, to add an image to a table, you would need to add it to the `Media` object first
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo24.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo24.ts_
### Images using Base64 URI
If you want to use a Base64 image instead
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo18.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo18.ts_
## Margins
Example showing how to set custom margins
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo6.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo6.ts_
## Orientation
Example showing how to set the document to `landscape` or `portrait`
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo7.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo7.ts_
## Headers & Footers
Example showing how to add headers and footers
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo8.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo8.ts_
## Multiple headers and footers
Check out `Sections` for this feature
## Page Breaks
### Normal page breaks
Example showing how to page break
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo14.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo14.ts_
### Page break before
Example showing how to page break before like in Word
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo15.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo15.ts_
## Sections
Example of how sections work. Sections allow multiple headers and footers, and `landscape`/`portrait` inside the same document.
Also you can have different page number formats and starts for different sections.
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo16.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo16.ts_
## Footnotes
Example of how to add footnotes. Good for references
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo17.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo17.ts_
## Packers
## Buffer output
Example showing how to use the Buffer packer and then write that buffer to the file system
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo19.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo19.ts_
## Bookmarks
Example showing how to make bookmarks to make internal hyperlinks within the document
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo21.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo21.ts_
## Bidirectional text
Example showing how to use bidirectional text for certain languages such as Hebrew
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo22.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo22.ts_
## Showcase
### My CV
Example showing how to add headers and footers
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo10.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo10.ts_
### Style and Images
This example shows how to customise the look and feel of a document and add images
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/demo11.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/demo11.ts_

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,40 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>docx - Generate .docx documents with JavaScript</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Generate .docx documents with JavaScript" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/style.min.css"
title="docsify-darklight-theme"
type="text/css"
/>
</head>
<head>
<meta charset="UTF-8">
<title>docx - Generate .docx documents with JavaScript</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Generate .docx documents with JavaScript">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/style.min.css"
title="docsify-darklight-theme"
type="text/css"
/>
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'docx',
repo: 'https://github.com/dolanmiu/docx',
loadSidebar: true,
subMaxLevel: 2,
search: 'auto',
}
</script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/emoji.min.js"></script>
<script src="https://unpkg.com/docsify-copy-code@2"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-typescript.min.js"></script>
<script
src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js"
type="text/javascript">
</script>
</body>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: "docx",
repo: "https://github.com/dolanmiu/docx",
loadSidebar: true,
subMaxLevel: 2,
search: "auto",
coverpage: true,
};
</script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/emoji.min.js"></script>
<script src="https://unpkg.com/docsify-copy-code@2"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-typescript.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/dist/index.min.js" type="text/javascript"></script>
</body>
</html>

View File

@ -1,16 +1,28 @@
# Bullet Points
!> Bullet Points requires an understanding of [Paragraphs](usage/paragraph.md).
## Example
To make a bullet point, simply make a paragraph into a bullet point:
```ts
const text = new TextRun("Bullet points");
const paragraph = new Paragraph({
text: "Bullet points",
bullet: {
level: 0, // How deep you want the bullet to me
},
const doc = new Document({
sections: [{
children: [
new Paragraph({
text: "Bullet points",
bullet: {
level: 0 //How deep you want the bullet to be
}
}),
new Paragraph({
text: "Are awesome",
bullet: {
level: 0
}
})
],
}];
});
```

View File

@ -0,0 +1,61 @@
# Change Tracking
> Instead of adding a `TextRun` into a `Paragraph`, you can also add an `InsertedTextRun` or `DeletedTextRun` where you need to supply an `id`, `author` and `date` for the change.
```ts
import { Paragraph, TextRun, InsertedTextRun, DeletedTextRun } from "docx";
const paragraph = new Paragraph({
children: [
new TextRun("This is a simple demo "),
new TextRun({
text: "on how to "
}),
new InsertedTextRun({
text: "mark a text as an insertion ",
id: 0,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
}),
new DeletedTextRun({
text: "or a deletion.",
id: 1,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
})
],
});
```
Note that for a `InsertedTextRun` and `DeletedTextRun`, it is not possible to simply call it with only a text as in `new TextRun("some text")`, since the additonal fields for change tracking need to be provided. Similar to a normal `TextRun` you can add additional text properties.
```ts
import { Paragraph, TextRun, InsertedTextRun, DeletedTextRun } from "docx";
const paragraph = new Paragraph({
children: [
new TextRun("This is a simple demo"),
new DeletedTextRun({
text: "with a deletion.",
color: "red",
bold: true,
size: 24,
id: 0,
author: "Firstname Lastname",
date: "2020-10-06T09:00:00Z",
})
],
});
```
In addtion to marking text as inserted or deleted, change tracking can also be added via the document settings. This will enable new changes to be tracked as well.
```ts
import { Document } from "docx";
const doc = new Document({
features: {
trackRevisions: true,
},
});
```

View File

@ -0,0 +1,22 @@
# Convenience functions
OOXML and this library mainly uses a unit called twentieths of a point or `twip` for short. a twip is a typographical measurement, defined as 1/20 of a typographical point. One twip is 1/1440 inch, or 17.64 μm. This unit is not intuitive for many users, so some functions were created to help
More info here: https://en.wikipedia.org/wiki/Twip
## Convert Inches to Twip
```ts
import { convertInchesToTwip } from "docx";
const twip = convertInchesToTwip(1); // returns 1440
const twip = convertInchesToTwip(0.5); // returns 720
```
## Convert Millimeters to Twip
```ts
import { convertMillimetersToTwip } from "docx";
const twip = convertMillimetersToTwip(50); // returns 2834
```

View File

@ -30,6 +30,24 @@ const doc = new docx.Document({
* keywords
* lastModifiedBy
* revision
* externalStyles
* styles
* numbering
* footnotes
* hyperlinks
* background
### Change background color of Document
Set the hex value in the document like so:
```ts
const doc = new docx.Document({
background: {
color: "C45911",
},
});
```
You can mix and match whatever properties you want, or provide no properties.

View File

@ -5,35 +5,35 @@
Every Section has a sections which you can define its Headers and Footers:
```ts
doc.addSection({
headers: {
default: new Header({ // The standard default header
children: [],
}),
first: new Header({ // The first header
children: [],
}),
even: new Header({ // The header on every other page
children: [],
}),
},
footers: {
default: new Footer({ // The standard default footer
children: [],
}),
first: new Footer({ // The first footer
children: [],
}),
even: new Footer({ // The footer on every other page
children: [],
}),
},
children: [],
const doc = new Document({
sections: [{
headers: {
default: new Header({ // The standard default header
children: [],
}),
first: new Header({ // The first header
children: [],
}),
even: new Header({ // The header on every other page
children: [],
}),
},
footers: {
default: new Footer({ // The standard default footer
children: [],
}),
first: new Footer({ // The first footer
children: [],
}),
even: new Footer({ // The footer on every other page
children: [],
}),
},
children: [],
}];
});
```
If you want more head
## Example
Example showing basic header and footer

View File

@ -5,7 +5,12 @@
To create a `floating` image on top of text:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
const image = new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
}
floating: {
horizontalPosition: {
offset: 1014400,
@ -20,47 +25,52 @@ Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
By default with no arguments, its an `inline` image:
```ts
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
const image = new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 100,
height: 100,
},
});
```
Add it into the document by adding the image into a paragraph:
```ts
doc.addSection({
children: [new Paragraph(image)],
});
```
Or:
```ts
doc.addSection({
children: [
new Paragraph({
children: [image],
}),
],
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [image],
}),
],
}];
});
```
## Intro
Adding images can be done in two ways:
Adding images can be easily done by creating an instance of `ImageRun`. This can be added in a `Paragraph` or `Hyperlink`:
1. Call the `createImage` method to add the image directly into the `document`:
```ts
Media.addImage(doc, [IMAGE_BUFFER], [WIDTH], [HEIGHT], [POSITION_OPTIONS]);
```
2. Create an `image` first, then add it into the `document`:
```ts
const image = Media.addImage(doc, [IMAGE_BUFFER]);
doc.addSection({
children: [new Paragraph(image)],
});
```
```ts
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new ImageRun({
data: [IMAGE_BUFFER],
transformation: {
width: [IMAGE_SIZE],
height: [IMAGE_SIZE],
},
}),
],
}),
],
}];
});
```
`docx` supports `jpeg`, `jpg`, `bmp`, `gif` and `png`
@ -75,7 +85,7 @@ Three types of image positioning is supported:
- Floating
- Inline
By default, picture are exported as `Inline` elements.
By default, images are exported as `Inline` elements.
### Usage
@ -86,7 +96,12 @@ Pass `options` into the `[POSITION_OPTIONS]` metioned in the [Intro above](#Intr
To change the position the image to be on top of the text, simply add the `floating` property to the last argument. By default, the offsets are relative to the top left corner of the `page`. Offset units are in [emus](https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/):
```ts
const imageData = document.createImage(buffer, 903, 1149, {
const image = new ImageRun({
data: buffer,
transformation: {
width: 903,
height: 1149,
},
floating: {
horizontalPosition: {
offset: 1014400, // relative: HorizontalPositionRelativeFrom.PAGE by default
@ -99,7 +114,12 @@ const imageData = document.createImage(buffer, 903, 1149, {
```
```ts
const imageData = document.createImage(buffer, 903, 1149, {
const image = new ImageRun({
data: buffer,
transformation: {
width: 903,
height: 1149,
},
floating: {
horizontalPosition: {
relative: HorizontalPositionRelativeFrom.RIGHT_MARGIN,
@ -125,6 +145,7 @@ Full options you can pass into `floating` are:
| lockAnchor | `boolean` | Optional |
| behindDocument | `boolean` | Optional |
| layoutInCell | `boolean` | Optional |
| zIndex | `number` | Optional |
`HorizontalPositionOptions` are:
@ -158,7 +179,12 @@ wrap: {
For example:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
const image = new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
},
floating: {
horizontalPosition: {
offset: 2014400,
@ -201,7 +227,12 @@ margins: {
For example:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
const image = new ImageRun({
data: fs.readFileSync("./demo/images/pizza.gif"),
transformation: {
width: 200,
height: 200,
},
floating: {
horizontalPosition: {
offset: 2014400,

265
docs/usage/math.md Normal file
View File

@ -0,0 +1,265 @@
# Math
!> Math requires an understanding of [Sections](usage/sections.md) and [Paragraphs](usage/paragraph.md).
## Intro
1. To add math, create a `Math` object
2. Add `MathComponents` inside `Math`
3. `MathComponents` can have nested `MathComponents` inside. e.g. A fraction where the numerator is a square root, and the demoninator as another fraction. More on `MathComponents` below
4. Make sure to add the `Math` object inside a `Paragraph`
## Example
```ts
new Math({
children: [
new MathRun("2+2"),
new MathFraction({
numerator: [new MathRun("hi")],
denominator: [new MathRun("2")],
}),
],
}),
```
This will produce:
<p align="center">
<img alt="clippy the assistant" src="images/math-example.png" width="200">
</p>
## Math Components
`MathComponents` are the unit sized building blocks of an equation in `docx`. A `MathComponent` takes in more nested `MathComponents` until you reach `MathRun`, which has no children. `MathRun` is similar to a [TextRun](usage/text.md).
### Math Run
`MathRun` is the most basic `MathComponent`.
#### Example
```ts
new MathRun("2+2");
```
```ts
new MathRun("hello");
```
An example of it being used inside `Math`:
```ts
new Math({
children: [
new MathRun("2"),
new MathRun("+"),
new MathRun("2"),
],
}),
```
### Math Fraction
`MathFractions` require a `numerator` and a `demoninator`, which are both a list of `MathComponents`
#### Example
```ts
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
```
```ts
new MathFraction({
numerator: [
new MathRun("1"),
new MathRadical({
children: [new MathRun("2")],
}),
],
denominator: [new MathRun("2")],
}),
```
An example of it being used inside `Math`:
```ts
new Math({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
new MathText("+"),
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
new MathText("= 1"),
],
}),
```
### Sum
A `MathComponent` for `Σ`. It can take a `superScript` and/or `subScript` as arguments to add `MathComponents` (usually limits) on the top and bottom
```ts
new MathSum({
children: [new MathRun("i")],
}),
```
```ts
new MathSum({
children: [
new MathSuperScript({
children: [new MathRun("e")],
superScript: [new MathRun("2")],
})
],
subScript: [new MathRun("i")],
superScript: [new MathRun("10")],
}),
```
### Radicals
A `MathComponent` for the `√` symbol. Examples include, square root, cube root etc. There is an optional `degree` parameter to specify the number of times the radicand is multiplied by itself. For example, `3` for cube root.
```ts
new MathRadical({
children: [new MathRun("2")],
}),
```
Cube root example:
```ts
new MathRadical({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
new MathRun('+ 1'),
],
degree: [new MathRun("3")],
}),
```
### Super Script
`MathSuperScripts` are the little numbers written to the top right of numbers or variables. It means the exponent or power if written by itself with the number or variable.
```ts
new MathSuperScript({
children: [new MathRun("x")],
superScript: [new MathRun("2")],
}),
```
An example with cosine:
```ts
new MathSuperScript({
children: [new MathRun("cos")],
superScript: [new MathRun("-1")],
}),
```
### Sub Script
`MathSubScripts` are similar to `MathSuperScripts`, except the little number is written below.
```ts
new MathSubScript({
children: [new MathRun("F")],
subScript: [new MathRun("n-1")],
}),
```
### Sub-Super Script
`MathSubSuperScripts` are a combination of both `MathSuperScript` and `MathSubScript`.
```ts
new MathSubSuperScript({
children: [new MathRun("test")],
superScript: [new MathRun("hello")],
subScript: [new MathRun("world")],
}),
```
### Function
`MathFunctions` are a way of describing what happens to an input variable, in order to get the output result. It takes a `name` parameter to specify the name of the function.
```ts
new MathFunction({
name: [
new MathSuperScript({
children: [new MathRun("cos")],
superScript: [new MathRun("-1")],
}),
],
children: [new MathRun("100")],
}),
```
### Brackets
#### Square brackets
```ts
new MathSquareBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
```
#### Round brackets
```ts
new MathRoundBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
```
#### Curly brackets
```ts
new MathCurlyBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
```
#### Angled brackets
```ts
new MathAngledBrackets({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
}),
```

View File

@ -2,11 +2,7 @@
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
Packers in `version 4` and above are now one single `Packer`. It works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob` or `base64 string`. It is up to you to take that and persist it with node's `fs`, send it down as a downloadable file, or anything else you wish. As of version 4, this library will not have options to export to PDF.
## Version 5
Packers in `version 5` and above are now static methods on `Packer`.
Packers works in both a node and browser environment (Angular etc). Now, the packer returns a `Buffer`, `Blob` or `base64 string`. It is up to you to take that and persist it with node's `fs`, send it down as a downloadable file, or anything else you wish. As of `version 4+`, this library will not have options to export to PDF.
### Export as Buffer
@ -36,117 +32,3 @@ Packer.toBlob(doc).then((blob) => {
saveAs(blob, "example.docx");
});
```
## Version 4
The `Packer` in `version 4` requires an instance of `Packer`, so be sure to `new` it.
### Export as Buffer
This will return a NodeJS `Buffer`. If this is used in the browser, it will return a `UInt8Array` instead.
```ts
const packer = new docx.Packer();
packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
```
### Export as a `base64` string
```ts
const packer = new docx.Packer();
packer.toBase64String(doc).then((string) => {
console.log(string);
});
```
### Export as Blob
This is useful if you want to send it as an downloadable in a browser environment.
```ts
const packer = new docx.Packer();
packer.toBlob(doc).then((blob) => {
// saveAs from FileSaver will download the file
saveAs(blob, "example.docx");
});
```
## Version 3 and below
### File System Packer
```ts
const docx = require("docx");
const doc = new docx.Document();
const exporter = new docx.LocalPacker(doc);
exporter.pack("My Document");
// Word Document is in file system
```
### Buffer Packer
```ts
const docx = require("docx");
const doc = new docx.Document();
const exporter = new docx.BufferPacker(doc);
const buffer = exporter.pack();
```
### Stream Packer
Creates a `node` `Readable` stream
```ts
const docx = require("docx");
const doc = new docx.Document();
const exporter = new docx.StreamPacker(doc);
const stream = exporter.pack();
```
### Express Packer
The old express packer is now deprecated and may disappear soon, so you should upgrade.
The reason for this is because it means this project needs to know about and use `express`, which for a Word document generator, does not sound right. Seperation of concerns.
It will still be usable (for now), but it is ill advised.
I used the express exporter in my [website](http://www.dolan.bio).
The recommended way is to use the `StreamPacker` and handle the `express` magic outside of the library:
```ts
const docx = require("docx");
const doc = new docx.Document();
const exporter = new docx.StreamPacker(doc);
const stream = exporter.pack();
// Express' response object
res.attachment("yourfile.xlsx");
stream.pipe(res);
```
where `res` is the response object obtained through the Express router. It is that simple. The file will begin downloading in the browser.
### PDF Exporting
You can export your word document as a PDF file like so:
```ts
const exporter = new docx.LocalPacker(doc);
exporter.packPdf("My Document");
// Express
const exporter = new docx.ExpressPacker(doc, res);
exporter.packPdf("My Document");
```

View File

@ -32,23 +32,27 @@ const paragraph = new Paragraph({
});
```
After you create the paragraph, you must add the paragraph into the `document's section`. Learn more about `sections` here:
After you create the paragraph, you must add the paragraph into a `section`:
```ts
doc.addSection({
children: [paragraph],
const doc = new Document({
sections: [{
children: [paragraph],
}];
});
```
Or the preferred convension, define the paragraph inside the section and remove the usage of variables:
```ts
doc.addSection({
children: [
new Paragraph({
children: [new TextRun("Lorem Ipsum Foo Bar"), new TextRun("Hello World")],
}),
],
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [new TextRun("Lorem Ipsum Foo Bar"), new TextRun("Hello World")],
}),
],
}];
});
```
@ -72,11 +76,13 @@ This is the list of options for a paragraph. A detailed explanation is below:
| indent | `IIndentAttributesProperties` | Optional | |
| keepLines | `boolean` | Optional | |
| keepNext | `boolean` | Optional | |
| children | `(TextRun or PictureRun or Hyperlink)[]` | Optional | |
| children | `(TextRun or ImageRun or Hyperlink)[]` | Optional | |
| style | `string` | Optional | |
| tabStop | `{ left?: ITabStopOptions; right?: ITabStopOptions; maxRight?: { leader: LeaderType; }; center?: ITabStopOptions }` | Optional | |
| bullet | `{ level: number }` | Optional | |
| numbering | `{ num: ConcreteNumbering; level: number; custom?: boolean }` | Optional | |
| [tabStop](usage/tab-stops) | `{ left?: ITabStopOptions; right?: ITabStopOptions; maxRight?: { leader: LeaderType; }; center?: ITabStopOptions }` | Optional | |
| [bullet](usage/bullet-points) | `{ level: number }` | Optional | |
| [numbering](usage/numbering) | `{ num: ConcreteNumbering; level: number; custom?: boolean }` | Optional | |
| [widowControl](#widow-control) | `boolean` | Optional | |
| [frame](usage/text-frames.md) | `IFrameOptions` | Optional | |
## Text
@ -142,18 +148,44 @@ const paragraph = new Paragraph({
});
```
## Shading
Add color to an entire paragraph block
```ts
const paragraph = new Paragraph({
text: "shading",
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF",
fill: "FF0000",
},
});
```
## Widow Control
Allow First/Last Line to Display on a Separate Page
```ts
const paragraph = new Paragraph({
text: "shading",
widowControl: true,
});
```
## Spacing
Adding spacing between paragraphs
### ISpacingProperties
| Property | Type | Notes |
| -------- | -------- | -------- |
| after | `number` | Optional |
| before | `number` | Optional |
| line | `number` | Optional |
| lineRule | `string` | Optional |
| Property | Type | Notes |
| -------- | -------------- | -------- |
| after | `number` | Optional |
| before | `number` | Optional |
| line | `number` | Optional |
| lineRule | `LineRuleType` | Optional |
**Example:**
@ -180,7 +212,7 @@ const paragraph = new Paragraph({
## Styles
To create styles, please refer to the styling Wiki: https://github.com/dolanmiu/docx/wiki/Styling
To create styles, please refer to the [styling documentation](usage/styling-with-js)
![Word 2013 Styles menu](http://content.gcflearnfree.org/topics/233/style_apply_choose.png "Word 2013 Styles menu")

View File

@ -11,11 +11,42 @@ For example, you could have one section which is portrait with a header and foot
This creates a simple section in a document with one paragraph inside:
```ts
doc.addSection({
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
}];
});
```
## Properties
You can specify additional properties to the section, by providing a `properties` attribute.
### Section Type
Setting the section type determines how the contents of the section will be placed relative to the previous section. E.g., There are five different types:
- `CONTINUOUS`
- `EVEN_PAGE`
- `NEXT_COLUMN`
- `NEXT_PAGE`
- `ODD_PAGE`
```ts
const doc = new Document({
sections: [{
properties: {
type: SectionType.CONTINUOUS,
}
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
}];
});
```

View File

@ -22,10 +22,11 @@ const name = new TextRun({
### Run formatting
- `bold`, `italics`, `smallCaps`, `allCaps`, `strike`, `doubleStrike`, `subScript`, `superScript`: Set the formatting property to true
- `underline(style="single", color=null)`: Set the underline style and color
- `underline({type="single", color=null})`: Set the underline style and color
- `emphasisMark({type="dot"})`: Set the emphasis mark style
- `color(color)`: Set the text color, using 6 hex characters for RRGGBB (no leading `#`)
- `size(halfPts)`: Set the font size, measured in half-points
- `font(name)`: Set the run's font
- `font(name)` or `font({ascii, cs, eastAsia, hAnsi, hint})`: Set the run's font
- `style(name)`: Apply a named run style
- `characterSpacing(value)`: Set the character spacing adjustment (in TWIPs)

View File

@ -4,9 +4,9 @@
## Intro
* `Tables` contain a list of `Rows`
* `Rows` contain a list of `TableCells`
* `TableCells` contain a list of `Parahraphs` and/or `Tables`. You can add `Tables` as tables can be nested inside each other
- `Tables` contain a list of `Rows`
- `Rows` contain a list of `TableCells`
- `TableCells` contain a list of `Parahraphs` and/or `Tables`. You can add `Tables` as tables can be nested inside each other
Create a simple table like so:
@ -19,8 +19,10 @@ const table = new Table({
Then add the table in the `section`
```ts
doc.addSection({
children: [table],
const doc = new Document({
sections: [{
children: [table],
}];
});
```
@ -51,19 +53,6 @@ const table = new Table({
});
```
### Pagination
#### Prevent row pagination
To prevent breaking contents of a row across multiple pages, call `cantSplit`:
```ts
const table = new Table({
rows: [],
cantSplit: true,
});
```
## Table Row
A table consists of multiple `table rows`. Table rows have a list of `children` which accepts a list of `table cells` explained below. You can create a simple `table row` like so:
@ -98,12 +87,12 @@ const table = new Table({
Here is a list of options you can add to the `table row`:
| Property | Type | Notes |
| ----------- | ------------------------------------- | -------- |
| children | `Array<TableCell>` | Required |
| cantSplit | `boolean` | Optional |
| tableHeader | `boolean` | Optional |
| height | `{ value: number, rule: HeightRule }` | Optional |
| Property | Type | Notes |
| ----------- | -------------------------------------- | -------- |
| children | `Array<TableCell>` | Required |
| cantSplit | `boolean` | Optional |
| tableHeader | `boolean` | Optional |
| height | `{ height: number, rule: HeightRule }` | Optional |
### Repeat row
@ -116,6 +105,19 @@ const row = new TableRow({
});
```
### Pagination
#### Prevent row pagination
To prevent breaking contents of a row across multiple pages, call `cantSplit`:
```ts
const row = new Row({
...,
cantSplit: true,
});
```
## Table Cells
Cells need to be added in the `table row`, you can create a table cell like:
@ -142,7 +144,7 @@ const tableRow = new TableRow({
| Property | Type | Notes |
| ------------- | ----------------------------------- | ----------------------------------------------------------- |
| children | `Array<Paragraph | Table>` | Required. You can nest tables by adding a table into a cell |
| children | `Array<Paragraph or Table>` | Required. You can nest tables by adding a table into a cell |
| shading | `ITableShadingAttributesProperties` | Optional |
| margins | `ITableCellMarginOptions` | Optional |
| verticalAlign | `VerticalAlign` | Optional |
@ -326,6 +328,16 @@ const cell = new TableCell({
});
```
### Visual Right to Left Table
It is possible to reverse how the cells of the table are displayed. The table direction. More info here: https://superuser.com/questions/996912/how-to-change-a-table-direction-in-microsoft-word
```ts
const table = new Table({
visuallyRightToLeft: true,
});
```
## Examples
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/4-basic-table.ts ':include')

69
docs/usage/text-frames.md Normal file
View File

@ -0,0 +1,69 @@
# Text Frames
Also known as `Text Boxes`
!> Text Frames requires an understanding of [Paragraphs](usage/paragraph.md).
> Text frames are paragraphs of text in a document which are positioned in a separate region or frame in the document, and can be positioned with a specific size and position relative to non-frame paragraphs in the current document.
## Intro
To make a `Text Frame`, simply add the `frame` property on a paragraph. `Borders` can be applied to frame simply by adding the `border` attribute.
```ts
new Paragraph({
frame: {
position: {
x: 1000,
y: 3000,
},
width: 4000,
height: 1000,
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
alignment: {
x: HorizontalPositionAlign.CENTER,
y: VerticalPositionAlign.TOP,
},
},
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
left: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
right: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
});
```

View File

@ -68,40 +68,87 @@ const text = new TextRun({
});
```
### Emphasis Mark
```ts
const text = new TextRun({
text: "and then emphasis mark",
emphasisMark: {},
});
```
### Shading and Highlighting
```ts
const text = new TextRun({
text: "shading",
shading: {
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF",
fill: "FF0000",
},
});
```
```ts
const text = new TextRun({
text: "highlighting",
highlight: "yellow",
});
```
### Strike through
```ts
text.strike();
const text = new TextRun({
text: "strike",
strike: true,
});
```
### Double strike through
```ts
text.doubleStrike();
const text = new TextRun({
text: "doubleStrike",
doubleStrike: true,
});
```
### Superscript
```ts
text.superScript();
const text = new TextRun({
text: "superScript",
superScript: true,
});
```
### Subscript
```ts
text.subScript();
const text = new TextRun({
text: "subScript",
subScript: true,
});
```
### All Capitals
```ts
text.allCaps();
const text = new TextRun({
text: "allCaps",
allCaps: true,
});
```
### Small Capitals
```ts
text.smallCaps();
const text = new TextRun({
text: "smallCaps",
smallCaps: true,
});
```
## Break
@ -109,13 +156,17 @@ text.smallCaps();
Sometimes you would want to put text underneath another line of text but inside the same paragraph.
```ts
text.break();
const text = new TextRun({
text: "break",
break: 1,
});
```
## Chaining
What if you want to create a paragraph which is **_bold_** and **_italic_**?
Adding two breaks:
```ts
paragraph.bold().italics();
const text = new TextRun({
text: "break",
break: 2,
});
```

3676
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "docx",
"version": "5.1.1",
"version": "6.0.0",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
"main": "build/index.js",
"scripts": {
@ -14,7 +14,7 @@
"tsc": "rimraf ./build && tsc -p .",
"webpack": "rimraf ./build && webpack",
"demo": "npm run build && npm run ts-node ./demo",
"typedoc": "typedoc src/index.ts",
"typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json",
"style": "prettier -l \"src/**/*.ts\"",
"style.fix": "npm run style -- --write",
"fix-types": "ts-node scripts/types-absolute-fixer.ts",
@ -50,9 +50,9 @@
"types": "./build/index.d.ts",
"dependencies": {
"@types/jszip": "^3.1.4",
"@types/node": "^13.1.6",
"@types/node": "^14.0.5",
"jszip": "^3.1.5",
"shortid": "^2.2.15",
"nanoid": "^3.1.20",
"xml": "^1.0.1",
"xml-js": "^1.6.8"
},
@ -63,11 +63,10 @@
},
"homepage": "https://github.com/dolanmiu/docx#readme",
"devDependencies": {
"@types/chai": "^3.4.35",
"@types/mocha": "^2.2.39",
"@types/chai": "^4.2.15",
"@types/mocha": "^8.0.0",
"@types/request-promise": "^4.1.42",
"@types/shortid": "0.0.29",
"@types/sinon": "^4.3.1",
"@types/sinon": "^9.0.4",
"@types/webpack": "^4.4.24",
"awesome-typescript-loader": "^3.4.1",
"chai": "^3.5.0",
@ -77,24 +76,24 @@
"jszip": "^3.1.5",
"mocha": "^5.2.0",
"mocha-webpack": "^1.0.1",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"pre-commit": "^1.2.2",
"prettier": "^1.15.2",
"prettier": "^2.1.2",
"prompt": "^1.0.0",
"replace-in-file": "^3.1.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"rimraf": "^2.5.2",
"shelljs": "^0.7.7",
"sinon": "^5.0.7",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-immutable": "^4.9.0",
"typedoc": "^0.11.1",
"typescript": "2.9.2",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4",
"sinon": "^9.0.2",
"ts-node": "^9.0.0",
"tslint": "^6.1.3",
"tslint-immutable": "^6.0.1",
"typedoc": "^0.20.29",
"typescript": "4.2.3",
"webpack": "^3.10.0"
},
"engines": {
"node": ">=8"
"node": ">=10"
}
}

View File

@ -0,0 +1,33 @@
import { expect } from "chai";
import { convertInchesToTwip, convertMillimetersToTwip, uniqueId, uniqueNumericId } from "./convenience-functions";
describe("Utility", () => {
describe("#convertMillimetersToTwip", () => {
it("should call the underlying header's addChildElement for Paragraph", () => {
expect(convertMillimetersToTwip(1000)).to.equal(56692);
});
});
describe("#convertInchesToTwip", () => {
it("should call the underlying header's addChildElement", () => {
expect(convertInchesToTwip(1)).to.equal(1440);
expect(convertInchesToTwip(0.5)).to.equal(720);
expect(convertInchesToTwip(0.25)).to.equal(360);
});
});
describe("#uniqueNumericId", () => {
it("should generate a unique ID", () => {
// tslint:disable-next-line: no-unused-expression
expect(uniqueNumericId()).to.not.be.empty;
});
});
describe("#uniqueId", () => {
it("should call the underlying header's addChildElement", () => {
// tslint:disable-next-line: no-unused-expression
expect(uniqueId()).to.not.be.empty;
});
});
});

View File

@ -0,0 +1,20 @@
import { customAlphabet, nanoid } from "nanoid/non-secure";
const numericNanoId = customAlphabet("0123456789", 15);
// Twip - twentieths of a point
export const convertMillimetersToTwip = (millimeters: number): number => {
return Math.floor((millimeters / 25.4) * 72 * 20);
};
export const convertInchesToTwip = (inches: number): number => {
return Math.floor(inches * 72 * 20);
};
export const uniqueNumericId = (): number => {
return parseFloat(numericNanoId());
};
export const uniqueId = (): string => {
return nanoid().toLowerCase();
};

View File

@ -1,9 +1,9 @@
import { BaseXmlComponent, IXmlableObject } from "file/xml-components";
import { File } from "../file";
import { BaseXmlComponent, IContext, IXmlableObject } from "file/xml-components";
export class Formatter {
public format(input: BaseXmlComponent, file?: File): IXmlableObject {
const output = input.prepForXml(file);
// tslint:disable-next-line: no-object-literal-type-assertion
public format(input: BaseXmlComponent, context: IContext = {} as IContext): IXmlableObject {
const output = input.prepForXml(context);
if (output) {
return output;

Some files were not shown because too many files have changed in this diff Show More