Compare commits

...

1263 Commits
2.0.0 ... 5.4.1

Author SHA1 Message Date
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
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
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
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
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
20e6b98770 Version bump 2020-05-26 21:07:30 +01:00
5ae824358c Revert "Update numbering.ts"
This reverts commit 0ebdcc30ed.
2020-05-26 21:06:43 +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
2654799822 Version bump 2020-05-19 19:24:29 +01:00
6245635b86 Merge pull request #540 from bschwarz/add-tablecell-textdirection
adds textDirection to table cells
2020-05-13 03:00:20 +01:00
b4f1c4dd6a Increase readability for enums 2020-05-13 02:51:47 +01:00
25a7ce3742 adds textDirection to table cells 2020-05-10 10:36:25 -07:00
08bc069cbf Merge pull request #539 from adrielstar/master
Update numbering.ts
2020-05-10 16:45:06 +01:00
0ebdcc30ed Update numbering.ts 2020-05-07 11:49:42 +02:00
3eca81d3f5 Merge branch 'master' of github.com:dolanmiu/docx 2020-05-06 02:15:32 +01:00
faefbae3a1 Add Japanese example 2020-05-06 02:13:25 +01:00
370fb098ac Merge pull request #480 from dolanmiu/dependabot/npm_and_yarn/handlebars-4.5.3
Bump handlebars from 4.1.2 to 4.5.3
2020-05-06 01:58:10 +01:00
c73019d84c Merge branch 'master' of github.com:dolanmiu/docx 2020-04-23 11:51:38 +01:00
250a1de71e Disable e2e temporarily 2020-04-23 11:50:56 +01:00
012963e90a Merge pull request #527 from boopathikumar018/master
Enabled dark and light mode with switch for docs using docsify-darklight-theme with redesigned search bar
2020-04-20 01:22:08 +01:00
632f3cd19b Enabled dark and light mode with switch for docs using docsify-darklight-theme 2020-04-18 01:48:00 +05:30
1c8cd325d7 Add character styles demo 2020-02-27 11:10:00 +00:00
7bcdaab2f2 Updated Hyperlink demo
To test image followed up by hyperlink bug
2020-02-27 10:44:07 +00:00
5b58e520f9 Update CodePen and JSFiddle examples 2020-01-19 02:55:31 +00:00
78f6ea6c44 Update JSFiddle Demo 2020-01-19 02:50:31 +00:00
b5172e73f9 Package lock bump 2020-01-17 21:26:09 +00:00
5cf534ad26 Version bump 2020-01-16 03:04:38 +00:00
d53cdb0558 Merge branch 'master' of github.com:dolanmiu/docx 2020-01-16 02:41:12 +00:00
212adbbffb Add workaround for loading 2020-01-16 02:23:17 +00:00
99ab2f0ef5 Version bump package lock 2020-01-15 22:46:42 +00:00
a8201b2658 Update README.md 2020-01-15 22:33:04 +00:00
f13e676c3b Version bump 2020-01-11 20:52:59 +00:00
61b01836bc Merge pull request #490 from dolanmiu/feat/fix-exports
Add type and node type definition exports
2020-01-11 19:25:41 +00:00
2ee918b845 Add type and node type definition exports 2020-01-11 19:16:36 +00:00
e9579d75c4 Merge pull request #483 from dolanmiu/feat/right-indent
Version 5.0.0
2019-12-31 15:54:07 +00:00
97824f1bb5 Version 5.0.0 2019-12-31 15:52:01 +00:00
884c134b25 Merge pull request #482 from dolanmiu/feat/right-indent
Add new image for README
2019-12-31 15:51:12 +00:00
4f3cb49076 Add new image for README 2019-12-31 15:49:34 +00:00
152285ed5a Merge pull request #481 from dolanmiu/feat/right-indent
Bump up coverage stats
2019-12-27 01:54:09 +00:00
49b7ac212d Bump handlebars from 4.1.2 to 4.5.3
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.1.2...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-27 01:44:24 +00:00
83450e6277 Bump up coverage stats 2019-12-27 01:44:20 +00:00
6d6155c742 Merge pull request #478 from dolanmiu/feat/right-indent
Declarative bookmarks
2019-12-27 01:43:48 +00:00
f8da2c311b Merge branch 'master' of github.com:dolanmiu/docx into feat/right-indent 2019-12-27 01:37:37 +00:00
f6bcaef5b5 Fix test 2019-12-27 01:29:15 +00:00
1a9e71bfa1 Add children and section tests for File 2019-12-27 01:21:19 +00:00
3591e11637 Add hyperlink cache test 2019-12-24 16:31:35 +00:00
47533cf4e2 Bookmark tests 2019-12-24 03:39:55 +00:00
de03f19b46 Remove unused code and improve coverage 2019-12-24 00:44:15 +00:00
d1472368f6 Merge pull request #476 from mustapelto/empty-first-paragraph-fix
Fix for empty first paragraph
2019-12-21 04:21:50 +00:00
b83d2c388f Make Bookmark declarative 2019-12-21 03:59:40 +00:00
ee5425bef7 Add shortId type 2019-12-21 03:58:58 +00:00
3fdbca939e Make internal hyperlink declarative 2019-12-21 03:31:09 +00:00
c68dc8c52a Make hyperlinks declarative 2019-12-18 21:11:15 +00:00
96471ecb45 Fix for empty first paragraph
If there is only one section, remove the extraneous empty paragraph during XML creation.
2019-12-15 22:56:24 +02:00
a13f898ad3 Merge pull request #474 from kalda341/allow-contextual-spacing-paragraph-style
Allow contextual spacing to be specified as an argument to paragraph style
2019-12-13 23:22:39 +00:00
b4cce534a5 Test contextual spacing 2019-12-12 11:44:00 +13:00
e0698554ad Fix style linting error 2019-12-11 15:21:50 +13:00
1649d2a0fa Allow contextual spacing to be specified as an argument to paragraph style 2019-12-11 15:10:46 +13:00
9683e89159 Merge pull request #466 from dolanmiu/feat/right-indent
Make create footnote declarative
2019-12-04 01:41:01 +00:00
2bece0bb61 Make create footnote declarative 2019-12-03 23:04:48 +00:00
deb6c42d86 Merge pull request #465 from dolanmiu/feat/right-indent
Add right indent
2019-12-02 23:57:54 +00:00
2b0953bb19 Add right indent 2019-12-02 23:13:26 +00:00
d25d22508c Merge pull request #460 from dolanmiu/feat/table-alignment
Overlap option for tables
2019-11-24 03:35:26 +00:00
6db37eb4fb Overlap tables 2019-11-24 03:22:50 +00:00
af461f8418 Merge pull request #459 from dolanmiu/feat/table-alignment
Alignment of tables
2019-11-24 02:47:02 +00:00
8bdbd1de39 Alignment of tables 2019-11-24 01:22:17 +00:00
1bdc93ef59 Update numbering demo to add more numbering levels 2019-11-23 23:22:02 +00:00
c12101fbc6 Add decimal to numbering demo 2019-11-23 21:06:15 +00:00
d5ba6578b3 Merge pull request #458 from dolanmiu/feat/remove-tab-method
Make tab and page numbers declarative
2019-11-23 19:22:43 +00:00
b37aefdc8d Correctly exporting methods 2019-11-23 02:26:59 +00:00
0be7c26798 Add companies 2019-11-23 01:21:25 +00:00
bf1d10e893 Fix demos 2019-11-21 01:12:32 +00:00
7dfb016faa Make tab and page numbers declarative 2019-11-21 01:02:46 +00:00
b2aeb2d83c Merge pull request #454 from dolanmiu/feat/table-borders
Add table borders
2019-11-19 22:46:46 +00:00
8f4c78e2a8 Update package lock 2019-11-19 22:08:01 +00:00
bd1f5898a8 Add tests 2019-11-19 22:06:10 +00:00
05a4ef1702 Update package.json 2019-11-18 11:29:32 +00:00
da9e6d6664 Add table borders 2019-11-18 01:04:31 +00:00
e9d3853d93 Merge pull request #448 from Sraleik/master
fix hyperlink id
2019-11-12 00:48:21 +00:00
5a9d6120a5 Merge pull request #447 from dolanmiu/feat/declaritive-numbering
Declarative numbering
2019-11-08 10:53:25 +00:00
e8410ff692 fix lint 2019-11-08 11:22:27 +01:00
3427d220c7 fix hyperlink id 2019-11-08 11:01:26 +01:00
643e3c2f84 Finish making numbering declarative 2019-11-08 03:11:19 +00:00
9b40b5e55e Add work for custom level id 2019-11-06 20:54:39 +00:00
a622c210ef Progress on declaritive numbering 2019-11-04 20:19:09 +00:00
9495f30e2d Merge pull request #446 from dolanmiu/dependabot/npm_and_yarn/lodash-4.17.15
Bump lodash from 4.17.11 to 4.17.15
2019-11-04 01:48:59 +00:00
617af87065 Bump lodash from 4.17.11 to 4.17.15
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-02 15:07:36 +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
c1dd421b27 Merge pull request #443 from alex-bogomolov/master
Add ability to vertically align content of section
2019-11-01 02:43:12 +00:00
8eff6bd0cf Declarative numbering work 2019-11-01 01:57:01 +00:00
8566c64eab improve coverage 2019-10-31 17:01:17 +02:00
afd468277e refactor code 2019-10-31 13:54:53 +02:00
ca9c992237 Merge pull request #444 from mloar/master
Allow image reuse
2019-10-31 02:10:55 +00:00
c93b74661b Fix linting error 2019-10-30 08:59:29 -05:00
08ff092638 Allow image reuse 2019-10-29 21:44:04 -05:00
2276572902 add ability to vertically align content of section 2019-10-29 12:55:15 +02:00
43ddeec6e1 Create FUNDING.yml 2019-10-29 01:04:43 +00:00
9eaf04f4c7 Merge pull request #436 from zaunermax/master
Support footnotes on TextRun elements
2019-10-19 14:46:23 +01:00
c3c29bb119 fix(test): added unit test for TextRun 2019-10-18 14:09:33 +02:00
ddb34e6a46 feat(textRun): implemented footnote references on the text run element 2019-10-18 13:33:47 +02:00
ef3055430b Merge pull request #428 from dolanmiu/feat/webpack-export
Put docx in a seperate namespace in the browser version
2019-10-12 22:37:02 +01:00
75cdae1473 Put docx in a seperate namespace in the browser version rather than the global namespace 2019-10-12 22:16:36 +01:00
860afe8f28 Merge pull request #427 from dolanmiu/feat/package-lock
Add lock file
2019-10-12 21:53:07 +01:00
f685dbe0d1 Add lock file 2019-10-12 21:46:18 +01:00
50911fff57 Add color to example 2019-10-12 21:42:10 +01:00
a7064f4728 Merge pull request #424 from seiya-git/master
fix set table cell width
2019-10-12 20:11:30 +01:00
564e9600ea Merge pull request #426 from jamesmontalvo3/nyc14
Bump nyc from 13.1.0 to 14.1.1
2019-10-12 18:50:01 +01:00
fcc4202598 Bump nyc from 13.1.0 to 14.1.1 2019-10-12 00:42:54 -05:00
bfbe59cb84 table cell width test 2019-10-12 03:14:25 +03:00
06abde2425 fix set table cell width 2019-10-12 02:52:30 +03:00
75c3c2f985 Version bump 2019-10-10 21:27:27 +01:00
fefefdd473 Merge pull request #421 from dolanmiu/feat/declaritive-styles-and-tab-stop
Declaritive styles and  multiple tab stops
2019-10-10 21:26:30 +01:00
db59474f1e Remove unused method 2019-10-10 21:10:03 +01:00
1d5e806ff4 Add character style tests 2019-10-10 21:03:38 +01:00
bf4885c7cf Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive-styles-and-tab-stop 2019-10-10 01:58:13 +01:00
3b289be5ce Fix demo 2019-10-10 01:25:37 +01:00
2bb7e08ade Remove unnecessary method 2019-10-10 01:19:55 +01:00
b571a7550f Fix demo 2019-10-10 01:18:20 +01:00
721de30587 Fix demos 2019-10-10 01:08:01 +01:00
f16126e948 Fix tests 2019-10-09 21:19:41 +01:00
40d1a3a7c2 Multiple tab stops 2019-10-09 20:56:31 +01:00
0d4c7a5fc0 Update documentation 2019-10-09 02:03:39 +01:00
5d401dfb27 Merge pull request #419 from jamesmontalvo3/section-fix
Revert "fix: try to remove unnecessary paragraph", which caused #418
2019-10-05 14:16:06 +01:00
a37c9d8f2f Revert "fix: try to remove unnecessary paragraph", which caused #418
This reverts commit cb74868247.
2019-10-03 22:12:23 -05:00
10ab3c70bf Add back default styles 2019-10-04 02:37:22 +01:00
591b2f4e04 Declarative styles 2019-10-04 01:20:41 +01:00
2536fbe752 Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive-styles-and-tab-stop
# Conflicts:
#	src/file/paragraph/paragraph.ts
2019-10-03 20:48:34 +01:00
33549d5ec3 Merge pull request #413 from jamesmontalvo3/master
Add SymbolRun to allow adding symbols inline
2019-10-02 21:41:24 +01:00
720c6172e3 Merge pull request #415 from jamesmontalvo3/export-run-fonts
Export RunFonts to be able to pass to Level.addRunProperty()
2019-10-02 21:40:40 +01:00
bbad2f5cde Merge pull request #416 from kalda341/fix-toc-t-flag
Fix table of contents \t flag
2019-10-02 21:27:21 +01:00
d2a0baa221 Fix table of contents \t flag 2019-10-02 14:49:55 +13:00
ad62f5459b Export RunFonts to be able to pass to Level.addRunProperty() 2019-10-01 15:23:01 -05:00
dfb910defb Add SymbolRun to allow adding symbols inline 2019-10-01 12:29:07 -05:00
04b6d8e54a Declarative hyperlinks, bookmarks, tab stops and page breaks 2019-09-30 22:56:21 +01:00
d2dded860d Fix example links 2019-09-30 20:58:18 +01:00
38f2638ea0 Version bump 2019-09-29 04:45:30 +01:00
2b874e3f69 Merge pull request #407 from dolanmiu/feat/declaritive-tables
Feat/declarative tables
2019-09-29 04:43:37 +01:00
b43ed12c84 Fix tests 2019-09-29 04:38:07 +01:00
59be381213 Update travis config 2019-09-29 04:25:40 +01:00
172c333357 Add tests and clean up code 2019-09-29 04:17:21 +01:00
c5eb3d5670 Add addMargin test 2019-09-26 02:24:43 +01:00
44b95f2f15 Add shading test 2019-09-26 02:14:52 +01:00
bd888219fc Amend table documentation 2019-09-26 02:03:17 +01:00
2842619196 Update table documentation 2019-09-25 01:59:30 +01:00
b2de74a0e6 Fix tests 2019-09-25 01:09:53 +01:00
7aa4134e2b Refactor row merging to table level 2019-09-25 00:57:24 +01:00
cc36ea7542 Optimise formatting to not over-format the same files 2019-09-22 20:45:24 +01:00
c11af71ed7 Add test such that it only should call prep once 2019-09-22 19:09:34 +01:00
a9d4ebc898 Add declarative column merge 2019-09-22 02:39:38 +01:00
d2f82052b4 Improve documentation 2019-09-19 22:49:09 +01:00
f88a309d55 Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive-tables 2019-09-13 00:52:26 +01:00
418adca9f3 Declarative tables 2019-09-13 00:51:20 +01:00
993f8f81f7 Merge pull request #392 from wainstead/parameter-fix
Fix: probable copy/paste error
2019-09-01 16:19:03 +01:00
99718784f1 Fix: probable copy/paste error
Fix the argument to "left:" which should likely be 2160
2019-08-30 09:29:45 -04:00
59fc1ed632 Merge pull request #391 from bokuweb/remove-extra-line
fix: try to remove unnecessary paragraph
2019-08-29 20:34:32 +01:00
cb74868247 fix: try to remove unnecessary paragraph 2019-08-29 20:52:05 +09:00
bd6ae2c0dc Remove unnecessary documentation 2019-08-22 22:49:57 +01:00
60a599a550 Improve bullet points documentation 2019-08-22 00:28:42 +01:00
4ac55a787e Fix includes 2019-08-21 00:53:49 +01:00
cb52a1ef42 Formatting 2019-08-21 00:51:26 +01:00
7827d158d7 Updated documentation 2019-08-21 00:05:46 +01:00
535f2d75b0 Fix embed links in documentation 2019-08-20 22:23:14 +01:00
4f8d435e16 Add Math Summation 2019-08-20 20:40:40 +01:00
5ecdb48d43 Stop unnecessary casting 2019-08-15 00:48:36 +01:00
a1b9be453b Add math run and fraction 2019-08-15 00:47:55 +01:00
2502fe7f39 Increase thresholds 2019-08-14 15:50:12 +01:00
02487fbb22 Merge pull request #376 from mforman1/Numbering
Add total number of pages in a section
2019-08-14 13:29:35 +01:00
2abff6991f Rename demo 2019-08-14 14:13:28 +03:00
49e85275c3 Fix tests 2019-08-13 10:53:29 +03:00
96efdf8b1a Merge branch 'master' of github.com:dolanmiu/docx into Numbering
# Conflicts:
#	src/file/paragraph/run/run.ts
2019-08-13 10:40:49 +03:00
b52a4adaff Merge pull request #375 from fpirsch/fpirsch-compression
Enable zip compression
2019-08-09 11:17:22 +01:00
a9fc40dad4 Add total number of pages in a section 2019-08-09 11:56:22 +03:00
b609a17362 Update packer.ts 2019-08-09 09:41:58 +02:00
4b49fdbf8e Update packer.ts 2019-08-09 00:19:44 +01:00
fd52c8cf47 Enable zip compression 2019-08-08 16:40:16 +02:00
a54c2714db Version bump 2019-08-08 02:01:22 +01:00
ad4a843a1e Update README.md 2019-08-08 01:56:31 +01:00
183062a977 Update README.md 2019-08-08 01:55:48 +01:00
e685da8cc2 Add more Used by logos 2019-08-08 01:52:20 +01:00
eea38a6709 Merge pull request #373 from dolanmiu/feat/declaritive
Static Packer
2019-08-08 01:06:00 +01:00
9fdd07e7fe Fix tests 2019-08-07 22:27:44 +01:00
d8b60d82f3 Turn Packer static 2019-08-07 22:12:14 +01:00
629e6a5095 Merge pull request #336 from dolanmiu/feat/declaritive
New declaritive API
2019-08-06 23:34:40 +01:00
65c5177daf Fix demo paths 2019-08-06 23:28:12 +01:00
b741db3050 Using a better demo naming system 2019-08-06 23:08:21 +01:00
82fef4c2b1 Fix tests 2019-08-06 22:27:16 +01:00
e45e7ffe06 Consolidate highlight and shadow API 2019-08-06 21:37:33 +01:00
099eb1d202 Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive
# Conflicts:
#	src/file/paragraph/run/run.ts
2019-08-06 21:06:06 +01:00
9da9f31c77 Change text documentation 2019-08-06 18:27:00 +01:00
820e5edc1e Using const rather than var and let, and using ts rather than js examples 2019-08-06 17:51:13 +01:00
0f1f398e6d Amended images documentation 2019-08-06 17:48:07 +01:00
b5503e7b9b Add documentation for AlignmentType 2019-08-06 17:36:05 +01:00
5a005365b2 Add more documentation 2019-08-06 17:15:45 +01:00
2a5e3729e0 Merge pull request #371 from mforman1/Highlighting
Add Highlight and Shading to the properties
2019-08-06 12:47:34 +01:00
ebc7dca949 Fix tests 2019-08-06 13:39:05 +03:00
fa710d1ba6 Highlighting 2019-08-06 11:13:43 +03:00
4b19131dbd Add description about sections 2019-08-06 00:52:50 +01:00
cb699e17b3 Paragraph documentation 2019-08-05 23:24:43 +01:00
c2c05b0140 Adding some documentation 2019-08-03 13:42:24 +01:00
3263984f03 Merge pull request #370 from wainstead/master
Removed artifact left over from (likely) the patch program
2019-08-03 13:41:38 +01:00
6f6f1e249c Removed artifact left over from (likely) the patch program 2019-08-01 11:12:07 -04:00
6380b2d8f3 Merge pull request #363 from moritz-tr/fix/create-document-from-template
fix: docx generation from template
2019-08-01 14:26:41 +01:00
9938a8bcc0 Fix linting 2019-07-31 08:48:25 +01:00
ac5b15d0e3 Mandatory Sections 2019-07-31 08:48:02 +01:00
ec5a678f05 fix: multiple def of header/footer attributes 2019-07-22 17:36:13 +02:00
bf80311ef7 Add new section method 2019-07-07 20:23:42 +01:00
58346a8937 Section WIP 2019-07-07 03:54:29 +01:00
f33d6da65a Merge branch 'master' into feat/declaritive
# Conflicts:
#	src/file/paragraph/formatting/border.spec.ts
#	src/file/paragraph/links/outline-level.spec.ts
#	src/file/paragraph/run/run.spec.ts
2019-07-02 01:33:41 +01:00
9e8d67c4a9 Version bump 2019-06-28 01:59:18 +01:00
cbbc4a80e7 FIx up API for column count 2019-06-28 01:57:43 +01:00
1f51fd7a31 Remove usage of Utility 2019-06-27 01:35:58 +01:00
120d97bc64 Remove Utility 2019-06-27 01:10:39 +01:00
a531713214 Remove usage of Utility class 2019-06-26 22:12:18 +01:00
564a055316 Remove jsonify method 2019-06-26 02:11:43 +01:00
6c29c4fb1f Merge pull request #343 from markcharyk/no-pretty-xml
Make prettified XML a Packer-wide configurable option
2019-06-26 00:44:33 +01:00
edbb4ce9f2 Merge branch 'master' into feat/declaritive 2019-06-26 00:38:21 +01:00
e2574ec23b Turn methods into "add()" 2019-06-25 23:17:56 +01:00
3ef8f5311d Make fixed layout declaritive 2019-06-25 20:57:46 +01:00
552580bc47 Merge pull request #340 from filippomuscolino/feat/row-height
Add table row height
2019-06-25 20:18:17 +01:00
0998d43b8f Merge pull request #341 from filippomuscolino/fix/missing-exports
Fix: add missing exports
2019-06-25 15:38:13 +01:00
b08354494c Improve tests 2019-06-25 14:48:45 +02:00
f54b9a197d Fix: add missing exports 2019-06-25 14:35:35 +02:00
2d4412ce51 Add table row height 2019-06-25 12:02:53 +02:00
b566b0f765 Simplify multiple addXXX methods into a single add method for Footer 2019-06-25 01:58:09 +01:00
384d144a85 Simplify multiple addXXX methods into a single add method 2019-06-25 01:52:02 +01:00
c97d15cb9f Remove create table helper function 2019-06-25 01:21:28 +01:00
dfe986331d Make media return a picture run instead 2019-06-23 22:36:01 +01:00
72c32378c5 Make prettified XML a Packer-wide configurable option
The xml() function was being passed a flag for pretty printing the XML in word/document.xml. This was causing some parsers (not Word itself) to break when they didn't expect whitepsace. It was also causing some files to be prettified and others to be ugly. This ensures consistent prettification.
2019-06-21 13:53:01 -07:00
0c79c0ac83 Merge pull request #337 from zahrafali/multiple-columns
Multiple columns in a section
2019-06-21 15:36:33 +01:00
1dfc27ba08 Multiple columns in a section 2019-06-21 01:22:27 +05:30
427dc86915 Fix demos 2019-06-17 01:54:48 +01:00
7bc00926eb Merge branch 'master' of github.com:dolanmiu/docx into feat/declaritive 2019-06-17 01:52:46 +01:00
fb65bb4207 Turn Run into a declaritive API 2019-06-17 01:51:57 +01:00
a1cd5e9573 Use new Paragraph API 2019-06-13 22:36:42 +01:00
5497dabaf9 Deprecate createParagraph in all demos 2019-06-13 01:07:00 +01:00
58dc6fe389 Format demo 2019-06-12 01:12:32 +01:00
34c3285426 Version bump 2019-06-12 01:07:53 +01:00
cb42c74a8d Make Paragraph declaritive 2019-06-12 01:03:36 +01:00
a5afce458d Merge pull request #262 from aravindballa/master
Feature: add line numbers to section
2019-06-05 17:38:49 +01:00
2f687125d1 fix lint issue in section-properties.ts 2019-06-05 13:01:24 +05:30
5c1a731314 Version bump 2019-05-16 22:15:50 +01:00
622331ad24 Merge pull request #324 from Scarface2013/master
Fix merging of 3+ cells vertically
2019-05-16 21:06:20 +01:00
3a593a53d3 Fix tests 2019-05-16 11:15:20 -04:00
31a9111667 Fix merging of 3+ cells vertically 2019-05-15 18:14:39 -04:00
373c890354 Add docsify serve 2019-04-30 00:30:18 +01:00
723d76d06f Merge pull request #314 from efx/fix-doc-links
fix broken documentation links
2019-04-29 12:08:27 +01:00
a24d745d75 fix broken documentation links 2019-04-25 09:49:44 -04:00
90891cfafd Merge pull request #310 from nickgeorgiou/feat/margin-spelling-fix
Fix spelling of "margin"
2019-04-18 17:10:00 +01:00
29f890918c Fix spelling of "margin" 2019-04-18 13:55:18 +10:00
b0f8f8ddbd Merge pull request #308 from filippomuscolino/master
Update documentation
2019-04-12 14:43:32 +01:00
9c89c1ab59 Update docs 2019-04-12 13:46:05 +02:00
7a9cb92955 Merge pull request #307 from brucehappy/features/xml_optimization
Optimize XML output
2019-04-11 22:50:10 +01:00
77edf8862b Added constant EMPTY_OBJECT (an empty sealed object) that is used to indicate to the xml library that an empty XML element should be generated, and use it in the JSON hardcoded into the tests. 2019-04-10 13:47:38 -04:00
bb1604cd8f Turn back on no-null-keyword. Use empty object instead of null to signal to the xml library that an empty element should be produced. Update the related tests.
Related to #306
2019-04-10 01:28:37 -04:00
816cb54b14 Optimize XML output by properly constructing objects to send to the xml library so that it can produce proper empty elements.
Rework the way attributes are stored in ImportedXmlComponent to match elsewhere (required allowing for a null xmlKeys in the XmlAttributeComponent interface).
Rework the way paragraphs get added to the end of table cells if needed.
The goal in both reworks is to not mess around with the objects output from `prepForXml` if we can avoid it.
Made the output of RunProperties, ParagraphProperties, TableCellProperties, TableRowProperties, and TableProperties all optional based on whether they contain any attributes or children.  Changed code in PageBorders, TableCellMargin, and TableCellBorders that implemented this same thing by overriding `prepForXml` so that it uses the new XmlComponent subclass instead.
Removed commented out code that attempted to fix-up XML output and make proper empty elements.
Fixed all affected tests.
Turn off `no-null-keyword` in the linter as we need to use null to signal to the `xml` library to create an empty element with no attributes (`undefined` will not work in its place).

Fixes #306
2019-04-09 05:27:18 -04:00
920bd3c175 Merge pull request #304 from brucehappy/issues/issue_303
Fix table cell margin type XML attribute
2019-04-08 20:30:54 +01:00
a2a01edc24 Change table cell margin type attribute form w:sz to w:type as per http://officeopenxml.com/WPtableCellMargins.php
Fixes #303
2019-04-08 13:50:40 -04:00
193d0c4239 Merge pull request #299 from filippomuscolino/fix-duplicated-section
Fix: duplicated generation of last section properties
2019-04-05 01:07:10 +01:00
d8cc11c5ab Merge pull request #300 from efx/fix-typo
fix minor typos
2019-04-05 01:03:39 +01:00
b874051f32 fix minor typos 2019-04-04 15:35:41 -04:00
272e2496f4 Fix duplicated generation of last section properties 2019-04-04 17:43:54 +02:00
43c199c725 Version bump 2019-03-30 15:45:12 +00:00
0e975b3d66 Merge pull request #292 from dolanmiu/feature/table-background
Add shading (background color) for cell
2019-03-21 01:33:11 +00:00
c6ab47e838 Add shading 2019-03-21 01:06:07 +00:00
48c17d51bb Merge pull request #288 from dolanmiu/feat/table
Add margains, widths and floats to tables
2019-03-19 00:19:55 +00:00
df2315ae4a Disable e2e for demo 32 temporarily 2019-03-19 00:07:11 +00:00
e67fd9cb2b Add tests and margain 2019-03-18 23:50:21 +00:00
639842332f Change contribution guidelines 2019-03-13 23:13:10 +00:00
2cb7d44a77 Work on new table API 2019-03-13 02:29:11 +00:00
6cd62418a5 Update README.md 2019-03-12 20:26:39 +00:00
f3ba11b21c Improving table api 2019-03-08 01:09:21 +00:00
51b1e08a35 Merge pull request #284 from askoufis/numbering-docs-typo
Fixes typo in numbering documentation
2019-03-07 17:08:33 +00:00
b0d0041ff9 Rewording and remove # 2019-03-07 15:36:06 +11:00
55c5dd818a More typos 2019-03-07 15:33:32 +11:00
3bebe0ad59 Found another typo 2019-03-07 15:32:16 +11:00
c5c67fd92a Fixes typo in numbering documentation 2019-03-07 15:28:30 +11:00
1486d3de56 Improve documentation 2019-03-07 01:01:01 +00:00
6d8eea40be Merge branch 'master' of github.com:dolanmiu/docx 2019-03-06 22:53:23 +00:00
0922d49cd3 Merge pull request #282 from filippomuscolino/fix/table-width
Fix: table width in percentage should include '%'
2019-03-06 13:52:49 +00:00
f76471f553 Fix test 2019-03-06 13:33:50 +01:00
973177676e fix: table width in percentage should include '%' 2019-03-06 12:21:15 +01:00
5aa878b901 Fix invalid link 2019-03-06 02:12:41 +00:00
b99d1fc129 correctly use include 2019-03-06 00:18:00 +00:00
1590f9ac70 Merge pull request #274 from dolanmiu/feat/vertical-table-merge
Add table column and vertical merging
2019-03-05 23:53:12 +00:00
6c772b956c Add examples to table documentation 2019-03-05 23:15:50 +00:00
9d09ff3518 Update documentation 2019-03-05 21:57:31 +00:00
d9ad69b7cd Merge pull request #278 from filippomuscolino/feat/style-improvements
Add bold and italics to character style + customize hyperlink
2019-03-05 20:59:21 +00:00
e23d230acb Merge pull request #280 from filippomuscolino/feat/justify-line-break
Add setting for not justify lines ending in soft line break
2019-03-05 20:55:21 +00:00
5ca872cb07 Merge pull request #279 from filippomuscolino/settings-fix
Fix: settings are ignored by Word without relationship and content type
2019-03-05 17:44:21 +00:00
b179facca2 Add setting for not justify lines ending in soft line break 2019-03-05 17:17:06 +01:00
db60270e1f fix: relationship and content type for settings 2019-03-05 15:40:00 +01:00
3e2130bc80 Customize text run of an hyperlink 2019-03-05 15:15:58 +01:00
1b336785b4 Add bold and italics to character style 2019-03-05 15:15:45 +01:00
6eed0fe0f5 Update contribution-guidelines.md 2019-03-05 13:32:09 +00:00
2f8f69b0c4 Update README.md 2019-03-05 13:29:36 +00:00
4580a65a84 Merge pull request #277 from filippomuscolino/feat/style-outline
Select styles that will go into TOC
2019-03-05 13:22:22 +00:00
661c3e21e4 Merge pull request #275 from filippomuscolino/feat/table-pagination
Table pagination: add cantSplit and tblHeader row properties
2019-03-05 11:24:08 +00:00
32646f8806 Add outline level to paragraph style 2019-03-05 12:19:36 +01:00
231428852e Merge pull request #276 from filippomuscolino/feat/cell-properties
Cell borders on Google Docs + set cell width
2019-03-05 11:19:29 +00:00
46ddf77342 Get cell properties 2019-03-05 11:38:21 +01:00
441afe8c97 Add tests 2019-03-05 11:34:43 +01:00
ca9ce01f56 Customize left and right cell borders (for Google Docs) 2019-03-05 11:09:47 +01:00
2b9ce0febd Add tests 2019-03-05 11:04:54 +01:00
18760387db Table pagination: add cantSplit and tblHeader row properties 2019-03-05 10:13:53 +01:00
28dabb06cb Write getColumn test 2019-03-05 01:58:56 +00:00
50fc9b6274 Test index out of bounds 2019-03-05 01:45:04 +00:00
367518d504 Add tests for table column 2019-03-05 01:39:51 +00:00
efd89f24e6 Add table column and vertical merging 2019-03-04 22:50:04 +00:00
4fd2b6f1d3 Merge branch 'feat/table-merge-fix' 2019-02-26 22:32:21 +00:00
5ae541a40d Fix descriptions of demos 2019-02-26 22:20:20 +00:00
c9fb9a827d Version bump 2019-02-26 21:54:33 +00:00
918faf59c3 Merge pull request #273 from dolanmiu/feat/table-merge-fix
Add higher width for GridCol to fix merging cells
2019-02-26 21:53:14 +00:00
3a9fa49fbb Fix test 2019-02-26 21:46:19 +00:00
218a08d793 Fix tests 2019-02-26 21:45:55 +00:00
416a239708 Add higher width for grid col to fix merging 2019-02-26 21:38:54 +00:00
d1bdbd397a Merge pull request #265 from joefitter/bugfix/conditional-coverage
dont run coverage if publishing
2019-02-09 17:43:43 +00:00
a6077b8f16 dont run coverage if publishing 2019-02-08 12:06:50 +00:00
8f133ff93a add example for line numbers 2019-02-06 13:26:18 +05:30
1f12e159ef add line numbers to section 2019-02-04 18:49:12 +05:30
83a7f4664d Update tslint.json 2019-01-28 13:04:51 +00:00
728aefc4a7 Merge pull request #256 from dolanmiu/feat/webpack-ts
Use a typescript webpack config
2019-01-24 01:16:08 +01:00
40730548bb Add webpack type definitions 2019-01-23 20:09:32 +00:00
d6c2c96757 Merge pull request #248 from filippomuscolino/master
Add OutlineLevel Paragraph property
2019-01-17 01:21:55 +01:00
b22f565dd0 Use a typescript webpack config 2019-01-16 13:34:32 +00:00
41eeac1b05 Update README.md 2019-01-16 13:26:26 +00:00
18a5f22f4c Version bump 2019-01-16 12:05:21 +01:00
2a1161d857 Add documentation 2019-01-16 12:05:21 +01:00
4b6d3c3e3c Write tests 2019-01-16 12:05:21 +01:00
14a1d62148 Add Number of pages element 2019-01-16 12:05:21 +01:00
1f98d9461b Merge pull request #250 from dolanmiu/feat/number-of-pages
Feat/number of pages
2019-01-16 01:18:11 +01:00
8dc590746b Version bump 2019-01-16 00:15:27 +00:00
de5f5c9a77 Add documentation 2019-01-16 00:13:18 +00:00
788205b14d Merge pull request #247 from dolanmiu/feat/number-of-pages
Add Total Number of pages element
2019-01-15 22:47:51 +01:00
ca5f6a56a5 Write tests 2019-01-15 21:40:19 +00:00
bf8dfe6604 Fix for prettier 2019-01-15 16:13:20 +01:00
b0ee0305fb Add OutlineLevel Paragraph property 2019-01-15 15:39:48 +01:00
8f6984580a Add Number of pages element 2019-01-15 02:09:38 +00:00
383c6d769f Merge pull request #246 from dolanmiu/feat/e2e-2
Add new e2e command
2019-01-15 02:17:21 +01:00
9f38a4f48a Test 32 instead of 30 2019-01-15 01:04:53 +00:00
475a132ce0 Fix e2e test 2019-01-15 00:50:38 +00:00
4111413074 Add relative pathing 2019-01-15 00:43:48 +00:00
50209bb435 Add Error for e2e test 2019-01-15 00:34:40 +00:00
b37d2c141d Add new e2e command 2019-01-15 00:23:01 +00:00
d19cdcae0c Rename methods 2019-01-11 01:45:57 +00:00
3f652764e9 Merge pull request #234 from dolanmiu/feat/improve-docs
Make ImportDotx easier to read
2019-01-11 01:15:42 +00:00
7b5cf690e2 Merge pull request #242 from dolanmiu/feat/more-tests2
Add more tests to paragraph
2019-01-11 00:29:45 +00:00
d674523139 Fix tests - No longer uses dummy variable 2019-01-11 00:26:16 +00:00
db7f27a88c Add more tests to paragraph 2019-01-11 00:16:25 +00:00
677300e34f Merge pull request #237 from dolanmiu/feat/image-wrap
Merge 4.6.0 into master
2019-01-10 23:53:00 +00:00
da0fa86345 Version bump 2019-01-10 02:37:40 +00:00
78b310e1dd Add Add createFirstPageFooter and createEvenPageFooter 2019-01-10 02:36:42 +00:00
4541d7c977 Text wrapping and borders for images 2019-01-10 02:10:20 +00:00
9271b2d11a Merge pull request #235 from dolanmiu/feat/floating-images
Feat/floating images
2019-01-09 21:33:52 +00:00
942c6d028c Remove unessesary null check
Trust the compiler and code
2019-01-09 21:19:57 +00:00
f717126145 Remove image-size dependency 2019-01-09 02:08:47 +00:00
abd5ace85c Merge branch 'master' of https://github.com/dolanmiu/docx into feat/floating-images
# Conflicts:
#	src/file/drawing/drawing.ts
2019-01-09 02:04:06 +00:00
a37ff90bd7 Version bump 2019-01-09 01:53:12 +00:00
9998ddfcc9 Add createEvenPageHeader method 2019-01-09 01:52:20 +00:00
12ed54c9fd Add floating image support and documentation 2019-01-09 01:16:47 +00:00
612c024b1f Use string style factory 2019-01-07 21:43:04 +00:00
12ad545fe8 Write ImportDotx more functionally 2019-01-07 21:41:39 +00:00
6d0f6a61d7 Merge pull request #231 from Vivekananda-Athukuri/master
Export Num class
2019-01-04 12:06:14 +00:00
e3bcad6d3c Fix missing media in Document Template 2019-01-04 00:11:50 +00:00
f7c372a85c Merge branch 'master' into feat/improve-docs 2019-01-03 20:56:05 +00:00
bb277a4a76 Format demo 2019-01-03 20:47:00 +00:00
52b78a583e Merge pull request #202 from dolanmiu/feat/correct-mine-type
Remove async await for Compiler.compile
2019-01-03 10:45:56 +00:00
20ab36191b Merge pull request #228 from dolanmiu/feat/improve-docs
Change table methods and document it
2019-01-03 02:43:16 +00:00
dbfb80e660 Add more tests 2019-01-03 02:36:56 +00:00
421f4471de Merge branch 'master' into feat/improve-docs
# Conflicts:
#	src/file/footer-wrapper.spec.ts
2019-01-03 02:12:05 +00:00
04ea2b2dc9 Add footer tests and improve table documentation 2019-01-03 02:11:04 +00:00
93a2404343 Merge pull request #229 from microbit-matt-hillsdon/get-started-packer-fix
Fix getting started docs for v4 packer.
2019-01-02 16:15:41 +00:00
149cda9a3b Fix getting started docs for v4 packer. 2019-01-02 15:56:13 +00:00
b9465b2a20 Add more changes to table API and documentation 2018-12-31 01:55:15 +00:00
ab07f2ecbe Change table methods and document it 2018-12-29 01:57:20 +00:00
c70c147afe Merge pull request #217 from dolanmiu/feat/fix-header-image-bug
Feat/fix header image bug
2018-12-28 15:19:44 +00:00
8db52212ab Remove id from media 2018-12-24 16:50:53 +00:00
d021a3995e Sending media data down image 2018-12-21 01:39:20 +00:00
1ea347ed21 Clean up 2018-12-18 23:37:21 +00:00
0725e54271 Add tests 2018-12-16 01:56:42 +00:00
3b6aca2451 Merge pull request #220 from efx/topic-docs
add documentation on positioning units
2018-12-12 00:17:55 +00:00
249e44532f add documentation on positioning units
See further discussions in #50, #191.
2018-12-11 16:49:18 -05:00
d3af3663ec Merge branch 'release/4.4.1' 2018-12-10 19:33:00 +00:00
3a1a21e498 Version bump 2018-12-10 19:27:51 +00:00
e5bfa99b92 Add correct docx mime type 2018-12-10 19:22:23 +00:00
bf18154fcf Fix style 2018-12-07 15:34:27 +00:00
5efc9e383b Update index.html 2018-12-06 14:30:24 +00:00
6505119d3b Merge pull request #205 from dolanmiu/refactor/style-refactor
Refactor in Style
2018-12-05 21:09:30 +00:00
600f97de29 Update README.md 2018-12-05 20:11:46 +00:00
a1c21d2143 Add space 2018-12-05 19:47:56 +00:00
39066fb5f2 Add lifecycles to add image 2018-12-05 00:05:11 +00:00
8fd99052fb Merge pull request #207 from dolanmiu/feat/rename-italic
Breaking change. Make all italic to italics.
2018-11-18 15:47:35 +00:00
4e671eb512 Breaking change. Make all italic to italics. 2018-11-18 15:22:23 +00:00
2677c4a4ec Merge pull request #206 from dolanmiu/feat/refactor-setwidth
Breaking Change. Swap arguments around and make default WidthType
2018-11-15 03:08:00 +00:00
e19890e27a Breaking Change. Swap arguments around and make default WidthType 2018-11-15 03:00:26 +00:00
28556f277b Update contribution-guidelines.md 2018-11-13 14:38:26 +00:00
50e08f198c Linter ajusts 2018-11-13 11:04:29 -02:00
7639b60b15 Refactor to separate classes in their specific files an tests improuvements for styles 2018-11-13 11:04:03 -02:00
765a9686d8 Remove async await for Compiler.compile 2018-11-12 13:17:53 +00:00
ff443aa7c4 Merge pull request #201 from dolanmiu/feat/correct-mine-type
Add correct docx mime type
2018-11-12 13:12:54 +00:00
28fc328cb3 Add more packer tests 2018-11-12 13:03:17 +00:00
083f121683 Add correct docx mime type 2018-11-12 12:32:07 +00:00
2f57d3be84 Merge pull request #197 from dolanmiu/bugfix/correct-section-page-num-type
Bugfix - Correct default section options
2018-11-11 23:05:20 +00:00
7b47dadede Fix Prettier styling 2018-11-11 22:54:35 +00:00
8ad5485347 Improuvments in headers and footers docs 2018-11-09 10:37:36 -02:00
8df78e45d9 Update in examples documentation. 2018-11-09 09:26:27 -02:00
39cef5e61d Demo 16 was updated to show how page number types format and start work. 2018-11-09 09:14:38 -02:00
5552f9d834 The page number type attribute of the sections was always been created, leading Word to always reset page numbers to zero in new sections.
The page number type DECIMAL is already the default in Word, there is no need to force this to be the default option in the default section, like it was.
2018-11-09 09:13:27 -02:00
d13795696d Update index.ts 2018-11-09 12:26:23 +05:30
f640f17fa6 Merge pull request #193 from dolanmiu/4.4.0
Version bump
2018-11-08 12:05:31 +00:00
494a32d45d Merge pull request #195 from kunizial/patch-1
Update numbering.md
2018-11-08 12:05:17 +00:00
8040a455be Update numbering.md
Fixed Typo
2018-11-08 11:09:09 +01:00
f091cff7c9 Version bump 2018-11-07 01:06:59 +00:00
401ef7336b Merge pull request #190 from dolanmiu/feat/more-tests
Introduce some functional programming techniques
2018-11-02 03:12:28 +00:00
18134519be Edit threshold 2018-11-02 03:00:07 +00:00
7980f14efb Introduce some functional programming techniques 2018-11-02 02:51:57 +00:00
40d6a41305 Merge pull request #189 from dolanmiu/feat/more-tests
More tests
2018-11-02 00:53:54 +00:00
9cfd835171 More tests 2018-11-02 00:42:49 +00:00
95a9f592eb Merge pull request #143 from amitm02/importDotx
use .dotx files as an initial template for a new (document) file
2018-11-01 02:31:33 +00:00
61411fd0f3 Add tests 2018-11-01 02:22:32 +00:00
a84eb16392 Merge branch 'master' into importDotx
# Conflicts:
#	src/import-dotx/import-dotx.ts
2018-10-31 22:09:36 +00:00
3355a6f472 Added back tests and method 2018-10-31 21:57:10 +00:00
071a8ea9f7 Merge pull request #187 from dolanmiu/feat/clean-imports
Feat/clean imports
2018-10-26 21:00:42 +01:00
ea3777d28b Better naming 2018-10-26 20:30:42 +01:00
3346b97ee7 Clean up 2018-10-26 20:23:26 +01:00
2b834a75a8 Add codecov badge 2018-10-26 20:22:33 +01:00
21df53d547 Clean up 2018-10-26 20:16:18 +01:00
9143c1c2c1 Add nyc support 2018-10-26 20:11:40 +01:00
83cab7563d Add nyc to travis 2018-10-26 02:20:10 +01:00
b05fbe7f6e Merge pull request #185 from dolanmiu/feat/clean-imports
Add codecov and add more tests to travis
2018-10-26 02:12:52 +01:00
e6a57738f4 Demo 25 does not exist 2018-10-26 02:07:25 +01:00
cc6e35165a Add codecov and add more tests to travis 2018-10-26 02:00:45 +01:00
7791ddf76e Merge pull request #184 from dolanmiu/feat/clean-imports
Clean imports
2018-10-26 01:16:23 +01:00
4742cf0f3f Clean imports 2018-10-26 01:04:07 +01:00
8858970491 Merge pull request #182 from dolanmiu/feat/table-clean-up
Tidied up table components
2018-10-24 14:33:10 +01:00
f7d18bfead Tidied up table components 2018-10-23 23:44:50 +01:00
0ce1b7fa15 Merge pull request #181 from dolanmiu/feat/float-table
Created float positioning for tables
2018-10-23 21:40:33 +01:00
4633592711 Improve API 2018-10-23 20:03:29 +01:00
54697ab6b1 Created float positioning for tables 2018-10-23 09:08:43 -02:00
1eed844b9a Merge pull request #179 from dolanmiu/feat/import-dotx
Feat/import dotx
2018-10-23 00:47:18 +01:00
dd89fe2463 Fix casing 2018-10-23 00:41:18 +01:00
9c66db97ff Use single media instead of multiple 2018-10-23 00:31:51 +01:00
fea6afdfe4 Remove npm dependency 2018-10-22 20:27:32 +01:00
6ec2e742ef Merge branch 'master' into importDotx 2018-10-22 20:25:34 +01:00
3f80b054fc Merge pull request #178 from dolanmiu/bugfix/correct-toc-instruction
changed comma by semicolon to work in Word 2016.
2018-10-22 03:37:54 +01:00
96d81873d8 forgot to fix the test 2018-10-21 19:56:31 -02:00
c429ae9920 changed comma by semicolon to work in Word 2016. 2018-10-21 19:37:37 -02:00
6b4e769f48 Merge branch 'master' of https://github.com/dolanmiu/docx 2018-10-21 05:16:32 +01:00
b67a9de0e9 Angular README example 2018-10-21 05:14:14 +01:00
ac9f65a068 Merge pull request #177 from dolanmiu/feat/guidelines
Contribution guidelines improve
2018-10-21 04:51:45 +01:00
7e8ebb2af2 Contribution guidelines improve 2018-10-21 04:50:57 +01:00
f53fe2f881 Merge pull request #175 from dolanmiu/feat/sequential-field
Created classes and methods needed to create Sequential Identifiers
2018-10-21 02:00:20 +01:00
6fdd88527a Merge pull request #176 from dolanmiu/bugfix/correct-toc-instruction
fixed TOC instruction that was missing quotes for some switches
2018-10-20 17:36:44 +01:00
b6f431e14d fixed TOC instruction that was missing quotes for some switches 2018-10-20 09:17:37 -03:00
23dee01f06 Created classes and methods needed to create Sequential Identifiers 2018-10-19 16:50:51 -03:00
5532f91423 Merge branch 'importxmljs' into importDotx 2018-10-17 09:17:42 +03:00
c849d5f3e5 fix demp30 2018-10-17 09:16:55 +03:00
3f3fd05cb1 works 2018-10-17 09:15:32 +03:00
a5bedf9a5b Add break after cases in switch 2018-10-17 01:40:17 +01:00
9d9dd62f00 c 2018-10-16 11:28:25 +03:00
a466578467 Version bump 2018-10-15 23:34:35 +01:00
3a9420fedf Merge pull request #149 from dolanmiu/feat/grid-span
Feat/grid span
2018-10-15 23:23:20 +01:00
8ac19a83b2 Rename demos 2018-10-15 22:21:40 +01:00
9f0b2f7074 Improve API 2018-10-15 21:54:33 +01:00
e02ac43c07 Version bump 2018-10-10 20:39:11 +01:00
97f76fb62c Change to new header API 2018-10-05 01:33:17 +01:00
3508fd97ec Merge branch 'importDotx' of https://github.com/amitm02/docx into importDotx 2018-10-05 01:21:29 +01:00
90f6f68693 Changed protected to private 2018-10-05 00:20:43 +01:00
733775d3b9 Rename demo 2018-10-05 00:08:14 +01:00
f3aa6a9203 detect if page title is defined in tempalte 2018-10-02 17:52:55 +03:00
ffdcc7baca hande hyplerlink references in header or footers 2018-10-02 16:17:26 +03:00
a1e20f4c9a handle templates with no headers or foolters 2018-10-02 16:02:28 +03:00
ccffdad4c0 Merge pull request #171 from amitm02/master
Contextual spacing
2018-09-26 15:57:16 +01:00
2fb5845501 contextual spacing 2018-09-26 17:47:17 +03:00
ddd84a1765 Merge pull request #3 from dolanmiu/master
from base
2018-09-26 17:27:41 +03:00
048ae6a58c extract styles from dotx 2018-09-26 14:33:05 +03:00
fafa54e4c9 bug fix (demo29 corrupted) 2018-09-26 13:10:21 +03:00
60dbb32e9e Revert "Revert "Add back relationships""
This reverts commit 52b07fd9cb.
2018-09-26 12:03:52 +03:00
52b07fd9cb Revert "Add back relationships"
This reverts commit 6e0c12afb3.
2018-09-26 10:12:40 +03:00
f6a13aed86 Merge pull request #169 from dolanmiu/feat/table-of-contents
Feat/table of contents
2018-09-26 02:28:44 +01:00
2da3ba0262 Rename variables 2018-09-26 02:17:39 +01:00
e08c7cbbfb Add table of contents to side bar 2018-09-26 02:12:10 +01:00
a6de5d8a21 Merge pull request #168 from dolanmiu/feat/table-of-contents
Change documentation properties to options
2018-09-26 02:10:03 +01:00
8ec5bc05e0 Export file properties 2018-09-26 02:03:32 +01:00
6e0c12afb3 Add back relationships 2018-09-26 00:24:33 +01:00
466e880bfc Merge from master 2018-09-25 23:46:55 +01:00
00a20b7cfc Merge pull request #166 from dolanmiu/feat/table-of-contents
Feat/table of contents
2018-09-25 23:32:58 +01:00
f27c95191b Change documentation properties to options 2018-09-25 21:19:04 +01:00
c140d2c37c ITableOfContentsProperties to ITableOfContentsOptions 2018-09-25 21:09:30 +01:00
3a42f2a2f0 Make API simplier with interfaces 2018-09-25 20:05:35 +01:00
00efedaa09 Fix spelling and linting and improve readme 2018-09-25 19:49:44 +01:00
72e3d229dc unnecessary comment removed 2018-09-25 02:36:00 -03:00
b12d6ef484 initial documentation 2018-09-25 02:35:08 -03:00
8ee6fd3e67 demo updated 2018-09-25 01:33:44 -03:00
808c5b00a0 table of contents with all the options 2018-09-25 01:18:47 -03:00
4de6b51e76 removed getStyles and clearPageBreak that became useless 2018-09-25 00:10:27 -03:00
0a8feca6ab Rename importDocx to import-dotx 2018-09-24 22:00:08 +01:00
4ca81df401 TOC content generation aborted 2018-09-21 11:16:14 -03:00
8b463b3bb6 updated clone deep dependency and make fields dirty to be updated when word is opened 2018-09-21 10:26:28 -03:00
17d696e33a merge with master, demo27 became demo28 2018-09-21 07:40:58 -03:00
2f59867db6 Merge branch 'feat/table-of-contents' of https://github.com/dolanmiu/docx into feat/table-of-contents 2018-09-21 07:37:26 -03:00
90f3da74cf Version bump 2018-09-20 21:04:21 +01:00
28d8659cb5 Merge pull request #161 from bre7/patch-1
Improve fluency (dsl like)
2018-09-20 21:03:38 +01:00
5d1740a2ef Style fixes 2018-09-20 16:54:58 -03:00
7aa44568d8 Improve fluency (dsl like)
addRunProperty / addParagraphProperty should also return this
2018-09-20 15:51:57 -03:00
bf1f702e5a created a clone method for xml-components 2018-09-20 15:13:18 -03:00
78ad3e340a Merge pull request #160 from bre7/patch-1
Added charSpacing to docs
2018-09-20 18:46:30 +01:00
63a965beab Added charSpacing 2018-09-20 14:00:49 -03:00
815354e06f Merge pull request #159 from bre7/master
Added character spacing attribute
2018-09-20 16:27:21 +01:00
1cff104bae correct sdt objects of table of contents 2018-09-20 10:47:10 -03:00
4805efad2e organized imports 2018-09-20 10:31:49 -03:00
12e2ae9e91 making leader a option field and test improvments 2018-09-20 10:30:16 -03:00
c07b5cf709 added settings.xml back 2018-09-20 10:11:59 -03:00
0684738ec2 removed lodash 2018-09-20 07:09:17 -03:00
f2b50478bf Fix tests and use proper types for disregarding XMLComponent 2018-09-20 00:41:57 +01:00
fc71ebdfef Refactor code 2018-09-19 23:07:37 +01:00
10114bb12d Remove TemplatedFile 2018-09-19 23:04:34 +01:00
6da3efdacc Added character spacing attribute 2018-09-19 18:41:55 -03:00
7cd8864fb9 added stdPr and stdContent to table of contents 2018-09-19 11:01:07 -03:00
a9c69664c7 Merge pull request #156 from bre7/master
Added mirror margins option
2018-09-19 12:40:31 +01:00
50569224c3 Fixed tests (included mirrorMargins attr) 2018-09-18 23:50:10 -03:00
e6d4741955 Merge branch 'master' of https://github.com/dolanmiu/docx into importDotx
# Conflicts:
#	src/file/file.ts
2018-09-19 01:53:52 +01:00
4d7387524c Rename demo 2018-09-19 01:30:25 +01:00
877aa325bb Merge pull request #153 from felipeochoa/fix-109
Fix 109
2018-09-19 01:25:32 +01:00
eb797d8986 Ignore Yarn lock & IntelliJ ide 2018-09-18 21:03:50 -03:00
fcb542471b Added mirror margins options 2018-09-18 21:03:20 -03:00
5fe4405d76 Add templated file 2018-09-19 00:37:11 +01:00
baf0f17bd6 added a method for clear the page breaks of a paragraph 2018-09-18 13:53:30 -03:00
8e911698a5 generating the content for a table of contents 2018-09-18 05:24:19 -03:00
0eb36be053 there is no need for the settings.xml file anymore 2018-09-17 22:09:05 -03:00
79dffc873a Organise imports 2018-09-18 00:51:35 +01:00
26ee12759c Using custom parseOptions 2018-09-17 23:54:19 +01:00
2e00634bc4 Fix tests but break demo 27 2018-09-17 22:06:38 +01:00
d63e6bf6b1 Revert back body test 2018-09-17 21:44:12 +01:00
a95366e54e Fix demo 27 2018-09-17 21:18:27 +01:00
1c376abeb6 Fix demo 8 2018-09-17 21:15:24 +01:00
353d888abd Simplify code using Spreading 2018-09-17 20:27:43 +01:00
b6bd532295 Use dedicated XmlComponent rather than polute pure one 2018-09-17 20:22:11 +01:00
c5b004166d Add back comp null check 2018-09-17 20:18:31 +01:00
2f43600daf Remove MyDocument 2018-09-17 20:09:31 +01:00
b39c7ce323 Fix naming 2018-09-17 20:06:51 +01:00
5b00279996 Remove space 2018-09-17 19:44:21 +01:00
53b24965aa Merge pull request #152 from felipeochoa/fix-typo-table-properties
Fix typo in private property
2018-09-17 19:04:58 +01:00
edce1bef92 Allow creating Styles and assigning them to File.Styles
Closes #109
2018-09-17 12:48:21 -05:00
e0d54d3af3 Fix typo in private property 2018-09-17 12:41:17 -05:00
d1d1e01aff lint fix 2018-09-17 11:29:01 +03:00
980bc597e2 test fixes 2018-09-17 11:24:56 +03:00
a05c5edd49 Revert back .vscode folder 2018-09-14 02:44:47 +01:00
985452f5f4 Use proper name 2018-09-14 02:39:52 +01:00
482674b3b3 Fix spelling error 2018-09-14 02:37:03 +01:00
fcbfed9068 Revert code 2018-09-14 02:33:36 +01:00
a9167b4809 Update demos 2018-09-13 01:54:37 +01:00
5b28eb0d00 Update logo to be blinking 2018-09-12 21:19:33 +01:00
f1b176670c Add more table demos 2018-09-12 21:03:06 +01:00
11ce9a5206 Add horizontal span 2018-09-12 21:01:52 +01:00
8b667b8d4c Merge pull request #148 from dolanmiu/feat/logo
Updated logo dimensions
2018-09-11 19:18:31 +01:00
a601a82a37 Updated logo dimensions 2018-09-11 19:16:47 +01:00
dcf3767a05 Merge pull request #147 from dolanmiu/feat/logo
Add logo
2018-09-11 19:08:27 +01:00
a9278009f8 Merge branch 'feat/logo' of https://github.com/dolanmiu/docx into feat/logo 2018-09-11 19:04:19 +01:00
5220f9e07c Add correct image 2018-09-11 19:03:53 +01:00
0b88064ca2 Update README.md 2018-09-11 19:03:29 +01:00
2233ccb968 Add logo 2018-09-11 19:00:52 +01:00
311fde01a1 Update Readme 2018-09-10 22:44:44 +01:00
146d0ad9e5 Moved addTableOfContents to File and creating a settings.xml and applying updateFields=true when there is a table of contents 2018-09-10 10:01:26 -03:00
385ad92331 Fix linting errors 2018-09-07 21:48:59 +01:00
571f8b526b Fix demo 2018-09-06 09:18:52 +01:00
7688aa99f6 Fix linting errors 2018-09-06 09:09:36 +01:00
4994bca34c Fix some linting errors 2018-09-06 08:30:23 +01:00
1a3603dbfb fix demo 16 2018-09-05 10:02:42 +03:00
aedfca377f elements need to be inside runs 2018-09-04 18:22:08 -03:00
7926f6c189 escape bars 2018-09-04 17:29:24 -03:00
0303a9f553 Merge pull request #141 from XappMedia/min-eight
Minimum Node v8 Support
2018-09-04 18:26:34 +01:00
e9a007d446 create default properties for table-of-contents instruction 2018-09-04 12:05:41 -03:00
e382dbff84 update demp template 2018-09-04 17:32:16 +03:00
e08be3d7a4 update template 2018-09-04 17:31:30 +03:00
03c4190c2c works! 2018-09-04 17:16:31 +03:00
12c1f82efe demo27 for TableOfContents 2018-09-04 11:03:17 -03:00
b1711ae293 first simple version of TOC working 2018-09-03 11:20:36 -03:00
a367951d07 moved Begin, Separate and End from page-number.ts to field.ts 2018-09-03 10:54:53 -03:00
c55f82c425 test improvment 2018-09-03 10:48:50 -03:00
2dab11e8b3 minimum 8 2018-08-31 11:25:05 -04:00
d1044d262e table of contents extending paragraph 2018-08-31 10:22:40 -03:00
010fde6258 commit 2018-08-29 18:36:48 +03:00
8d83219bb6 wrote some initial code 2018-08-29 12:06:01 -03:00
a710483918 Merge pull request #2 from dolanmiu/master
merge from upstream
2018-08-27 18:11:47 +03:00
4f8ecf631b Merge branch 'master' into feat/table-of-contents 2018-08-23 06:21:01 -03:00
cc453dc24e Merge pull request #134 from dolanmiu/feat/readme-update
Version bump
2018-08-23 01:27:59 +01:00
60abe4857b Version bump 2018-08-23 01:26:30 +01:00
dc942bc2e4 Merge pull request #133 from dolanmiu/feat/readme-update
Add table cell margin
2018-08-23 01:24:16 +01:00
90497036a6 Fix browser demo 2018-08-23 01:12:54 +01:00
fe2032a3d4 change demos to typescript and WidthType disparity 2018-08-23 01:05:26 +01:00
877dcb462f Add table cell margin 2018-08-23 00:55:33 +01:00
4a3b7d71fe Merge pull request #130 from dolanmiu/feat/readme-update
Fix demo examples
2018-08-22 14:48:30 +01:00
0e1bfb6524 Merge pull request #132 from dolanmiu/pull-126
Old PR #126 Fixed
2018-08-22 14:48:04 +01:00
e68bc50e6e style fixed 2018-08-22 10:39:13 -03:00
a6a8012b39 wrote some inital code 2018-08-22 10:30:19 -03:00
e9e42011cd Merge branch 'master' into master 2018-08-22 08:04:45 -03:00
85f686dede Fix demo examples 2018-08-22 01:14:17 +01:00
0f6f79ebc6 Merge pull request #128 from nschechter/feat/paragraph-borders
Feat/paragraph borders
2018-08-22 01:08:53 +01:00
9a6c92222c Change demo26 to typescript 2018-08-22 00:51:18 +01:00
33f87523e0 Merge from master 2018-08-21 23:50:58 +01:00
a53818754a Merge pull request #129 from dolanmiu/feat/readme-update
Add new slogan
2018-08-21 23:09:51 +01:00
6c2f335a31 Add new slogan 2018-08-21 22:29:40 +01:00
ff80f76855 Merge pull request #124 from dolanmiu/feat/browser-packer
Feat/browser packer
2018-08-21 22:04:01 +01:00
6f0f3ccca7 Update documentation 2018-08-21 21:46:12 +01:00
eb9cc767c6 Merge from master 2018-08-21 20:59:20 +01:00
410080a8a3 Fix tests 2018-08-21 19:27:07 +01:00
d5b6225a90 starting table of contents 2018-08-21 07:19:46 -03:00
a777842f9d updated mocha to version 5 due to vulnerabilities found by npm audit 2018-08-21 07:16:27 -03:00
62306133c8 Update .travis.yml 2018-08-21 10:27:46 +01:00
a7f6224fb2 Made demo files into typescript files 2018-08-21 02:46:21 +01:00
e97c432a64 added border specs, createBorder method, and color attribute to setProperties 2018-08-19 19:37:36 -04:00
0411153832 Added in the ability to create borders for paragraphs 2018-08-19 11:59:38 -04:00
f9a0d1b388 Fix tests 2018-08-15 23:06:48 +01:00
bf5bcea607 Make add image support base64 strings 2018-08-15 22:20:43 +01:00
f969c866a7 Update target for library 2018-08-15 01:38:00 +01:00
07261232ff Removed old compiler and unused dependencies 2018-08-15 01:22:22 +01:00
2018f41368 Discard pdf 2018-08-14 22:05:04 +01:00
bfa0edeb09 Remove pdf packer 2018-08-14 21:56:38 +01:00
3d91c84966 alphabetized import sources 2018-08-14 11:28:01 -03:00
f91fd5921f merge with upstream master 2018-08-14 11:27:08 -03:00
36157bb8db Added optional drawingOptions parameter to addImage and addImageFromBuffer methods. This way it can be passaed to Image constructor. 2018-08-14 11:06:17 -03:00
a38abeb4c2 Huge refactoring to use new compiler and deprecate all other Packers
Add new PdfPacker
2018-08-14 01:46:48 +01:00
675192b86f Refactor image to accept Buffer only 2018-08-12 23:07:31 +01:00
bc1132146f Revert test changes 2018-08-10 02:46:15 +01:00
d850f37904 Remove unused import 2018-08-10 01:49:37 +01:00
f15fdb921e Merge branch 'master' into feat/browser-packer
# Conflicts:
#	demo/demo13.js
#	package.json
#	src/export/packer/compiler.ts
#	src/file/media/data.ts
#	src/file/media/media.ts
2018-08-10 01:40:29 +01:00
7b43551148 Merge pull request #123 from dolanmiu/feat/h4-update
Feat/h4 update
2018-08-10 00:30:53 +01:00
ad356d2759 Add ignores so it doesnt get generated in documentation 2018-08-09 23:40:11 +01:00
5f594a822f Fix and enable linting on tests 2018-08-09 23:29:40 +01:00
89df3c48e0 Fix linting errors 2018-08-09 23:22:03 +01:00
3436a1584c Merge branch 'master' of https://github.com/h4buli/docx into feat/h4-update
# Conflicts:
#	package.json
#	src/file/document/body/body.ts
#	src/file/document/body/section-properties/section-properties.ts
#	src/file/file.ts
#	src/file/media/media.ts
#	src/file/styles/external-styles-factory.ts
#	src/file/table/table-cell.ts
2018-08-09 23:21:24 +01:00
d44b0d50d8 Merge pull request #118 from dolanmiu/feat/add-image-to-run
Add image to run
2018-08-09 23:06:05 +01:00
1bd94aca7c Merge pull request #117 from dolanmiu/feat/refactor-bidi
Feat/refactor bidi
2018-08-09 23:05:58 +01:00
f264e4d0f7 Add scale method to image 2018-08-09 21:58:50 +01:00
d8252141fe Update tsconfig.json 2018-08-09 11:54:05 +01:00
d9716a1cf7 Update README.md 2018-08-09 11:52:47 +01:00
e9bd27bc55 Update README.md 2018-08-09 11:52:17 +01:00
0a69851463 Update README.md 2018-08-09 11:51:27 +01:00
5e7c5aa620 Fix typo 2018-08-09 03:23:07 +01:00
f6996a1d98 Update README 2018-08-09 03:20:46 +01:00
e9ea4845be Improve README 2018-08-09 03:13:16 +01:00
d961721b33 Refactor name 2018-08-09 02:56:23 +01:00
bb8c29f4a2 Fix tests 2018-08-09 02:53:28 +01:00
e10c20fa42 Add image to run 2018-08-09 01:55:50 +01:00
94274733f4 Improve API documentation 2018-08-08 22:51:54 +01:00
42f723813a Merge branch 'master' into feat/refactor-bidi
# Conflicts:
#	demo/demo22.js
#	src/file/paragraph/run/run.ts
2018-08-08 20:20:22 +01:00
4c75b91ce9 Update README.md 2018-08-08 01:53:44 +01:00
3dd6faa620 Update README.md 2018-08-08 01:29:52 +01:00
9a1313fe89 Merge pull request #114 from amitm02/complex-font-bold
add bold and italic formatting support for complex font (e.g Hebrew)
2018-08-07 14:30:52 +01:00
fe43525dad update hebrew demo 2018-08-07 16:19:13 +03:00
92da93a160 Rename to more readable names 2018-08-07 02:47:24 +01:00
cf0c2c7691 Add Express packer deprecation warning 2018-08-07 02:23:58 +01:00
e9aecfac1c Updated lint rules 2018-08-07 01:38:15 +01:00
12c8cb93f6 Clean up API 2018-08-07 01:25:28 +01:00
f9c97a673e add complex font support to bold and italic 2018-08-06 12:14:51 +03:00
ca8f331eec Add new demo and remove tslint disable 2018-08-06 03:53:27 +01:00
9e11774a1b Add no null rule 2018-08-06 03:49:27 +01:00
257c8bde99 Add pre-commit hook 2018-08-06 03:26:30 +01:00
0bdbb1b24a Add more documentation 2018-08-06 02:57:25 +01:00
bd1aa7b49e Update URL 2018-08-05 04:25:12 +01:00
5de3dc802f Add more examples 2018-08-05 04:24:04 +01:00
f25ecd0743 Update docs 2018-08-05 04:18:12 +01:00
cdf3a6fb40 Add more examples 2018-08-05 04:14:25 +01:00
f9c5db8df7 Add sample demo 2018-08-05 03:28:51 +01:00
7d05d69707 Update documentation and README 2018-08-04 04:03:08 +01:00
08a3538d8e Update documentation 2018-08-04 03:40:41 +01:00
6b38a3637f Merge pull request #113 from dolanmiu/feat/documentation-revamp
Feat/documentation revamp
2018-08-04 03:32:48 +01:00
7d116d1ce9 Add more documentation 2018-08-04 03:28:27 +01:00
73267ac4e5 Add docsify documentation 2018-08-03 23:26:14 +01:00
efe7d594b0 Add accessor to getter and setters 2018-08-03 02:29:58 +01:00
b7a4ca9c3b Merge pull request #89 from dolanmiu/feat/base64-image
Image methods
2018-08-03 02:22:46 +01:00
810fd7e7b8 Fix style and tslint 2018-08-03 01:53:19 +01:00
22bd13a253 Add image tests 2018-08-03 01:28:20 +01:00
5f22950721 Change image API so that it now sends Images 2018-08-03 00:01:42 +01:00
31fdf08c27 Make function return Image rather than PictureRun 2018-08-02 21:14:53 +01:00
2d12f6e54c Add new Image class 2018-08-02 21:07:37 +01:00
f7c02f4679 Revert returning Paragraph 2018-08-02 02:32:57 +01:00
3fcfc29e3f Style formatting 2018-08-02 02:21:15 +01:00
817356f2a8 Merge pull request #107 from ydfzgyj/gridspan
add addGridspan to TableRow
2018-08-02 02:20:30 +01:00
8fbaec3567 Merge pull request #106 from ydfzgyj/shading
Add table cell shading
2018-08-02 02:20:16 +01:00
3f1eda60eb Rename data to buffer 2018-08-02 02:14:57 +01:00
0d5e9ce9d8 Offload media methods into Media static object
Simplified File handling of images
2018-08-02 02:09:00 +01:00
019ae24c7d Change method to createImageData 2018-08-01 23:32:31 +01:00
4dd84ded54 Merge branch 'master' into feat/base64-image 2018-08-01 23:22:38 +01:00
5232c055b1 Merge pull request #111 from felipeochoa/bugfix-110
Fix #110
2018-07-31 19:12:41 +01:00
06d3f3c34b Fix #110 2018-07-31 12:13:05 -05:00
2aca988c0b fix style 2018-07-27 17:26:23 +08:00
fc27e44471 Add addGridSpan to TableRow 2018-07-27 17:25:04 +08:00
60f312446e fix style 2018-07-27 16:59:29 +08:00
807605c0cc Add table cell Shading 2018-07-27 16:55:03 +08:00
1aa592b1b9 Merge pull request #105 from ydfzgyj/buffer
fix inheritance of BufferPacker class
2018-07-26 13:03:06 +01:00
763fa62eca Merge pull request #103 from amitm02/master
resubmitting bidi and RTL support with lint fixs
2018-07-26 13:02:42 +01:00
40ac08836d bidi+rtl demo 2018-07-26 14:49:21 +03:00
6bdcee1d1b fix inheritance of BufferPacker class 2018-07-26 17:16:18 +08:00
0ea79775c5 Merge branch 'master' of https://github.com/amitm02/docx 2018-07-25 15:04:01 +03:00
696b5daf5c rtl 2018-07-25 15:02:58 +03:00
e136f4e987 more alignments 2018-07-25 13:07:58 +03:00
41308fea13 prettier 2018-07-25 12:51:02 +03:00
0e14b2d2e3 fix lint issues 2018-07-25 09:47:09 +03:00
c9b66bf77b Merge branch 'master' of https://github.com/amitm02/docx 2018-07-25 09:28:05 +03:00
4168d1a296 revert 2018-07-25 09:28:01 +03:00
51d172b8fc Merge branch 'master' into master 2018-07-25 09:27:11 +03:00
e02e54db2c Merge pull request #100 from XappMedia/bookmarks-and-internal-hyperlinks
feat: Bookmarks and Internal hyperlinks
2018-07-24 22:40:47 +01:00
305dd84769 adding a demo 2018-07-24 17:15:23 -04:00
985ea30d36 tests 2018-07-24 16:56:27 -04:00
cc904ee211 style fix 2018-07-24 16:00:55 -04:00
8ceb38963e initial functionality 2018-07-24 15:56:13 -04:00
59ca9df663 remove post install 2018-07-24 18:58:01 +03:00
0689489985 Merge branch 'master' into build 2018-07-24 18:53:18 +03:00
3015b05c77 add rtl mode 2018-07-24 18:52:45 +03:00
f299e49966 Merge pull request #1 from dolanmiu/master
original updates
2018-07-24 18:33:33 +03:00
0186450221 Merge pull request #98 from ydfzgyj/font
Let fonts suit for more characters
2018-07-24 10:49:47 +01:00
974eb510ef Fix style 2018-07-24 12:37:15 +08:00
1fad9a666e Let fonts suit for more characters 2018-07-24 12:24:26 +08:00
b6cf1ab951 Add demo20 table border styles 2018-07-23 20:28:29 +01:00
d979ef3b40 commit 2018-07-23 10:31:48 +03:00
4a320d3031 npm postinstall 2018-07-23 10:08:09 +03:00
fbfdc6a383 add test 2018-07-22 17:08:11 +03:00
4dfce582c8 bidi support 2018-07-22 17:03:45 +03:00
ee048968cc Update request promise and pin types/bluebird 2018-07-21 01:42:34 +01:00
fe54e892cc Use node 9 2018-07-21 01:32:25 +01:00
5fab6e2714 Remove test only 2018-07-21 01:28:15 +01:00
8e80df30b9 Merge pull request #95 from dolanmiu/feat/update-dependencies
Feat/update dependencies
2018-07-21 01:24:40 +01:00
b9e7b9e1e3 Update typedoc 2018-07-21 01:21:28 +01:00
bb88053ae3 Update typescript 2018-07-21 01:13:17 +01:00
0611b94c01 Add docx.js.org CNAME 2018-07-15 23:36:13 +01:00
3da0bb38df Version bump 2018-07-06 19:01:23 +02:00
c57c7f2aa7 Merge pull request #13 from h4buli/feature/numbering-level-suffix
Add support to define suffix on a numbering level
2018-07-06 19:00:32 +02:00
a05abd0eea numbering: add support to define suffix for numbering level 2018-07-06 18:54:30 +02:00
c95e765456 Version bump 2018-07-03 14:11:19 +02:00
9d034ab48d Merge pull request #12 from h4buli/feature/section-page-borders
feature: add support for section page borders
2018-07-03 14:09:56 +02:00
796e000826 feature: add support for section page borders 2018-07-03 13:48:31 +02:00
60a92fb22b Merge pull request #90 from dolanmiu/feat/buffer-packer
Feat/buffer packer
2018-07-01 02:29:19 +01:00
ddbae91840 Add buffer packer tests 2018-07-01 02:26:23 +01:00
ded155a6af Add buffer packer 2018-07-01 02:16:11 +01:00
59cc0d3211 Add demo of current way of adding image from base64 string 2018-07-01 01:07:52 +01:00
4b06baab3f Merge pull request #87 from dolanmiu/feat/footnotes
Feat/footnotes
2018-06-30 23:53:42 +01:00
ef16dac4f4 Improve demo 2018-06-30 23:50:11 +01:00
b8934c68f2 Add counter to footnotes 2018-06-30 23:50:02 +01:00
e5fae3af64 Add footnote test 2018-06-30 23:42:48 +01:00
34a92ab448 Use enums instead of strings 2018-06-30 23:41:57 +01:00
6c85ad3188 Fix tests 2018-06-30 23:39:45 +01:00
9f0e55b7b8 Add footnotes spec file 2018-06-29 19:49:19 +01:00
612a2f90ac version bump 2018-06-29 16:31:25 +02:00
c797ed9c25 media: fixed bug when media size can be decimal
- produces invalid docx document
2018-06-29 00:32:01 +02:00
5dc82d8176 Add styles to footnote 2018-06-28 03:01:25 +01:00
802e461792 Footnotes demo 2018-06-27 23:36:04 +01:00
b9e702086a Merge branch 'master' into feat/footnotes
# Conflicts:
#	demo/demo16.js
#	src/file/file.ts
2018-06-27 23:34:23 +01:00
9f591c4d87 Merge pull request #86 from dolanmiu/feat/multiple-headers
Feat/multiple headers
2018-06-27 23:28:07 +01:00
55220c147d version bump 2018-06-27 22:10:11 +02:00
2ea5b1c0bd Merge pull request #11 from h4buli/fix/parsing-external-styles
bug: Not all content from external styles was imported correctly
2018-06-27 22:05:44 +02:00
ed72d60951 external-styles: create correct XmlComponents from imported style 2018-06-27 21:55:15 +02:00
5f6d177df9 Update README.md 2018-06-27 02:27:56 +01:00
b3e15d6729 Updated demo for sections 2018-06-26 23:34:39 +01:00
b26a9f8dcf Fix styles 2018-06-26 00:10:08 +01:00
f3a822b4b2 Add section demo 2018-06-26 00:03:37 +01:00
cee091fa58 Use method approach to different first page header 2018-06-26 00:03:28 +01:00
84ebf8e6c3 Remove old implementation of first page header 2018-06-25 22:13:12 +01:00
2a0b45dc20 make default settings in the addSection 2018-06-25 21:53:01 +01:00
00955d2e4f Fix imports 2018-06-25 19:53:40 +01:00
044442b0d7 Add footnote classes 2018-06-25 19:50:19 +01:00
99290d646e Add footnote support to API 2018-06-25 19:49:46 +01:00
52007785af version bump 2018-06-25 12:54:36 +02:00
9d3b32a841 fix: fixed wrong import causing exported SectionProperties class to be unusable 2018-06-25 12:53:25 +02:00
0b939b1cd6 Organise imports 2018-06-22 23:18:07 +01:00
d63adc7a6b Fix linting 2018-06-22 23:04:03 +01:00
026a221e5e Move header outside 2018-06-22 23:01:34 +01:00
f1ac646518 Merge branch 'feature/multiple-sections' of https://github.com/h4buli/docx into feat/multiple-headers
# Conflicts:
#	src/export/packer/compiler.ts
#	src/file/content-types/content-types.ts
#	src/file/document/body/section-properties/header-reference/header-reference.ts
#	src/file/document/body/section-properties/section-properties.ts
#	src/file/file.ts
#	src/file/media/media.ts
2018-06-22 22:59:38 +01:00
8b3cf8c38c Merge pull request #84 from dolanmiu/feat/h4-update
Feat/h4 update
2018-06-22 01:22:50 +02:00
89e2129ca4 Version bump 2018-06-21 14:50:50 +02:00
d9999f8dd9 Merge pull request #10 from h4buli/feature/multiple-sections
feature: add multiple sections to the document inc. headers and footers
2018-06-21 14:49:24 +02:00
0b963ec3b8 feature: add support to add mutiple sections to the document inc. headers and footers
- write missing tests
2018-06-21 12:03:34 +02:00
369ec9c30b Set correct ID 2018-06-11 00:50:48 +01:00
c19a2e71b5 Add footnotes as part of export 2018-06-11 00:48:50 +01:00
6085f69c22 Sorting 2018-06-11 00:46:51 +01:00
8cb8d3514a Add footnotes class 2018-06-11 00:45:21 +01:00
55005b57c6 Fix linting and style errors 2018-06-09 23:49:01 +01:00
80cdaaeb1c Fix compile error 2018-06-09 23:34:54 +01:00
deccfd7cc9 Add back scale functionality 2018-06-09 23:33:52 +01:00
0f4c2e64f4 Merge branch 'master' of https://github.com/h4buli/docx into feat/h4-update
# Conflicts:
#	package.json
#	src/file/drawing/drawing.ts
#	src/file/media/media.ts
#	src/file/paragraph/run/picture-run.ts
#	src/file/styles/external-styles-factory.ts
#	src/file/xml-components/imported-xml-component.ts
2018-06-09 23:29:59 +01:00
b8b5d18662 version bump 2018-06-08 22:21:10 +02:00
5ee5698347 Merge pull request #9 from h4buli/feature/image-position
Add support for different positioning of the images
2018-06-08 22:19:27 +02:00
97b254ee7b add support for floating drawings
- added need elements and test for them
2018-06-08 16:03:04 +02:00
ac40a40ec0 refactor: move components from /drawing/inline to /drawing
- they will be used for other positioning element (floating)
2018-06-08 07:50:23 +02:00
b5b96506ae Add footnotes scaffolding 2018-06-03 02:11:21 +01:00
548fe3c864 Version bump 2018-05-28 09:18:09 +02:00
97e976a184 import: add support to import any xml tab element to XmlComponent (#8)
- make method to import/convert to XmlComponent
 - expose method to add childElement to Header/Footer
 - add tests
2018-05-28 09:15:44 +02:00
5de6617d10 Merge pull request #75 from h4buli/feature/page-break-before
paragraph: add support for 'page break before' format property
2018-05-28 02:33:59 +01:00
bcd6110578 Add demo for page break before 2018-05-28 02:27:46 +01:00
ba0ca78696 Version bump 2018-05-22 02:35:03 +01:00
22ba53ad4c Merge pull request #79 from formatically/master
Removed unnecessary header2 references
2018-05-20 20:28:23 +01:00
81304f50d1 Removed unnecessary header2 references 2018-05-19 20:52:45 -06:00
3c22372f49 Merge pull request #76 from formatically/master
Added DifferentFirstPageHeader and Page Number features
2018-05-19 12:30:39 +01:00
7584671312 Fixed TSLint Errors 2018-05-18 09:21:27 -06:00
7296c9e744 Removed extra empty lines 2018-05-17 19:51:01 -06:00
c63a8982e4 Added demo14 to showcase differentFirstPageHeader and pagenumbers 2018-05-17 19:44:37 -06:00
8d35dc1bb0 Added tests, renamed pagenumber to page-number 2018-05-17 13:32:33 -06:00
0fedfcf709 Renamed titlepage to title-page 2018-05-17 11:54:13 -06:00
6c2eb882bb Added differentFirstPageHeader section property 2018-05-17 11:45:06 -06:00
c9eb27de11 fixed formatting styles 2018-05-17 15:34:47 +02:00
dadd8c122f fixed formatting styles 2018-05-17 15:32:15 +02:00
59560d96ba Add downloads badge and remove existing node badge 2018-05-16 20:10:12 +01:00
864c9afd93 Remove Gemnasium because they no longer exist :( 2018-05-16 20:00:01 +01:00
b4f07f51ae Merge pull request #70 from dolanmiu/feat/h4buli-update
H4 update
2018-05-16 19:51:40 +01:00
e9b153095c Add demo for custom xml styles 2018-05-16 19:34:25 +01:00
7968c1efcf Removed header-wrapper-2 2018-05-12 22:22:54 -04:00
87648a742c Initial Commit 2018-05-12 20:04:54 -04:00
cdb86b741c Version bump 2018-05-10 20:25:14 +02:00
15e8d7c053 paragraph: add support for page break before format property (#7) 2018-05-10 20:24:06 +02:00
cbe9c3ac50 paragraph: add support for page break before format property 2018-05-10 19:43:58 +02:00
4d7bdc2ed9 Version bump 2018-05-08 22:19:01 +01:00
d10c707f12 Add tests for catching errors for exporter packer.pack 2018-05-08 20:40:04 +01:00
ac512b2eab Merge branch 'feat/h4buli-update' of https://github.com/dolanmiu/docx into feat/h4buli-update 2018-05-08 02:12:20 +01:00
fdf6a59c4c Add back xml-component export 2018-05-08 01:26:13 +01:00
4b9a6a6735 Merge branch 'master' into feat/h4buli-update 2018-05-08 01:23:56 +01:00
49cc8a267c Merge pull request #71 from ivanryuu/hyperlink_support
External hyperlink support
2018-05-08 01:16:28 +01:00
68cb57aea6 fix style issues 2018-05-06 23:18:00 -05:00
9d7fd55e4c add hyperlink to paragraph and doc 2018-05-06 22:24:16 -05:00
195c62f80b modify relationships to support external links 2018-05-06 22:23:35 -05:00
1fd222abea create hyperlink style 2018-05-06 22:23:04 -05:00
ac40e13e33 added support for hyperlinks 2018-05-06 22:20:56 -05:00
53ab822dbc Fix style 2018-05-06 03:38:08 +01:00
0c9c292291 Fix tests. _attr is needed 2018-05-06 03:27:58 +01:00
573dd753a7 Fix styling and linting 2018-05-06 03:19:36 +01:00
79b5b3a1f6 Merge branch 'master' into feat/h4buli-update 2018-05-06 03:03:45 +01:00
52e8fe576e Bump prettier version 2018-05-06 03:03:35 +01:00
0d34d2d92e Merge branch 'master' into feat/h4buli-update 2018-05-06 03:02:26 +01:00
b389ac6347 Add style fix command 2018-05-06 03:02:06 +01:00
534c601068 Linting fixes 2018-05-06 02:58:16 +01:00
424436579b Remove xml component from main export 2018-05-06 02:58:08 +01:00
a716360faa Restore numbering 2018-05-06 02:57:40 +01:00
af485c678d Merge branch 'master' of https://github.com/h4buli/docx into feat/h4buli-update
# Conflicts:
#	package.json
#	src/file/numbering/numbering.ts
2018-05-06 02:57:15 +01:00
84e298e7ee Version bump 2018-05-04 15:59:46 +02:00
753287d9d1 extend table and table cell support for cell merge, span, borders ... (#6)
* extend table and table cell support for cell merge, span, borders ...

* added tests for table cell borders and table cell width, renamed some variables, added jsdoc
2018-05-04 15:56:28 +02:00
21bb8f9016 Version bump 2018-04-26 14:18:22 +02:00
dc136daeab tables: add option to pass column size when creating a table
- add optionto the XmlComponent to `delete`/skip elements when exporting to xml
2018-04-26 14:16:02 +02:00
e8bc7952db Move fs to exporter and add browser packer 2018-04-24 22:56:56 +01:00
06418655c0 Add image support to new packer 2018-04-24 22:35:31 +01:00
c99b2940c6 Add next gen compiler using JSZip 2018-04-24 21:12:09 +01:00
e67f5f80e1 Version bump 2018-04-23 11:50:40 +02:00
3691d79a4a add method to add child to an element 2018-04-23 11:49:57 +02:00
8108eca2fa Update README.md 2018-04-21 00:04:14 +01:00
4f48c8fb80 Merge branch 'master' of github.com:h4buli/docx 2018-04-20 16:01:09 +02:00
20ba081308 Version bump 2018-04-20 16:00:44 +02:00
2119ae769b Images: Extend API for working with images (#5)
* extend creating image using buffer and dimensions from outside

* remove empty space
2018-04-20 15:59:06 +02:00
c618ca7539 Version bump 2018-04-17 16:33:08 +02:00
8b11140be2 export AbstractNumbering class 2018-04-17 16:31:36 +02:00
bebfec7755 version bump 2018-04-17 15:39:57 +02:00
124aac4888 fixed failing tests - removed test for the ctor for Numbering class 2018-04-17 15:38:51 +02:00
b3bfd063d8 Merge branch 'master' of github.com:h4buli/docx 2018-04-17 15:34:46 +02:00
c92cab5e5b Fix Numbering (#4)
* Version bump

* (fix): fixed issue with numbering in document
2018-04-17 15:33:53 +02:00
8c613195f3 Version bump 2018-04-10 21:55:02 +01:00
41f941728e Clean up and tests 2018-04-10 21:54:52 +01:00
ecf1542d95 Add instructions image 2018-04-10 21:42:21 +01:00
06b2bbba25 Add image demo 2018-04-10 21:36:11 +01:00
0494fdeabd Add other demo scripts as part of build 2018-04-10 21:08:40 +01:00
226206b100 Fix build 2018-04-10 21:06:02 +01:00
02f80bc616 Merge pull request #68 from citizenos/master
Updated bullet list creating
2018-04-10 21:04:27 +01:00
3189c9251a modified style script 2018-04-10 11:00:25 +03:00
ae43137906 revert demo10.js, fix paragraph tests 2018-04-10 10:25:12 +03:00
50bee30799 reverted gitignore 2018-04-09 23:21:51 +03:00
38484a3063 removed build folder 2018-04-09 23:18:55 +03:00
919327ed08 bullet points update 2018-04-05 16:50:25 +03:00
c00c5fa02d Merge pull request #67 from citizenos/master
image scaling add rounding
2018-04-03 22:51:15 +01:00
80f09ac10b modified git ignore 2018-04-02 14:37:54 +03:00
ee721ffbec image scaling add rounding 2018-04-02 12:55:43 +03:00
323f91dd68 Version bump 2018-03-28 16:31:44 +02:00
810ccb40d7 Merge pull request #3 from h4buli/feature/import-styles
styles: support for external styles. parsing external styles.
2018-03-28 16:02:11 +02:00
5242f7d55c styles: support for external styles. parsing external styles. 2018-03-28 14:54:07 +02:00
d293ae516c Merge pull request #2 from h4buli/revert-1-feature/external-styles-support
Revert "(styles): add support to provide external styles (as complete file co…"
2018-03-26 16:29:16 +02:00
3fb563f9c8 Revert "(styles): add support to provide external styles (as complete file co…" 2018-03-26 16:28:40 +02:00
1dd1c65341 Version bump 2018-03-24 19:24:24 +00:00
e593327fea Merge pull request #66 from dolanmiu/feat/resizable-pictures
Feat/resizable pictures
2018-03-24 19:23:22 +00:00
64e0aeeb18 Fix demo 2018-03-24 19:11:25 +00:00
05816abc12 Add scalable image feature 2018-03-24 19:06:10 +00:00
ce306aef07 Version bump 2018-03-23 12:25:30 +01:00
373c850f35 Merge pull request #1 from h4buli/feature/external-styles-support
(styles): add support to provide external styles (as complete file co…
2018-03-23 12:21:00 +01:00
a0e00b8eff (styles): add support to provide external styles (as complete file content) 2018-03-23 12:18:31 +01:00
a954c69458 Fix tests 2018-03-22 23:04:46 +00:00
a0e034bd55 Version bump 2018-03-22 22:56:05 +00:00
1a1c1f26d9 Border for tables by default 2018-03-22 22:55:33 +00:00
114c429aed pdf-export: remove option to export to pdf 2018-03-21 10:53:07 +01:00
40251a76f6 setup: rename npm package 2018-03-21 10:46:22 +01:00
a102b479e6 Add new demo 2018-03-10 23:04:45 +00:00
5b5f5ea203 Merge pull request #63 from felipeochoa/stream-packer
Added generic stream packer
2018-02-25 15:40:46 +00:00
40a8e581f1 Added generic stream packer 2018-02-23 19:21:00 -05:00
1b988e7135 Remove old deployment scripts 2018-02-21 22:09:55 +00:00
9433c7aedc Update documentation links 2018-02-21 22:09:42 +00:00
479dfed987 Clean up and nojekyll 2018-02-21 21:51:17 +00:00
1866033128 Remove spec files from docs 2018-02-21 21:46:02 +00:00
844b9ab2ec Update travis for docs 2018-02-21 21:34:43 +00:00
e6713d6ce2 Ignore My Document generated file 2018-02-13 23:21:20 +00:00
069ce73c07 Add My CV Demo 2018-02-13 23:20:14 +00:00
6dda6a5513 Formatting 2018-02-13 02:10:42 +00:00
329def42ac Prettier formatting 2018-02-13 02:08:28 +00:00
c5137b5fad Add RunKit examples 2018-02-13 02:07:56 +00:00
ab05ccb846 Simplify prettier command 2018-02-10 17:56:52 +00:00
cb8e9fdd36 Version bump 2018-02-08 01:19:00 +00:00
53ce3c1526 Formatting 2018-02-08 00:52:05 +00:00
a78f06b41b Remove all references to template 2018-02-08 00:12:59 +00:00
ce7ef30806 Fix Prettier styling changes 2018-02-05 01:44:28 +00:00
fd93c0776a Fix tests 2018-02-04 01:43:10 +00:00
6a762c6c0e Rename properties to core properties 2018-02-04 01:43:03 +00:00
23c5aef276 Add file relationships 2018-02-04 00:58:34 +00:00
69707a7207 Add more content type files 2018-02-03 20:56:20 +00:00
cfd3505414 Add content types initial files 2018-02-02 01:57:50 +00:00
ee958dc351 Fix exported type definitions 2018-02-02 01:56:08 +00:00
680f2325a3 Pin typescript version 2018-02-01 00:16:00 +00:00
2f0ad3eeb2 Add and fix tests 2018-01-31 23:24:55 +00:00
c895a9c7d9 Version bump 2018-01-31 21:10:15 +00:00
388a8404f5 Rename for further workaround 2018-01-31 20:12:09 +00:00
320cb1c418 Add workaround for files which only have an interface 2018-01-31 20:08:36 +00:00
8a6b73915f Update typescript 2018-01-31 19:09:30 +00:00
774355d608 Fix tests 2018-01-31 01:23:13 +00:00
35dbce3a68 Add File alias to Document for backwards compatability 2018-01-31 00:32:13 +00:00
6d0a267ba4 Add Header and Footer wrapper for their own relationship classes 2018-01-31 00:31:54 +00:00
df701be572 Merge pull request #58 from dolanmiu/feat/update-archiver
Update dependency
2018-01-30 01:47:20 +00:00
1edad47e6e Update dependency 2018-01-30 01:43:17 +00:00
c873abfe18 Fix referenceId +1 error and spelling mistakes
Add demo
2018-01-30 01:16:48 +00:00
989446ef36 Add tests 2018-01-29 23:09:54 +00:00
fc6daed620 Merge pull request #57 from dolanmiu/feat/footer
Add footer
2018-01-29 22:00:12 +00:00
5e921f1dfc Add footer 2018-01-29 21:53:22 +00:00
45bbf1b693 Merge pull request #56 from dolanmiu/feat/header
Feat/header
2018-01-29 03:00:07 +00:00
8b8c664f0f Add header objects and demo 2018-01-29 02:56:35 +00:00
079334f71b Make fields readonly 2018-01-29 01:55:25 +00:00
3fe0c76d54 Add header to type 2018-01-29 01:54:50 +00:00
1e55a3e6a8 Expose header 2018-01-29 01:54:10 +00:00
950a2f8b53 Add header class 2018-01-28 22:32:51 +00:00
bbe2e1e46e Fix styles 2018-01-28 20:34:49 +00:00
635c58c131 Fix tests 2018-01-28 20:23:30 +00:00
ba39d806b7 Add more demos to CI 2018-01-25 01:50:30 +00:00
355e97cb5e Landscape mode 2018-01-25 01:47:47 +00:00
4339f8cfc0 Add section properties 2018-01-25 01:21:03 +00:00
448572d7a1 Add section properties to root File 2018-01-24 13:09:34 +00:00
2132c7b6da Add watch to tests 2018-01-24 13:08:34 +00:00
d0bd83d6c5 Fix tests 2018-01-24 13:08:22 +00:00
1037b7c23d Merge branch 'master' of https://github.com/dolanmiu/docx 2018-01-24 00:04:29 +00:00
df197f73ea Create section properties section 2018-01-24 00:01:38 +00:00
ea08f603f5 Add build command before demos 2018-01-23 11:28:27 +00:00
fa2f1235f7 Run each demo in test 2018-01-23 11:24:44 +00:00
ff5d02c964 Add prettier badge 2018-01-23 01:36:27 +00:00
e93d6799fd Made project Prettier compliant 2018-01-23 01:33:12 +00:00
f2027230a0 Add prettier + style command 2018-01-22 23:38:49 +00:00
cb47d4f772 Merge pull request #55 from dolanmiu/feat/file-wrapper
Feat/file wrapper
2018-01-22 23:07:05 +00:00
eebc9fbcfa Merge pull request #51 from dolanmiu/feat/images
Feat/images support
2018-01-22 22:40:23 +00:00
0e698491f3 Merge pull request #52 from dolanmiu/feat/file-wrapper
Feat/file wrapper
2018-01-22 22:40:00 +00:00
ae52e8fabb Add gif support 2018-01-22 22:17:17 +00:00
ccd655ef8b Add support for jpg and bmp 2018-01-22 22:12:33 +00:00
3dc6e71aaf Add png support 2018-01-22 22:05:20 +00:00
e6d3577f74 Rename penguin 2018-01-22 21:34:09 +00:00
ef05024f2f Add image dimensions 2018-01-22 20:42:57 +00:00
d3bc784248 Add types to image-size 2018-01-22 20:42:33 +00:00
979701331e Install image-size 2018-01-22 19:34:30 +00:00
76b1682296 Put media in correct location 2018-01-22 00:53:22 +00:00
7c31b72f99 Got docx not crashing when adding image 2018-01-16 01:31:47 +00:00
f7c2072cff Progress on embeddding image 2018-01-16 00:43:00 +00:00
392db1cd11 Add more graphic files 2018-01-12 00:12:39 +00:00
ca244bcfe1 Add more files for creating a drawing 2018-01-11 01:47:09 +00:00
2d02f51f25 Offset reference id a little 2018-01-10 00:35:26 +00:00
592fb5ca9f Add dynamic relationships 2018-01-10 00:29:17 +00:00
a3945bc7f1 Media addMedia method 2018-01-09 21:57:10 +00:00
2adde9830c Add image demo 2018-01-09 21:54:48 +00:00
0355afe11c Rename IData to something more reasonable 2017-12-30 21:18:55 +00:00
998fe3f370 Made index into barrel and made seperate drawing file 2017-12-30 20:59:05 +00:00
eb71fc20e6 Use absolute path rather than silly relative path 2017-12-30 20:25:16 +00:00
ab348bd5f9 Add build before typedoc 2017-12-30 20:02:44 +00:00
c518d1c6c7 Fix tests using new mocha-webpack 2017-12-30 20:01:20 +00:00
d8d16b4a7d Absolute path imports! 2017-12-29 02:26:26 +00:00
928e4b9bc2 Turn off sourceRoot to hotfix typedoc 2017-12-29 02:06:44 +00:00
4f900d6566 Update typedoc 2017-12-29 02:05:34 +00:00
362a997187 Redundant library specification 2017-12-29 01:48:46 +00:00
89c658746d Use webpack as the main builder 2017-12-29 01:46:31 +00:00
75d699f7ef Enable dirname 2017-12-29 01:45:33 +00:00
f7412690b6 Fix library export 2017-12-29 01:36:42 +00:00
ece2b23407 Export as a library 2017-12-29 01:16:45 +00:00
f84af9a44b Move tsconfig files to root, and made webpack config build 2017-12-29 01:11:59 +00:00
90dc1103f6 Experimental webpack support 2017-12-22 16:49:25 +00:00
c469fb24db Fix imports 2017-12-20 01:41:53 +00:00
32be6e36da Add package-lock to ignore 2017-12-20 01:41:32 +00:00
b34ad22ad6 Add editorconfig 2017-12-20 01:40:52 +00:00
2358139a6b Change docx folder to more appropriate "file" folder 2017-12-20 01:03:20 +00:00
43ebfe7a2f Move properties to sub folder 2017-12-20 00:58:24 +00:00
0b8094dea8 Move styles to sub folder 2017-12-20 00:52:41 +00:00
f1d1570b10 Move relationships to sub folder 2017-12-20 00:09:01 +00:00
e9e68bc802 Move media to sub folder 2017-12-20 00:06:08 +00:00
4c369510ce Move numbering into sub folder 2017-12-20 00:01:23 +00:00
96413d6c47 Fix lint 2017-12-19 23:14:23 +00:00
df6c7cf19f Re-order package 2017-12-19 23:13:11 +00:00
49fc28d86c Updated demos 2017-12-19 21:49:44 +00:00
cc67a83ce8 For importing absolute path in future 2017-12-19 21:42:17 +00:00
742e2b5089 Make compiler take in a file 2017-12-15 02:15:44 +00:00
d19ff1e300 Add file class 2017-12-15 01:16:04 +00:00
01950ed443 Move ts to src folder for standards 2017-12-15 00:01:59 +00:00
cf1689a3c2 Version bump 2017-12-06 01:39:40 +00:00
66d0bab0a5 Add packPdf reference 2017-12-06 01:39:24 +00:00
5889f20f1e Simplify tests and made compile async 2017-12-06 01:32:57 +00:00
ebec10e312 Refactor 2017-12-06 01:03:14 +00:00
ae8a0c7fd0 Edit Tslint 2017-12-05 23:43:19 +00:00
bb49200fad Clean up code using request promise 2017-12-05 02:24:49 +00:00
a6bba0bc6c Enable pdf export 2017-12-05 00:16:21 +00:00
fb08f79344 Add initial conversion 2017-11-10 14:27:57 +00:00
741c74825e Class definition for Pdf converter wrapper 2017-09-30 18:23:02 +01:00
28539cd47b Initial scaffold of pdf convert 2017-09-30 18:15:33 +01:00
8ca7c5a343 Add test 2017-09-30 18:00:06 +01:00
32b56e7071 Move sub components of Paragraph into own folder 2017-09-30 01:52:37 +01:00
7dad717952 Add documentation links 2017-09-22 14:46:19 +01:00
34e928755f Add documentation links 2017-09-21 14:56:46 +01:00
51e0f311fe Refactor numbering into its own file 2017-09-20 13:37:39 +01:00
cc9dff6b94 Version bump 2017-09-19 16:02:32 +01:00
101cc0fdea Add docx keyword to package 2017-09-19 16:02:06 +01:00
d408262fa8 Remove unused class 2017-09-19 15:58:37 +01:00
ed53c30f42 Remove template file and placed in the Wiki
https://github.com/dolanmiu/docx/wiki/Contributing-Guidelines
2017-09-19 15:56:52 +01:00
ebbf6a99c1 Make exporting more consistent 2017-09-19 15:51:55 +01:00
b98c103e45 Export table into own file 2017-09-19 15:49:27 +01:00
518fec0595 Export like standard style 2017-09-19 15:47:29 +01:00
659936f3f0 Refactor xml component into own class 2017-09-19 15:46:20 +01:00
b0febf5054 Refactor run into own file 2017-09-19 15:42:40 +01:00
56b951a2b1 Refactor body into own file 2017-09-19 15:39:14 +01:00
a3a9958a69 Refactor document into own file 2017-09-19 15:36:41 +01:00
4f36bbf426 Refactor paragraph into its own file
Create barrel
2017-09-19 15:21:07 +01:00
357bc7f377 Add documentation reference 2017-09-19 15:17:58 +01:00
da8405b5b9 Add Right and Center tab stops 2017-09-19 12:51:37 +01:00
492face7ab 3.0.0 2017-09-17 00:20:18 +01:00
b6351f0260 Merge branch 'jacwright-indent-bc' 2017-09-17 00:09:57 +01:00
3a7f9053b9 Allow indent to use other options than left and hanging
This is a breaking change. Existing code using indent will break when padding in the number for left.
2017-09-16 17:05:40 -06:00
19b122684c Add lint to Travis
Fix linting
2017-09-17 00:01:09 +01:00
72e89cfc3c Move tests to respective folders as .spec
This is to keep to standards
2017-09-17 00:00:41 +01:00
5ae02c3342 Merge pull request #43 from jacwright/default-run-styles
Making it easier to work with default styles
2017-09-16 17:48:37 +01:00
258adba94c Version bump 2017-09-16 17:48:15 +01:00
190208d5df Making it easier to work with default styles
Adds the likely common styles, font and size, to be defined in defaults.
2017-09-16 08:24:15 -06:00
32cda4dfb3 Merge pull request #42 from jacwright/patch-1-test
Fix tests
2017-09-15 16:09:18 +01:00
b2c3dd2f7b Fix tests 2017-09-15 09:05:28 -06:00
58eca3ff5b Merge pull request #41 from jacwright/patch-1
Fix page/thematic breaks
2017-09-15 15:57:22 +01:00
d5c04f9042 Pin typescript to 2.4.1 2017-09-15 15:56:21 +01:00
67ea7c95de Just pagebreak, update test 2017-09-15 08:37:57 -06:00
e57fd8fc57 Fix page/thematic breaks
These items are not paragraph properties, but part of the content of the paragraph.
2017-09-15 08:25:43 -06:00
411c0dadb5 Add table demo 2017-07-29 01:58:29 +01:00
ee81f3c502 Version bump 2017-07-29 01:26:34 +01:00
8263b93c36 Add third demo 2017-07-29 01:26:04 +01:00
be709d082c Export formatting from paragraph folder 2017-07-29 01:15:33 +01:00
70c4e89a65 Version bump 2017-07-08 21:37:02 +01:00
8f632d4ecd Made XmlableObject non ambient typings to fix typescript problem 2017-07-08 20:45:19 +01:00
6784dc1f3d Updated archiver types 2017-07-08 01:24:25 +01:00
fd63a30298 Updated definitions 2017-07-07 16:51:22 +01:00
b0a29e26c9 Version bump 2017-07-07 14:36:34 +01:00
8826fb010d Added types to package json 2017-07-07 14:34:03 +01:00
97101adb10 Enabled declarations in tsconfig to be true 2017-07-07 14:31:08 +01:00
2ec171d4a8 Used my updated typings for archiver 1.3 2017-05-09 18:03:31 +01:00
8876bb1fea updated readme about demos 2017-04-17 19:53:53 +01:00
96ca9d9c23 commented out the rm 2017-04-17 16:36:56 +01:00
74a65f02fa remove exit code 2017-04-17 16:07:28 +01:00
339c017940 edited rm function 2017-04-17 15:41:03 +01:00
969b52ae05 added nojekyll to gh-pages 2017-04-17 13:24:43 +01:00
eb8f0f4033 added debugging to deployment 2017-04-17 13:05:02 +01:00
d7229eb049 removed rimraf 2017-04-16 12:41:24 +01:00
644819ed81 added deployment keys and scripts 2017-04-16 12:22:50 +01:00
96fd61d3e4 using stable version of node 2017-04-16 02:25:44 +01:00
b96cfe7b19 git fetch added 2017-04-16 01:29:29 +01:00
d0e7c97a88 added commit message with merge with gh pages 2017-04-16 01:18:22 +01:00
0ede54cfdc added travis doc deployment solution 2017-04-16 01:12:42 +01:00
5be1163549 remove docs in gitignore 2017-04-16 01:07:11 +01:00
580f6eb633 fixed tests 2017-04-16 00:44:35 +01:00
321be35918 added docs in gitignore 2017-04-16 00:30:27 +01:00
45a18742d7 moved documentation to gh-pages branch 2017-04-16 00:22:29 +01:00
7e81da404a updated readme 2017-04-16 00:09:07 +01:00
6c2abb4abc added typedoc generated docs 2017-04-16 00:07:16 +01:00
e8b0dbf93b added docs ignore to npmignore file 2017-04-16 00:04:29 +01:00
e59c255d85 added type to pack param 2017-04-15 23:45:27 +01:00
17b28cb724 fixed more linting issues 2017-04-15 20:11:54 +01:00
410152441b fixed tslinting issues 2017-04-15 17:54:47 +01:00
dfff4b96bd updated tslint to 5.1.0 2017-04-15 17:47:29 +01:00
72cb75a486 added comma 2017-04-15 17:46:56 +01:00
53fe1dd988 added typedoc support for generating documentation 2017-04-15 17:46:11 +01:00
043219f005 Merge pull request #32 from felipeochoa/keep-lines
add keepLines and keepNext support for paragraph formatting
2017-04-15 17:41:11 +01:00
0453f28951 add keepLines and keepNext support for paragraph formatting
This commit adds it to the three places where paragraph formatting can
be applied right now (directly on the paragraph, paragraph styles, and
bullets/numbering styles). I'm separately adding an entry to the wiki
regarding what these methods do (widow/orphan control)
2017-04-14 21:13:11 +02:00
94716e081b Merge pull request #31 from felipeochoa/spacing-bugfix
Spacing bugfix
2017-04-14 17:30:54 +01:00
30f826fd3d made a mini app which you can select the demo you want from a list with an interactive prompt. 2017-04-14 15:48:12 +01:00
99b7a03b8a update demo2 to test space preservation 2017-04-14 11:09:08 +02:00
b1c8b2beb8 add xml:space="preserve" to text runs
In MS Word 2015 (and possibly others), leading and trailing spaces are
ignored in text runs. This means that calling TextRun with
leading/trailing space would result in a document that didn't include
those spaces. The fix here (per http://officeopenxml.com/WPtext.php)
is to include an extra attribute on the "w:t" element that forces word
to recognize those spaces.
2017-04-14 11:08:19 +02:00
a706455a7c Merge pull request #30 from felipeochoa/overrides
Add support for numbering level overrides
2017-04-12 18:34:07 +01:00
8c388a95c4 bump patch version 2017-04-12 16:01:26 +02:00
9a41d78ecb add an additional demo 2017-04-12 16:00:16 +02:00
6fc4ad782a add #overrideLevel method to concrete numberings 2017-04-12 16:00:16 +02:00
16b9057ac6 prepare Level to be extended for overrides 2017-04-12 15:57:26 +02:00
662 changed files with 39841 additions and 5100 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

12
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: dolanmiu
patreon: dolanmiu
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

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

@ -0,0 +1,104 @@
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/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

28
.gitignore vendored
View File

@ -36,5 +36,29 @@ node_modules
build
build-tests
# vscode
.vscode
# Documentation
docs/api/
docs/.nojekyll
# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history
# IntelliJ
.idea
# Lock files
yarn.lock
# Documents
My Document.docx
# Temporary folder
tmp
# nyc
.nyc_output

View File

@ -38,3 +38,6 @@ build-tests
# vscode
.vscode
# docs
docs

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v10

26
.nycrc Normal file
View File

@ -0,0 +1,26 @@
{
"check-coverage": true,
"lines": 96.81,
"functions": 93.80,
"branches": 92.63,
"statements": 96.80,
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.spec.ts",
"src/import-dotx/import-dotx.ts"
],
"reporter": [
"lcov",
"text",
"json"
],
"extension": [
".ts"
],
"cache": true,
"all": true,
"instrument": false,
"sourceMap": true
}

5
.prettierrc.yml Normal file
View File

@ -0,0 +1,5 @@
trailingComma: all
printWidth: 140
tabWidth: 4
arrowParens: always
bracketSpacing: true

View File

@ -1,10 +1,63 @@
language: node_js
node_js:
- "6"
- "node"
- 10
install:
- npm install
- npm install -g codecov
script:
- npm test
after_failure:
- "cat /home/travis/builds/dolanmiu/docx/npm-debug.log"
- npm run lint
- npm run test.coverage
- npm run style
- npm run build
- npm run ts-node -- ./demo/1-basic.ts
# - npm run e2e "My Document.docx"
- 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 e2e "My Document.docx"
- 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/demo25.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 e2e "My Document.docx" // Need to fix
- npm run ts-node -- ./demo/33-sequential-captions.ts
- npm run ts-node -- ./demo/34-floating-tables.ts
after_failure:
- "cat /home/travis/builds/dolanmiu/docx/npm-debug.log"
after_success:
- npm run typedoc
- echo "docx.js.org" > docs/.nojekyll
- echo "docx.js.org" > docs/CNAME
- codecov
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
local-dir: docs
on:
branch: master

9
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"cSpell.words": ["clippy", "docx", "dolan", "miu", "officegen", "typedoc"],
"prettier.trailingComma": "all",
"prettier.printWidth": 140,
"editor.formatOnSave": false,
"prettier.tabWidth": 4,
"prettier.arrowParens": "always",
"prettier.bracketSpacing": true
}

24
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"option": "watch",
"problemMatcher": [
"$tsc-watch"
]
},
{
"type": "npm",
"script": "ts-node",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

129
README.md
View File

@ -1,85 +1,122 @@
<p align="center">
<img alt="clippy the assistant" src="http://i60.tinypic.com/339pvtt.png">
<img alt="clippy the assistant" src="https://i.imgur.com/37uBGhO.gif">
</p>
<p align="center">
Generate .docx files with JS/TS very easily, written in TS.
Easily generate .docx files with JS/TS. Works for Node and on the Browser.
</p>
-----
---
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][gemnasium-image]][gemnasium-url] [![Known Vulnerabilities][snky-image]][snky-url] [![Chat on Gitter][gitter-image]][gitter-url]
[![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]
[![PRs Welcome][pr-image]][pr-url]
[![codecov][codecov-image]][codecov-url]
[![NPM](https://nodei.co/npm/docx.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/docx/)
<p align="center">
<img src="https://i.imgur.com/TCH0YzD.png" alt="drawing" width="800"/>
</p>
# docx
# Demo
## Install
## Browser
```sh
$ npm install --save docx
```
Here are examples of `docx` being used with basic `HTML/JS` in a browser environment:
## Demo
* https://codepen.io/dolanmiu/pen/RwNeObg
* https://jsfiddle.net/dolanmiu/kqxrj35u/1/
```sh
$ npm run demo
```
Here is an example of `docx` working in `Angular`:
will run the demo app in the `demo` folder, which creates a file called "My Document.docx" in the root of the project
* https://stackblitz.com/edit/angular-afvxtz
## Guide
Here is an example of `docx` working in `React`:
Please refer to [the Wiki](https://github.com/dolanmiu/docx/wiki) for details on how to use this library, examples and much more!
* https://stackblitz.com/edit/react-ts-qq25sp
* https://stackblitz.com/edit/react-ts-qdqu7z (adding images to Word Document)
## Simple Usage
Here is an example of `docx` working in `Vue.js`:
```js
// Used to create docx files
var docx = require('docx');
* https://stackblitz.com/edit/vuejs-docx
// Create document
var doc = new docx.Document();
## Node
// Add some content in the document
var paragraph = new docx.Paragraph("Some cool text here.");
// Add more text into the paragraph if you wish
paragraph.addRun(new docx.TextRun('Lorem Ipsum Foo Bar'));
doc.addParagraph(paragraph);
Press `endpoint` on the `RunKit` website:
// Used to export the file into a .docx file
var exporter = new docx.LocalPacker(doc);
![RunKit Instructions](https://user-images.githubusercontent.com/2917613/38582539-f84311b6-3d07-11e8-90db-5885ae02c3c4.png)
// Or use the express packer to make the file downloadable.
// res is express' Response object
var exporter = new docx.ExpressPacker(doc, res);
* https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
* https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
* https://runkit.com/dolanmiu/docx-demo3 - Bullet points
* https://runkit.com/dolanmiu/docx-demo4 - Simple table
* https://runkit.com/dolanmiu/docx-demo5 - Images
* https://runkit.com/dolanmiu/docx-demo6 - Margins
* https://runkit.com/dolanmiu/docx-demo7 - Landscape
* https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
exporter.pack('My First Document');
More [here](https://github.com/dolanmiu/docx/tree/master/demo)
// done! A file called 'My First Document.docx'
// will be in your file system if you used LocalPacker
// Or it will start downloading if you are using Express
```
# How to use & Documentation
## Examples
Check [the Wiki](https://github.com/dolanmiu/docx/wiki/Examples) for examples.
Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/) for details on how to use this library, examples and much more!
-----
# Examples
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
# Contributing
Read the contribution guidelines [here](https://docx.js.org/#/contribution-guidelines).
# Used by
[<img src="https://i.imgur.com/zy5qWmI.png" alt="drawing" height="50"/>](https://hfour.com/)
[<img src="https://i.imgur.com/OYP5tgS.png" alt="drawing" height="50"/>](https://fuzzproductions.com/)
[<img src="https://i.imgur.com/zUDMfZ3.png" alt="drawing" height="50"/>](https://www.mettzer.com/)
[<img src="https://i.imgur.com/wtNB1uq.png" alt="drawing" height="50"/>](https://www.wisedoc.net/)
[<img src="https://i.imgur.com/suiH2zc.png" alt="drawing" height="50"/>](https://www.dabblewriter.com/)
[<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/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/)
...and many more!
---
[![patreon][patreon-image]][patreon-url]
[![browserstack][browserstack-image]][browserstack-url]
Made with 💖
Huge thanks to [@felipeochoa](https://github.com/felipeochoa) for awesome contributions to this project
[npm-image]: https://badge.fury.io/js/docx.svg
[npm-url]: https://npmjs.org/package/docx
[downloads-image]: https://img.shields.io/npm/dm/docx.svg
[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
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
[gitter-image]: https://badges.gitter.im/dolanmiu/docx.svg
[gitter-url]: https://gitter.im/docx-lib/Lobby
[gemnasium-image]: https://gemnasium.com/badges/github.com/dolanmiu/docx.svg
[gemnasium-url]: https://gemnasium.com/github.com/dolanmiu/docx
[pr-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[pr-url]: http://makeapullrequest.com
[codecov-image]: https://codecov.io/gh/dolanmiu/docx/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/dolanmiu/docx
[patreon-image]: https://user-images.githubusercontent.com/2917613/51251459-4e880480-1991-11e9-92bf-38b96675a9e2.png
[patreon-url]: https://www.patreon.com/dolanmiu
[browserstack-image]: https://user-images.githubusercontent.com/2917613/54233552-128e9d00-4505-11e9-88fb-025a4e04007c.png
[browserstack-url]: https://www.browserstack.com

29
demo/1-basic.ts Normal file
View File

@ -0,0 +1,29 @@
// 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, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
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,
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

344
demo/10-my-cv.ts Normal file
View File

@ -0,0 +1,344 @@
// Generate a CV
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
// tslint:disable:no-shadowed-variable
const PHONE_NUMBER = "07534563401";
const PROFILE_URL = "https://www.linkedin.com/in/dolan1";
const EMAIL = "docx@com";
const experiences = [
{
isCurrent: true,
summary: "Full-stack developer working with Angular and Java. Working for the iShares platform",
title: "Associate Software Developer",
startDate: {
month: 11,
year: 2017,
},
company: {
name: "BlackRock",
},
},
{
isCurrent: false,
summary:
"Full-stack developer working with Angular, Node and TypeScript. Working for the iShares platform. Emphasis on Dev-ops and developing the continous integration pipeline.",
title: "Software Developer",
endDate: {
month: 11,
year: 2017,
},
startDate: {
month: 10,
year: 2016,
},
company: {
name: "Torch Markets",
},
},
{
isCurrent: false,
summary:
"Used ASP.NET MVC 5 to produce a diversity data collection tool for the future of British television.\n\nUsed AngularJS and C# best practices. Technologies used include JavaScript, ASP.NET MVC 5, SQL, Oracle, SASS, Bootstrap, Grunt.",
title: "Software Developer",
endDate: {
month: 10,
year: 2016,
},
startDate: {
month: 3,
year: 2015,
},
company: {
name: "Soundmouse",
},
},
{
isCurrent: false,
summary:
"Develop web commerce platforms for various high profile clients.\n\nCreated a log analysis web application with the Play Framework in Java, incorporating Test Driven Development. It asynchronously uploads and processes large (2 GB) log files, and outputs meaningful results in context with the problem. \n\nAnalysis and development of the payment system infrastructure and user accounts section to be used by several clients of the company such as Waitrose, Tally Weijl, DJ Sports, Debenhams, Ann Summers, John Lewis and others.\n\nTechnologies used include WebSphere Commerce, Java, JavaScript and JSP.",
title: "Java Developer",
endDate: {
month: 10,
year: 2014,
},
startDate: {
month: 3,
year: 2013,
},
company: {
name: "Soundmouse",
},
},
];
const education = [
{
degree: "Master of Science (MSc)",
fieldOfStudy: "Computer Science",
notes:
"Exam Results: 1st Class with Distinction, Dissertation: 1st Class with Distinction\n\nRelevant Courses: Java and C# Programming, Software Engineering, Artificial Intelligence, \nComputational Photography, Algorithmics, Architecture and Hardware.\n\nCreated a Windows 8 game in JavaScript for the dissertation. \n\nCreated an award-winning 3D stereoscopic game in C# using XNA.",
schoolName: "University College London",
startDate: {
year: 2012,
},
endDate: {
year: 2013,
},
},
{
degree: "Bachelor of Engineering (BEng)",
fieldOfStudy: "Material Science and Engineering",
notes:
"Exam Results: 2:1, Dissertation: 1st Class with Distinction\n\nRelevant courses: C Programming, Mathematics and Business for Engineers.",
schoolName: "Imperial College London",
startDate: {
year: 2009,
},
endDate: {
year: 2012,
},
},
];
const skills = [
{
name: "Angular",
},
{
name: "TypeScript",
},
{
name: "JavaScript",
},
{
name: "NodeJS",
},
];
const achievements = [
{
issuer: "Oracle",
name: "Oracle Certified Expert",
},
];
class DocumentCreator {
// tslint:disable-next-line: typedef
public create([experiences, educations, skills, achivements]): Document {
const document = new Document();
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));
});
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));
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
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 document;
}
public createContactInfo(phoneNumber: string, profileUrl: string, email: string): Paragraph {
return new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`),
new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break(),
],
});
}
public createHeading(text: string): Paragraph {
return new Paragraph({
text: text,
heading: HeadingLevel.HEADING_1,
thematicBreak: true,
});
}
public createSubHeading(text: string): Paragraph {
return new Paragraph({
text: text,
heading: HeadingLevel.HEADING_2,
});
}
public createInstitutionHeader(institutionName: string, dateText: string): Paragraph {
return new Paragraph({
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
],
children: [
new TextRun({
text: institutionName,
bold: true,
}),
new TextRun({
text: `\t${dateText}`,
bold: true,
}),
],
});
}
public createRoleText(roleText: string): Paragraph {
return new Paragraph({
children: [
new TextRun({
text: roleText,
italics: true,
}),
],
});
}
public createBullet(text: string): Paragraph {
return new Paragraph({
text: text,
bullet: {
level: 0,
},
});
}
// tslint:disable-next-line:no-any
public createSkillList(skills: any[]): Paragraph {
return new Paragraph({
children: [new TextRun(skills.map((skill) => skill.name).join(", ") + ".")],
});
}
// tslint:disable-next-line:no-any
public createAchivementsList(achivements: any[]): Paragraph[] {
return achivements.map(
(achievement) =>
new Paragraph({
text: achievement.name,
bullet: {
level: 0,
},
}),
);
}
public createInterests(interests: string): Paragraph {
return new Paragraph({
children: [new TextRun(interests)],
});
}
public splitParagraphIntoBullets(text: string): string[] {
return text.split("\n\n");
}
// tslint:disable-next-line:no-any
public createPositionDateText(startDate: any, endDate: any, isCurrent: boolean): string {
const startDateText = this.getMonthFromInt(startDate.month) + ". " + startDate.year;
const endDateText = isCurrent ? "Present" : `${this.getMonthFromInt(endDate.month)}. ${endDate.year}`;
return `${startDateText} - ${endDateText}`;
}
public getMonthFromInt(value: number): string {
switch (value) {
case 1:
return "Jan";
case 2:
return "Feb";
case 3:
return "Mar";
case 4:
return "Apr";
case 5:
return "May";
case 6:
return "Jun";
case 7:
return "Jul";
case 8:
return "Aug";
case 9:
return "Sept";
case 10:
return "Oct";
case 11:
return "Nov";
case 12:
return "Dec";
default:
return "N/A";
}
}
}
const documentCreator = new DocumentCreator();
const doc = documentCreator.create([experiences, education, skills, achievements]);
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,263 @@
// Setting styles with JavaScript configuration
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
AlignmentType,
Document,
Footer,
HeadingLevel,
Media,
Packer,
Paragraph,
Table,
TableCell,
TableRow,
TabStopPosition,
UnderlineType,
} from "../build";
const doc = new Document({
styles: {
paragraphStyles: [
{
id: "Heading1",
name: "Heading 1",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 52,
bold: true,
color: "000000",
underline: {
type: UnderlineType.SINGLE,
color: "000000",
},
},
paragraph: {
alignment: AlignmentType.CENTER,
spacing: { line: 340 },
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 26,
bold: true,
},
paragraph: {
spacing: { line: 340 },
},
},
{
id: "Heading3",
name: "Heading 3",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 26,
bold: true,
},
paragraph: {
spacing: { line: 276 },
},
},
{
id: "Heading4",
name: "Heading 4",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 26,
bold: true,
},
paragraph: {
alignment: AlignmentType.JUSTIFIED,
},
},
{
id: "normalPara",
name: "Normal Para",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 26,
bold: true,
},
paragraph: {
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
rightTabStop: TabStopPosition.MAX,
leftTabStop: 453.543307087,
},
},
{
id: "normalPara2",
name: "Normal Para2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "Calibri",
size: 26,
},
paragraph: {
alignment: AlignmentType.JUSTIFIED,
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
},
},
{
id: "aside",
name: "Aside",
basedOn: "Normal",
next: "Normal",
run: {
color: "999999",
italics: true,
},
paragraph: {
spacing: { line: 276 },
indent: { left: 720 },
},
},
{
id: "wellSpaced",
name: "Well Spaced",
basedOn: "Normal",
paragraph: {
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.")],
}),
],
}),
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",
style: "normalPara",
alignment: AlignmentType.RIGHT,
}),
],
}),
},
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",
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

19
demo/12-scaling-images.ts Normal file
View File

@ -0,0 +1,19 @@
// 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";
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)],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

32
demo/13-xml-styles.ts Normal file
View File

@ -0,0 +1,32 @@
// This example shows 3 styles using XML styles
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
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",
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

47
demo/14-page-numbers.ts Normal file
View File

@ -0,0 +1,47 @@
// 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";
const doc = new Document();
doc.addSection({
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"),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,20 @@
// Page break before example
// Import from 'docx' rather than '../build' if you install from npm
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,
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,124 @@
// Multiple sections and headers
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Footer, Header, Packer, PageNumber, PageNumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
const doc = new Document();
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 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 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({
children: [
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
}),
],
}),
],
}),
},
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."),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

55
demo/17-footnotes.ts Normal file
View File

@ -0,0 +1,55 @@
// Footnotes
// Import from 'docx' rather than '../build' if you install from npm
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({
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(1)],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(2)],
}),
],
}),
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
}),
],
});
doc.addSection({
children: [
new Paragraph({
children: [
new TextRun({
children: ["Hello", new FootnoteReferenceRun(4)],
}),
new TextRun({
children: [" World!", new FootnoteReferenceRun(5)],
}),
],
}),
new Paragraph({
children: [new TextRun("Hello World"), new FootnoteReferenceRun(6)],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,22 @@
// 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();
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],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,28 @@
// Export to base64 string - Useful in a browser environment.
// 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();
doc.addSection({
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo",
bold: true,
}),
new TextRun({
text: "\tBar",
bold: true,
}),
],
}),
],
});
Packer.toBase64String(doc).then((str) => {
fs.writeFileSync("My Document.docx", str);
});

View File

@ -0,0 +1,178 @@
// 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";
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,
run: {
size: 28,
bold: true,
italics: true,
color: "red",
},
paragraph: {
spacing: {
after: 120,
},
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
size: 26,
bold: true,
underline: {
type: UnderlineType.DOUBLE,
color: "FF0000",
},
},
paragraph: {
spacing: {
before: 240,
after: 120,
},
},
},
{
id: "aside",
name: "Aside",
basedOn: "Normal",
next: "Normal",
run: {
color: "999999",
italics: true,
},
paragraph: {
indent: {
left: 720,
},
spacing: {
line: 276,
},
},
},
{
id: "wellSpaced",
name: "Well Spaced",
basedOn: "Normal",
quickFormat: true,
paragraph: {
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
},
},
{
id: "ListParagraph",
name: "List Paragraph",
basedOn: "Normal",
quickFormat: true,
},
],
},
numbering: {
config: [
{
reference: "my-crazy-numbering",
levels: [
{
level: 0,
format: "lowerLetter",
text: "%1)",
alignment: AlignmentType.LEFT,
},
],
},
],
},
});
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({
children: [
new TextRun({
text: "Some monospaced content",
font: {
name: "Monospace",
},
}),
],
}),
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.",
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,103 @@
// Add custom borders to table cell
// 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();
const table = 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: [],
}),
],
}),
],
});
doc.addSection({ children: [table] });
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

40
demo/21-bookmarks.ts Normal file
View File

@ -0,0 +1,40 @@
// 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";
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.";
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,
},
},
});
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")],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,44 @@
// 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";
const doc = new Document();
doc.addSection({
children: [
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,
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

32
demo/23-base64-images.ts Normal file
View File

@ -0,0 +1,32 @@
// 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"));
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),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,85 @@
// 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";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const table = 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(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,33 @@
// Creates two paragraphs, one with a border and one without
// Import from 'docx' rather than '../build' if you install from npm
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,
},
},
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,67 @@
// 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";
const doc = new Document({
styles: {
paragraphStyles: [
{
id: "myWonkyStyle",
name: "My Wonky Style",
basedOn: "Normal",
next: "Normal",
run: {
color: "990000",
italics: true,
},
paragraph: {
indent: {
left: 720,
},
spacing: {
line: 276,
},
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
bold: true,
size: 26,
underline: {
type: UnderlineType.DOUBLE,
color: "FF0000",
},
},
paragraph: {
spacing: {
before: 240,
after: 120,
},
},
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "Hello",
style: "myWonkyStyle",
}),
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_2,
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,64 @@
// Table of contents
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "../build";
const doc = new File({
styles: {
paragraphStyles: [
{
id: "MySpectacularStyle",
name: "My Spectacular Style",
basedOn: "Heading1",
next: "Heading1",
quickFormat: true,
run: {
italics: true,
color: "990000",
},
},
],
},
});
// 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,
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

117
demo/29-numbered-lists.ts Normal file
View File

@ -0,0 +1,117 @@
// Numbered lists
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { AlignmentType, Document, Packer, Paragraph } from "../build";
const doc = new Document({
numbering: {
config: [
{
levels: [
{
level: 0,
format: "upperRoman",
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
},
},
},
],
reference: "my-crazy-reference",
},
{
levels: [
{
level: 0,
format: "decimal",
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
},
},
},
],
reference: "my-number-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,
},
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,142 @@
// 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";
const doc = new Document({
numbering: {
config: [
{
reference: "my-crazy-numbering",
levels: [
{
level: 0,
format: "upperRoman",
text: "%1",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 720, hanging: 260 },
},
},
},
{
level: 1,
format: "decimal",
text: "%2.",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 1440, hanging: 980 },
},
},
},
{
level: 2,
format: "lowerLetter",
text: "%3)",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 2160, hanging: 1700 },
},
},
},
{
level: 3,
format: "upperLetter",
text: "%4)",
alignment: AlignmentType.START,
style: {
paragraph: {
indent: { left: 2880, hanging: 2420 },
},
},
},
],
},
],
},
});
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,
},
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,30 @@
// Example on how to use a template document
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, ImportDotx, Packer, Paragraph } from "../build";
const importDotx = new ImportDotx();
const filePath = "./demo/dotx/template.dotx";
fs.readFile(filePath, (err, data) => {
if (err) {
throw new Error(`Failed to read file ${filePath}.`);
}
importDotx.extract(data).then((templateDocument) => {
const doc = new Document(undefined, {
template: templateDocument,
});
doc.addSection({
properties: {
titlePage: templateDocument.titlePageIsDefined,
},
children: [new Paragraph("Hello World")],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
});
});

76
demo/31-tables.ts Normal file
View File

@ -0,0 +1,76 @@
// 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, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build";
const doc = new Document();
const table = 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,
}),
],
}),
],
});
doc.addSection({
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,397 @@
// Example of how you would merge cells together (Rows and Columns) and apply shading
// 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, BorderStyle, Document, HeadingLevel, Packer, Paragraph, ShadingType, Table, TableCell, TableRow, WidthType } from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Hello")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
});
const table2 = new Table({
alignment: AlignmentType.CENTER,
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("World")],
margins: {
top: 1000,
bottom: 1000,
left: 1000,
right: 1000,
},
columnSpan: 3,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
width: {
size: 100,
type: WidthType.AUTO,
},
columnWidths: [1000, 1000, 1000],
});
const table3 = new Table({
alignment: AlignmentType.CENTER,
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Foo")],
}),
new TableCell({
children: [new Paragraph("v")],
columnSpan: 3,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Bar1")],
shading: {
fill: "b79c2f",
val: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "auto",
},
}),
new TableCell({
children: [new Paragraph("Bar2")],
shading: {
fill: "42c5f4",
val: ShadingType.PERCENT_95,
color: "auto",
},
}),
new TableCell({
children: [new Paragraph("Bar3")],
shading: {
fill: "880aa8",
val: ShadingType.PERCENT_10,
color: "e2df0b",
},
}),
new TableCell({
children: [new Paragraph("Bar4")],
shading: {
fill: "FF0000",
val: ShadingType.CLEAR,
color: "auto",
},
}),
],
}),
],
width: {
size: 7000,
type: WidthType.DXA,
},
margins: {
top: 400,
bottom: 400,
right: 400,
left: 400,
},
});
const table4 = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("0,0")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("1,0")],
}),
new TableCell({
children: [new Paragraph("1,1")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("2,0")],
columnSpan: 2,
}),
],
}),
],
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
});
const table5 = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("0,0")],
}),
new TableCell({
children: [new Paragraph("0,1")],
rowSpan: 2,
}),
new TableCell({
children: [new Paragraph("0,2")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("1,0")],
}),
new TableCell({
children: [new Paragraph("1,2")],
rowSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("2,0")],
}),
new TableCell({
children: [new Paragraph("2,1")],
}),
],
}),
],
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
});
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")],
}),
],
}),
new TableRow({
children: [
new TableCell({
borders,
children: [new Paragraph("1,1")],
rowSpan: 2,
}),
],
}),
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,
},
});
doc.addSection({
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,
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,47 @@
// Sequential Captions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build";
const doc = new Document();
doc.addSection({
children: [
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"),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,62 @@
// Example of how you would create a table with float positions
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import {
Document,
OverlapType,
Packer,
Paragraph,
RelativeHorizontalPosition,
RelativeVerticalPosition,
Table,
TableAnchorType,
TableCell,
TableLayoutType,
TableRow,
WidthType,
} from "../build";
const doc = new Document();
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Hello")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
float: {
horizontalAnchor: TableAnchorType.MARGIN,
verticalAnchor: TableAnchorType.MARGIN,
relativeHorizontalPosition: RelativeHorizontalPosition.RIGHT,
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
overlap: OverlapType.NEVER,
},
width: {
size: 4535,
type: WidthType.DXA,
},
layout: TableLayoutType.FIXED,
});
doc.addSection({
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

36
demo/35-hyperlinks.ts Normal file
View File

@ -0,0 +1,36 @@
// 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";
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,
},
},
});
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")],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,72 @@
// 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"));
const table = 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(image)],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
});
// Adding same table in the body and in the header
doc.addSection({
headers: {
default: new Header({
children: [table],
}),
},
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,22 @@
// 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";
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")],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

45
demo/38-text-wrapping.ts Normal file
View File

@ -0,0 +1,45 @@
// Example of how to "wrap" text around an image
// 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";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 2014400,
},
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),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

69
demo/39-page-numbers.ts Normal file
View File

@ -0,0 +1,69 @@
// Example how to display page numbers
// Import from 'docx' rather than '../build' if you install from npm
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({
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,
children: [
new TextRun("Foo Bar corp. "),
new TextRun({
children: ["Page Number: ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES],
}),
],
}),
],
}),
},
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()],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

39
demo/4-basic-table.ts Normal file
View File

@ -0,0 +1,39 @@
// 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();
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Hello")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("World")],
}),
],
}),
],
});
doc.addSection({
children: [table],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

29
demo/40-line-numbers.ts Normal file
View File

@ -0,0 +1,29 @@
// Example demonstrating line numbers.
// Import from 'docx' rather than '../build' if you install from npm
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.",
),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,261 @@
// Multiple cells merging in the same table - Rows and Columns
// 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();
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("0,0")],
}),
new TableCell({
children: [new Paragraph("0,1")],
columnSpan: 2,
}),
new TableCell({
children: [new Paragraph("0,3")],
}),
new TableCell({
children: [new Paragraph("0,4")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("1,0")],
columnSpan: 2,
}),
new TableCell({
children: [new Paragraph("1,2")],
columnSpan: 2,
}),
new TableCell({
children: [new Paragraph("1,4")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("2,0")],
}),
new TableCell({
children: [new Paragraph("2,1")],
columnSpan: 2,
}),
new TableCell({
children: [new Paragraph("2,3")],
}),
new TableCell({
children: [new Paragraph("2,4")],
columnSpan: 2,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("3,0")],
}),
new TableCell({
children: [new Paragraph("3,1")],
}),
new TableCell({
children: [new Paragraph("3,2")],
}),
new TableCell({
children: [new Paragraph("3,3")],
}),
new TableCell({
children: [new Paragraph("3,4")],
}),
new TableCell({
children: [new Paragraph("3,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("4,0")],
columnSpan: 5,
}),
new TableCell({
children: [new Paragraph("4,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
});
const table2 = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("0,0")],
}),
new TableCell({
children: [new Paragraph("0,1")],
rowSpan: 2,
}),
new TableCell({
children: [new Paragraph("0,2")],
}),
new TableCell({
children: [new Paragraph("0,3")],
}),
new TableCell({
children: [new Paragraph("0,4")],
}),
new TableCell({
children: [new Paragraph("0,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("1,0")],
}),
new TableCell({
children: [new Paragraph("1,2")],
}),
new TableCell({
children: [new Paragraph("1,3")],
}),
new TableCell({
children: [new Paragraph("1,4")],
}),
new TableCell({
children: [new Paragraph("1,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("2,0")],
}),
new TableCell({
children: [new Paragraph("2,1")],
}),
new TableCell({
children: [new Paragraph("2,2")],
}),
new TableCell({
children: [new Paragraph("2,3")],
}),
new TableCell({
children: [new Paragraph("2,4")],
}),
new TableCell({
children: [new Paragraph("2,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("3,0")],
}),
new TableCell({
children: [new Paragraph("3,1")],
}),
new TableCell({
children: [new Paragraph("3,2")],
}),
new TableCell({
children: [new Paragraph("3,3")],
}),
new TableCell({
children: [new Paragraph("3,4")],
}),
new TableCell({
children: [new Paragraph("3,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [new Paragraph("4,0")],
}),
new TableCell({
children: [new Paragraph("4,1")],
}),
new TableCell({
children: [new Paragraph("4,2")],
}),
new TableCell({
children: [new Paragraph("4,3")],
}),
new TableCell({
children: [new Paragraph("4,4")],
}),
new TableCell({
children: [new Paragraph("4,5")],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
new TableCell({
children: [],
}),
],
}),
],
});
doc.addSection({
children: [table, new Paragraph(""), table2],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,84 @@
// Add image to table cell
// 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();
const table = 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 TableCell({
children: [],
}),
new TableCell({
children: [],
rowSpan: 2,
}),
],
}),
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,40 @@
// Sections with multiple columns
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addSection({
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.",
),
],
});
doc.addSection({
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.",
),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,35 @@
// Highlighting text
// Import from 'docx' rather than '../build' if you install from npm
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,
children: [
new TextRun({
text: "Hello World",
color: "red",
bold: true,
size: 24,
font: {
name: "Garamond",
},
highlight: "yellow",
}),
],
}),
],
}),
},
children: [],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

51
demo/46-shading-text.ts Normal file
View File

@ -0,0 +1,51 @@
// Shading text
// Import from 'docx' rather than '../build' if you install from npm
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,
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.DIAGONAL_CROSS,
color: "00FFFF",
fill: "FF0000",
},
children: [
new TextRun({
text: "Hello World for entire paragraph",
}),
],
}),
],
}),
},
children: [],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,67 @@
// Multiple sections with total number of pages in each section
// Import from 'docx' rather than '../build' if you install from npm
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({
children: [
new TextRun("Header on another page"),
new TextRun({
children: ["Page number: ", PageNumber.CURRENT],
}),
new TextRun({
children: [" to ", PageNumber.TOTAL_PAGES_IN_SECTION],
}),
],
alignment: AlignmentType.CENTER,
}),
],
});
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()],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

31
demo/48-vertical-align.ts Normal file
View File

@ -0,0 +1,31 @@
// Example of making content of section vertically aligned
// Import from 'docx' rather than '../build' if you install from npm
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({
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);
});

37
demo/49-table-borders.ts Normal file
View File

@ -0,0 +1,37 @@
// Add custom 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();
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("Hello")],
}),
new TableCell({
children: [],
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [],
}),
new TableCell({
children: [new Paragraph("World")],
}),
],
}),
],
});
doc.addSection({ children: [table] });
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

62
demo/5-images.ts Normal file
View File

@ -0,0 +1,62 @@
// 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,
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,
},
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),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

61
demo/50-readme-demo.ts Normal file
View File

@ -0,0 +1,61 @@
// 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, 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"));
const table = new Table({
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph(image1)],
verticalAlign: VerticalAlign.CENTER,
}),
new TableCell({
children: [
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
],
verticalAlign: VerticalAlign.CENTER,
}),
],
}),
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_1,
}),
],
}),
new TableCell({
children: [new Paragraph(image1)],
}),
],
}),
],
});
doc.addSection({
children: [
new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}),
table,
new Paragraph(image2),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,37 @@
// Custom character styles using JavaScript configuration
// 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({
styles: {
characterStyles: [
{
id: "myRedStyle",
name: "My Wonky Style",
basedOn: "Normal",
run: {
color: "990000",
italics: true,
},
},
],
},
});
doc.addSection({
children: [
new Paragraph({
children: [
new TextRun({
text: "Foo bar",
style: "myRedStyle",
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

37
demo/52-japanese.ts Normal file
View File

@ -0,0 +1,37 @@
// Japanese text - Need to use a Japanese font
// Import from 'docx' rather than '../build' if you install from npm
import * as fs from "fs";
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
const doc = new Document({
styles: {
paragraphStyles: [
{
id: "Normal",
name: "Normal",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: "MS Gothic",
},
},
],
},
});
doc.addSection({
children: [
new Paragraph({
text: "KFCを食べるのが好き",
heading: HeadingLevel.HEADING_1,
}),
new Paragraph({
text: "こんにちは",
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

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

@ -0,0 +1,55 @@
// 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: {
paragraphStyles: [
{
id: "Normal",
name: "Normal",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
font: {
ascii: "Times",
eastAsia: "KaiTi",
},
},
},
],
},
});
doc.addSection({
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
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

145
demo/54-track-revisions.ts Normal file
View File

@ -0,0 +1,145 @@
// 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 doc = new Document({
footnotes: [
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,
},
});
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",
}),
],
});
doc.addSection({
properties: {},
children: [
paragraph,
new Paragraph({
children: [
new TextRun("This is a demo "),
new DeletedTextRun({
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",
}).break(),
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);
});

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

@ -0,0 +1,294 @@
// 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();
doc.addSection({
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,33 @@
// 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",
},
});
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,
}),
],
}),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

40
demo/6-page-borders.ts Normal file
View File

@ -0,0 +1,40 @@
// Example of how to change page borders
// 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();
doc.addSection({
margins: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo bar",
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"),
],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

17
demo/7-landscape.ts Normal file
View File

@ -0,0 +1,17 @@
// Example of how to set the document to landscape
// Import from 'docx' rather than '../build' if you install from npm
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")],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

24
demo/8-header-footer.ts Normal file
View File

@ -0,0 +1,24 @@
// Add text to 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();
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")],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

View File

@ -0,0 +1,35 @@
// 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";
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],
}),
],
}),
},
footers: {
default: new Footer({
children: [
new Paragraph({
children: [image2],
}),
],
}),
},
children: [new Paragraph("Hello World")],
});
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});

File diff suppressed because one or more lines are too long

45
demo/browser-demo.html Normal file
View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<script src="../build/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
</head>
<body>
<h1>DOCX browser Word document generation</h1>
<button type="button" onclick="generate()">Click to generate document</button>
<script>
function generate() {
const doc = new docx.Document();
doc.addSection({
children: [
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");
console.log("Document created successfully");
});
}
</script>
</body>
</html>

View File

@ -1,22 +0,0 @@
const docx = require('../build');
var doc = new docx.Document();
var paragraph = new docx.Paragraph("Hello World");
var institutionText = new docx.TextRun("University College London").bold();
var dateText = new docx.TextRun("5th Dec 2015").tab().bold();
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
doc.addParagraph(paragraph);
// Feature coming soon
// var media = new docx.Media();
// media.addMedia("happy-penguins", "./demo/penguins.jpg");
// var pictureRun = new docx.PictureRun(media.getMedia("happy-penguins"));
// var exporter = new docx.LocalPacker(doc);
var exporter = new docx.LocalPacker(doc);
exporter.pack('My Document');
console.log('Document created succesfully at project root!');

BIN
demo/dotx/template.dotx Normal file

Binary file not shown.

BIN
demo/images/cat.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

BIN
demo/images/dog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View File

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

BIN
demo/images/parrots.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 KiB

BIN
demo/images/pizza.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

37
demo/index.ts Normal file
View File

@ -0,0 +1,37 @@
// tslint:disable:no-console
import * as fs from "fs";
import * as prompt from "prompt";
import * as shelljs from "shelljs";
console.log("What demo do you wish to run? (Enter a number)");
const schema = {
properties: {
number: {
pattern: /^[0-9]+$/,
message: "Please enter a number.",
required: true,
},
},
};
prompt.start();
prompt.get(schema, (_, result) => {
const demoNumber = result.number;
const files = fs.readdirSync("./demo").filter((fn) => fn.startsWith(demoNumber));
if (files.length === 0) {
console.error(`demo number ${demoNumber} does not exist`);
return;
}
const filePath = `./demo/${files[0]}`;
console.log(`Running demo ${demoNumber}: ${files[0]}`);
if (shelljs.exec(`npm run ts-node -- ${filePath}`).code === 0) {
console.log("Document created successfully");
} else {
console.error("Something went wrong with the demo");
}
});

65
docs/README.md Normal file
View File

@ -0,0 +1,65 @@
# Welcome
## Installation
```sh
npm install --save docx
```
Then you can `require` or `import` as usual:
```ts
const docx = require("docx");
```
```ts
import * as docx from "docx";
// or
import { ... } from "docx";
```
## Basic Usage
```ts
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,
}),
],
}),
],
});
// Used to export the file into a .docx file
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
// Done! A file called 'My Document.docx' will be in your file system.
```
<p align="center">
<img alt="clippy the assistant" src="./clippy.png">
</p>
---
Made with 💖

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
- 50+ usage examples
- Battle tested, mature, 95%+ coverage
[GitHub](https://github.com/dolanmiu/docx)
[Get Started](#Welcome)

32
docs/_sidebar.md Normal file
View File

@ -0,0 +1,32 @@
* [Getting Started](/)
* [Examples](https://github.com/dolanmiu/docx/tree/master/demo)
* API
* [Documentation](https://docx.js.org/api/)
* Usage
* [Document](usage/document.md)
* [Sections](usage/sections.md)
* [Paragraph](usage/paragraph.md)
* [Text](usage/text.md)
* [Image](usage/images.md)
* [Headers & Footers](usage/headers-and-footers.md)
* [Bullet Points](usage/bullet-points.md)
* [Numbering](usage/numbering.md)
* [Tables](usage/tables.md)
* [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)
* Styling
* [Styling with JS](usage/styling-with-js.md)
* [Styling with XML](usage/styling-with-xml.md)
* Exporting
* [Packers](usage/packers.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

@ -0,0 +1,195 @@
# Contribution Guidelines
- 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 the `TSLint` rules
## Always think about the user
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 declarative?
5. Is it fun to use?
## Good Commit Names
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
works! // Glad its working, but the message is not helpful
demo updated // Getting better, but capitalize the first letter
Unesesary coment removed // Make sure to use correct spelling
```
**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:
```ts
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
const paragraph = doc.createParagraph();
const text = paragraph.createText();
text.contents = "Hello World";
```
**Do**
```ts
doc.addSection({
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
});
```
## Getters and Setters
Getters and Setters are done with a capital letter like so:
```ts
public get Level() {
...
}
```
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:**
```ts
private get _level: string;
```
**Do**
```ts
private get level: string;
```
## Interfaces over type alias
Do not use `type`, but rather use `Interfaces`. `type` cannot be extended, and a class cannot implement it.
> "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
`Interface` is generally preferred over `type`: https://stackoverflow.com/questions/37233735/typescript-interfaces-vs-types
**Do not:**
```ts
type RelationshipFileInfo = { id: number; target: string };
```
**Do:**
```ts
interface IRelationshipFileInfo {
id: number;
target: string;
}
```
## String enums vs type
To take full advantage of TypeScript's typing system, its best to use `string enums`:
**Do not:**
```ts
type WeaponType = "bow" | "sword" | "wand";
```
**Do:**
```ts
enum WeaponType = {
BOW = "bow",
SWORD = "sword",
WAND = "wand",
}
```
## Spell correctly, in full and in American English
**Do not:**
```ts
readdy; // misspelling
perm; // abbreviation
conf; // abbreviation
cnty; // abbreviation
relationFile; // abbreviation
colour; // U.K. English
```
**Do:**
```ts
ready;
permission;
config;
country;
relationshipFile;
color;
```
## Keep files small (within reason)
To minimize merge conflicts, reduce complexity, and improve readability, keep the files small.
## Name files and folders with `/foo-bar/kebab-case.ts`
To be consistent and in-line with the project, name files `like-this.ts`.
https://stackoverflow.com/questions/7273316/what-is-the-javascript-filename-naming-convention
## Testing
Please write a test of every file you make and suffix it with `.spec.ts`.
Here is a template of a test:
```ts
import { assert } from "chai";
describe("ClassName", () => {
beforeEach(() => {
// TODO
});
describe("#methodName()", () => {
it("should ", () => {
// TODO
});
});
});
```
Try not to use the `tests/utility.ts` file as this is being deprecated.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

36
docs/index.html Normal file
View File

@ -0,0 +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>
<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

@ -0,0 +1,20 @@
# Bullet Points
## 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
},
});
```
### This will produce:
- Bullet points
- Are awesome

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,
},
});
```

57
docs/usage/document.md Normal file
View File

@ -0,0 +1,57 @@
# Document
> The `Document` object is the starting point of your `.docx` journey, this is the literal Word Document. You add all your content such as `Paragraphs` to this `Document`, and at the end export it however you like.
To create a new document, it is very easy:
```ts
const doc = new docx.Document();
```
## Document properties
You can add properties to the Word document by specifying options, for example:
```ts
const doc = new docx.Document({
creator: "Dolan Miu",
description: "My extremely interesting document",
title: "My Document",
});
```
### Full list of options:
* creator
* description
* title
* subject
* 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.
### Units for positioning
Various parts of the API require positioning arguments. The units are "20ths of a point" from the [OOXML](http://officeopenxml.com/index.php) specification.
See [Lars Corneliussen's blog post](https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/) for more information and how to convert units.

View File

@ -0,0 +1,47 @@
# Headers and Footers
!> Headers and Footers requires an understanding of [Sections](usage/sections.md).
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: [],
});
```
If you want more head
## Example
Example showing basic header and footer
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/8-header-footer.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/8-header-footer.ts_
## Multiple Headers and Footers
More headers and footers can be accomplished by creating more `Section`. New headers and footers can be set per `Section`

47
docs/usage/hyperlinks.md Normal file
View File

@ -0,0 +1,47 @@
# Hyperlinks
There are two types of hyperlinks: internal (pointing to a bookmark inside the document) and external (pointing to an external url).
## Internal
To create an internal hyperlink you need first to create a bookmark (the paragraph that will be the destination of the hyperlink) with `doc.createBookmark(anchor, text)`.
A bookmark is composed of an anchor (an identifier) and the text displayed. After creating a bookmark just add it to a paragraph with `paragraph.addBookmark(bookmark)`
For example:
```ts
const paragraph = this.doc.createParagraph();
const bookmark = this.doc.createBookmark('anchorForChapter1', 'This is chapter1');
paragraph.addBookmark(bookmark);
```
Then you can create an hyperlink pointing to that bookmark with `doc.createInternalHyperLink(anchor,text)`:
```ts
const paragraph = this.doc.createParagraph();
const link = this.doc.createInternalHyperLink('anchorForChapter1', 'This is a link to chapter1');
paragraph.addHyperLink(link);
```
## External
To create an external hyperlink you just need to specify the url and the text of the link, then add it to a paragraph with `doc.createHyperlink(url, text)`:
```ts
const paragraph = this.doc.createParagraph();
const link = this.doc.createHyperlink('https://docx.js.org', 'This is an external link');
paragraph.addHyperLink(link);
```
## Styling an hyperlink
It is possible to set the style of the text of an hyperlink. This can be done applying run formatting on `TextRun` property of the hyperlink.
Example:
```ts
const link = this.doc.createHyperlink('https://docx.js.org', 'This is an external link');
link.TextRun.bold().italics()
```

248
docs/usage/images.md Normal file
View File

@ -0,0 +1,248 @@
# Images
!> Images requires an understanding of [Sections](usage/sections.md) and [Paragraphs](usage/paragraph.md).
To create a `floating` image on top of text:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 1014400,
},
verticalPosition: {
offset: 1014400,
},
},
});
```
By default with no arguments, its an `inline` image:
```ts
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
```
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],
}),
],
});
```
## Intro
Adding images can be done in two ways:
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)],
});
```
`docx` supports `jpeg`, `jpg`, `bmp`, `gif` and `png`
## Positioning
> Positioning is the method on how to place the image on the document
![Word Image Positiong](https://user-images.githubusercontent.com/34742290/41765548-b0946302-7604-11e8-96f9-166a9f0b8f39.png)
Three types of image positioning is supported:
- Floating
- Inline
By default, picture are exported as `Inline` elements.
### Usage
Pass `options` into the `[POSITION_OPTIONS]` metioned in the [Intro above](#Intro).
## Floating
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, {
floating: {
horizontalPosition: {
offset: 1014400, // relative: HorizontalPositionRelativeFrom.PAGE by default
},
verticalPosition: {
offset: 1014400, // relative: VerticalPositionRelativeFrom.PAGE by default
},
},
});
```
```ts
const imageData = document.createImage(buffer, 903, 1149, {
floating: {
horizontalPosition: {
relative: HorizontalPositionRelativeFrom.RIGHT_MARGIN,
offset: 1014400,
},
verticalPosition: {
relative: VerticalPositionRelativeFrom.BOTTOM_MARGIN,
offset: 1014400,
},
},
});
```
### Options
Full options you can pass into `floating` are:
| Property | Type | Notes |
| ------------------ | --------------------------- | -------- |
| horizontalPosition | `HorizontalPositionOptions` | Required |
| verticalPosition | `VerticalPositionOptions` | Required |
| allowOverlap | `boolean` | Optional |
| lockAnchor | `boolean` | Optional |
| behindDocument | `boolean` | Optional |
| layoutInCell | `boolean` | Optional |
`HorizontalPositionOptions` are:
| Property | Type | Notes | Possible Values |
| -------- | -------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| relative | `HorizontalPositionRelativeFrom` | Required | `CHARACTER`, `COLUMN`, `INSIDE_MARGIN`, `LEFT_MARGIN`, `MARGIN`, `OUTSIDE_MARGIN`, `PAGE`, `RIGHT_MARGIN` |
| align | `HorizontalPositionAlign` | You can either have `align` or `offset`, not both | `CENTER`, `INSIDE`, `LEFT`, `OUTSIDE`, `RIGHT` |
| offset | `number` | You can either have `align` or `offset`, not both | `0` to `Infinity` |
`VerticalPositionOptions` are:
| Property | Type | Notes | Possible Values |
| -------- | ------------------------------ | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| relative | `VerticalPositionRelativeFrom` | Required | `BOTTOM_MARGIN`, `INSIDE_MARGIN`, `LINE`, `MARGIN`, `OUTSIDE_MARGIN`, `PAGE`, `PARAGRAPH`, `TOP_MARGIN` |
| align | `VerticalPositionAlign` | You can either have `align` or `offset`, not both | `BOTTOM`, `CENTER`, `INSIDE`, `OUTSIDE`, `TOP` |
| offset | `number` | You can either have `align` or `offset`, not both | `0` to `Infinity` |
## Wrap text
Wrapping only works for floating elements. Text will "wrap" around the floating `image`.
Add `wrap` options inside the `floating` options:
```ts
wrap: {
type: [TextWrappingType],
side: [TextWrappingSide],
},
```
For example:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 2014400,
},
verticalPosition: {
offset: 2014400,
},
wrap: {
type: TextWrappingType.SQUARE,
side: TextWrappingSide.BOTH_SIDES,
},
},
});
```
Wrap options have the following properties are:
| Property | Type | Notes | Possible Values |
| -------- | ------------------ | -------- | ------------------------------------------- |
| type | `TextWrappingType` | Optional | `NONE`, `SQUARE`, `TIGHT`, `TOP_AND_BOTTOM` |
| side | `TextWrappingSide` | Optional | `BOTH_SIDES`, `LEFT`, `RIGHT`, `LARGEST` |
## Margins
Margins give some space between the text and the image. Margins [only work for floating elements](http://officeopenxml.com/drwPicInline.php). Additionally, the image must also be in wrap mode (see above).
?> Be sure to also set `wrap` in your options!
To use, add the `margins` options inside the `floating` options:
```ts
margins: {
top: number,
bottom: number,
left: number,
right: number
},
```
For example:
```ts
Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
floating: {
horizontalPosition: {
offset: 2014400,
},
verticalPosition: {
offset: 2014400,
},
wrap: {
type: TextWrappingType.SQUARE,
side: TextWrappingSide.BOTH_SIDES,
},
margins: {
top: 201440,
bottom: 201440,
},
},
});
```
## Examples
### Add image to the document
Importing Images from file system path
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/5-images.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/5-images.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/9-images-in-header-and-footer.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/9-images-in-header-and-footer.ts_
### Floating images
Example showing how to float images on top of text and optimally give a `margin`
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/38-text-wrapping.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/38-text-wrapping.ts_

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")],
}),
],
}),
```

88
docs/usage/numbering.md Normal file
View File

@ -0,0 +1,88 @@
# Bullets and Numbering
`docx` is quite flexible in its bullets and numbering system, allowing
the user great freedom in how bullets and numbers are to be styled and
displayed. E.g., numbers can be shown using Arabic numerals, roman
numerals, or even ordinal words ("one", "two", "three", ...). The
format also supports re-using bullets/numbering styles throughout the
document, so that different lists using the same style need not
redefine them.
Because of this flexibility, bullets and numbering in DOCX involves a
couple of moving pieces:
1. Document-level bullets/numbering definitions (abstract)
2. Document-level bullets/numbering definitions (concrete)
3. Paragraph-level bullets/numbering selection
## Document-level bullets/numbering definitions (abstract)
Every document contains a set of abstract bullets/numbering
definitions which define the formatting and layout of paragraphs using
those bullets/numbering. An abstract numbering system defines how
bullets/numbers are to be shown for lists, including any sublists that
may be used. Thus each abstract definition includes a series of
_levels_ which form a sequence starting at 0 indicating the top-level
list look and increasing from there to descibe the sublists, then
sub-sublists, etc. Each level includes the following properties:
* **level**: This is its 0-based index in the definition stack
* **numberFormat**: This indicates how the bullet or number should be
generated. Options include `bullet` (meaning don't count), `decimal`
(arabic numerals), `upperRoman`, `lowerRoman`, `hex`, and many
more.
* **levelText**: This is a format string using the output of the
`numberFormat` function and generating a string to insert before
every item in the list. You may use `%1`, `%2`, ... to reference the
numbers from each numbering level before this one. Thus a level
text of `%d)` with a number format of `lowerLetter` would result in
the sequence "a)", "b)", ...
* and a few others, which you can see in the OXML spec section 17.9.6
## Document-level bullets/numbering defintions (concrete)
Concrete definitions are sort of like concrete subclasses of the
abstract defintions. They indicate their parent and are allowed to
override certain level definitions. Thus two lists that differ only in
how sub-sub-lists are to be displayed can share the same abstract
numbering definition and have slightly different concrete definitions.
## Paragraph-level bullets/numbering selection
In order to use a bullets/numbering definition (which must be
concrete), paragraphs need to select it, similar to applying a CSS
class to an element, using both the concrete numbering definition ID
and the level number that the paragraph should be at. Additionally, MS
Word and LibreOffice typically apply a "ListParagraph" style to
paragraphs that are being numbered.
## Using bullets/numbering in `docx`
`docx` includes a pre-defined bullet style which you can add to your
paragraphs using `para.bullets()`. If you require different bullet
styles or numbering of any kind, you'll have to use the
`docx.Numbering` class.
First you need to create a new numbering container class and use it to
create your abstract numbering style, define your levels, and create
your concrete numbering style:
```ts
const numbering = new docx.Numbering();
const abstractNum = numbering.createAbstractNumbering();
abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent(720, 260));
abstractNum.createLevel(1, "decimal", "%2.", "start").addParagraphProperty(new Indent(1440, 980));
abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addParagraphProperty(new Indent(2160, 1700));
const concrete = numbering.createConcreteNumbering(abstractNum);
```
You can then apply your concrete style to paragraphs using the
`setNumbering` method:
```ts
topLevelP.setNumbering(concrete, 0);
subP.setNumbering(concrete, 1);
subSubP.setNumbering(concrete, 2);
```

34
docs/usage/packers.md Normal file
View File

@ -0,0 +1,34 @@
# Packers
> Packers are the way in which `docx` turns your code into `.docx` format. It is completely decoupled from the `docx.Document`.
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
This will return a NodeJS `Buffer`. If this is used in the browser, it will return a `UInt8Array` instead.
```ts
Packer.toBuffer(doc).then((buffer) => {
fs.writeFileSync("My Document.docx", buffer);
});
```
### Export as a `base64` string
```ts
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
Packer.toBlob(doc).then((blob) => {
// saveAs from FileSaver will download the file
saveAs(blob, "example.docx");
});
```

View File

@ -0,0 +1,66 @@
# Page Numbers
> This feature allows you to set page numbers on each page
?> **Note:** This feature only works on Headers and Footers
```ts
doc.Header.createParagraph().addRun(new TextRun("Page Number: ").pageNumber()).addRun(new TextRun("to ").numberOfTotalPages());
```
## Current page number
To get the current page number, call the `.pageNumber()` method on a `TextRun`. Then add the newly created `TextRun` into a paragraph
```ts
pageNumber();
```
For example:
```ts
const currentPageRun = new TextRun("Current Page Number: ").pageNumber();
paragraph.addRun(currentPageRun);
```
## Total number of pages
```ts
numberOfTotalPages();
```
For example:
```ts
const lastPage = new TextRun("Total Page Number: ").numberOfTotalPages();
paragraph.addRun(lastPage);
```
## Both
You can combine the two to get "Page 2 of 10" effect:
```ts
const currentPageRun = new TextRun("Page ").pageNumber();
const lastPage = new TextRun("of ").numberOfTotalPages();
paragraph.addRun(currentPageRun);
paragraph.addRun(lastPage);
```
Or:
```ts
doc.Header.createParagraph().addRun(new TextRun("Page ").pageNumber()).addRun(new TextRun("of ").numberOfTotalPages());
```
## Examples
### Simple Example
Adding page numbers to Header and Footer
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/39-page-numbers.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/39-page-numbers.ts_

289
docs/usage/paragraph.md Normal file
View File

@ -0,0 +1,289 @@
# Paragraph
> Everything (text, images, graphs etc) in OpenXML is organised in paragraphs.
!> Paragraphs requires an understanding of [Sections](sections.md).
You can create `Paragraphs` in the following ways:
### Shorthand
```ts
import { Paragraph } from "docx";
const paragraph = new Paragraph("Short hand Hello World");
```
### Children Method
This method is useful for adding different [text](text.md) with different styles, [symbols](symbols.md), or adding [images](images.md) inline.
```ts
const paragraph = new Paragraph({
children: [new TextRun("Lorem Ipsum Foo Bar"), new TextRun("Hello World"), new SymbolRun("F071")],
});
```
### Explicit
```ts
const paragraph = new Paragraph({
text: "Short hand notation for adding text.",
});
```
After you create the paragraph, you must add the paragraph into the `document's section`. Learn more about `sections` here:
```ts
doc.addSection({
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")],
}),
],
});
```
## Options
This is the list of options for a paragraph. A detailed explanation is below:
| Property | Type | Mandatory? | Possible Values |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------- |
| [text](#text) | `string` | Optional | |
| [heading](#heading) | `HeadingLevel` | Optional | `HEADING_1`, `HEADING_2`, `HEADING_3`, `HEADING_4`, `HEADING_5`, `HEADING_6`, `TITLE` |
| [border](#border) | `IBorderOptions` | Optional | `top`, `bottom`, `left`, `right`. Each of these are of type IBorderPropertyOptions. Click here for Example |
| [spacing](#spacing) | `ISpacingProperties` | Optional | See below for ISpacingProperties |
| [outlineLevel](#outline-level) | `number` | Optional | |
| alignment | `AlignmentType` | Optional | |
| heading | `HeadingLevel` | Optional | |
| bidirectional | `boolean` | Optional | |
| thematicBreak | `boolean` | Optional | |
| pageBreakBefore | `boolean` | Optional | |
| contextualSpacing | `boolean` | Optional | |
| indent | `IIndentAttributesProperties` | Optional | |
| keepLines | `boolean` | Optional | |
| keepNext | `boolean` | Optional | |
| children | `(TextRun or PictureRun 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 | |
## Text
This is the text in a paragraph. You can also add text by using the `Paragraph` shorthand (mentioned above) or adding `children`.
**Example:**
```ts
const paragraph = new Paragraph({
text: "Hello World",
});
```
## Heading
**Example:**
Setting a Heading 1 paragraph with "Hello World" as it's text:
```ts
const paragraph = new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
});
```
## Border
Add borders to a `Paragraph`. Good for making the `Paragraph` stand out
#### IBorderPropertyOptions
`top`, `bottom`, `left`, `right` of the border
| Property | Type | Notes |
| -------- | -------- | -------- |
| color | `string` | Required |
| space | `number` | Required |
| value | `string` | Required |
| size | `number` | Required |
**Example:**
Add border on the top and the bottom of the paragraph
```ts
const paragraph = 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,
},
},
});
```
## 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",
},
});
```
## Spacing
Adding spacing between paragraphs
### ISpacingProperties
| Property | Type | Notes |
| -------- | -------- | -------- |
| after | `number` | Optional |
| before | `number` | Optional |
| line | `number` | Optional |
| lineRule | `string` | Optional |
**Example:**
Add spacing before the paragraph:
```ts
const paragraph = new Paragraph({
text: "Paragraph with spacing before",
spacing: {
before: 200,
},
});
```
## Outline Level
**Example:**
```ts
const paragraph = new Paragraph({
outlineLevel: 0,
});
```
## Styles
To create styles, please refer to the styling Wiki: https://github.com/dolanmiu/docx/wiki/Styling
![Word 2013 Styles menu](http://content.gcflearnfree.org/topics/233/style_apply_choose.png "Word 2013 Styles menu")
### Headings and titles
```ts
import { HeadingLevel, Paragraph } from "docx";
const paragraph = new Paragraph({
text: "Hello World",
heading: HeadingLevel.TITLE,
});
```
## Text Alignment
To change the text alignment of a paragraph, add an `AlignmentType` option on the paragraph.for center, left, right or justified:
**Example:**
```ts
const paragraph = new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
alignment: AlignmentType.CENTER,
});
```
The above will create a `heading 1` which is `centered`.
### Justified text with breaks
When a paragraph is justified, you may want to not justify the contents of incomplete lines, which end in a soft line break.
![Justified line before](https://user-images.githubusercontent.com/7989576/53820338-e060c680-3f6b-11e9-817c-ecb43271951e.png)
This is possible to achieve using:
```ts
this.doc.Settings.addCompatibility().doNotExpandShiftReturn();
```
The result is:
![Justified line after](https://user-images.githubusercontent.com/7989576/53820344-e2c32080-3f6b-11e9-9afe-24a2ed6e0d78.png)
## Thematic Break
To add a thematic break in the `Paragraph`:
```ts
const paragraph = new docx.Paragraph("Amazing Heading");
const paragraph = new Paragraph({
text: "Amazing Heading",
heading: HeadingLevel.HEADING_1,
thematicBreak: true,
});
```
The above example will create a heading with a page break directly under it.
## Page Break
To move to a new page (insert a page break):
```ts
const paragraph = new docx.Paragraph({
children: [new TextRun("Amazing Heading"), new PageBreak()],
});
```
The above example will create a heading and start a new page immediately afterwards.
### Page break before:
This option (available in word) will make sure that the paragraph will start on a new page (if it's not already on a new page).
```ts
const paragraph = new Paragraph({
text: "Hello World on another page",
pageBreakBefore: true,
});
```
![Page Break Before in Word](https://user-images.githubusercontent.com/34742290/40176503-df3a8398-59db-11e8-8b9c-d719f13aa8b4.png)
Example: https://github.com/dolanmiu/docx/blob/master/demo/15-page-break-before.ts
## Page break control
Paragraphs have `.keepLines()` and `.keepNext()` methods that allow restricting page breaks within and between paragraphs. See [this Microsoft article](https://support.office.com/en-us/article/Keep-lines-and-paragraphs-together-d72af534-926f-4c4b-830a-abfc2daa3bfa) for more details)

21
docs/usage/sections.md Normal file
View File

@ -0,0 +1,21 @@
# Sections
> Every document is made up of one or more sections
A section is a grouping of paragraphs that have a specific set of properties used to define the pages on which the text will appear. Properties include page size, page numbers, page orientation, headers, borders and margins.
For example, you could have one section which is portrait with a header and footer, and another section in landscape with no footer, and a header showing the current page number.
## Example
This creates a simple section in a document with one paragraph inside:
```ts
doc.addSection({
children: [
new Paragraph({
children: [new TextRun("Hello World")],
}),
],
});
```

View File

@ -0,0 +1,208 @@
# Styling with JS
## Example
```ts
const para = new Paragraph({
text: "To whom it may concern:",
heading: HeadingLevel.HEADING_2,
alignment: AlignmentType.CENTER,
});
const name = new TextRun({
text: "Name:",
bold: true,
font: "Calibri",
allCaps: true,
});
```
## Available Options
### Run formatting
- `bold`, `italics`, `smallCaps`, `allCaps`, `strike`, `doubleStrike`, `subScript`, `superScript`: Set the formatting property to true
- `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)` 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)
### Paragraph formatting
- `heading1`, `heading2`, `heading3`, `heading4`, `heading5`, `title`: apply the appropriate style to the paragraph
- `left`, `center`, `right`, `justified`: set the paragraph's alignment
- `thematicBreak`, `pageBreak`: Insert a thick rule or a page break beneath the paragraph
- `leftTabStop(position)`: Add a left tab stop (measured in TWIPs from the left)
- `maxRightTabStop`: Add a right tab stop at the far right
- `bullet`: Use the default bullet style
- `setNumbering(numbering, indentLevel)`: Use a custom numbering format for the paragraph
- `style(name)`: Apply a named paragraph style
- `indent(start, hanging=0)`: Set the paragraph's indent level (in TWIPs)
- `spacing({before=0, after=0, line=0})`: Set the line and before/after on the paragraph. Before/after is measured in TWIPs, line is measured in 240ths of a line
Paragraph styles have all the run formatting methods, except `style()`, and `left()`, `center()`, `right()`, `justified()`, `thematicBreak()`, `leftTabStop(position)`, `maxRightTabStop()`, `indent(start, hanging=0)`, and `spacing({before=0, after=0, line=0})` methods.
## Detailed guide
There are 4 items in `docx` that can be styled:
- Characters: Attributes that can change within a paragraph. e.g., bold, italics, etc.
- Paragraphs: Attributes like indent, text alignment, line spacing, etc.
- Tables: Border styles, table formats, etc.
- List items: These are the numbers and bullets that are automatically inserted
There are a few different ways of styling this content in `docx`, which somewhat resemble the HTML/CSS approach. In order of greatest to lowest priority:
1. Direct formatting (inline formatting)
2. Declaritive Styles (similar to external CSS)
3. Document defaults (similar to a `*` rule in CSS)
Unlike CSS, less specific rules don't _necessarily_ override parent rules. The rules are a bit wonky, but if you're interested, see the [advanced formatting section](#Advanced formatting).
### Direct formatting (inline formatting)
This is the type of formatting that your uncle uses when he types out documents: _N ... a ... m ... e ... :_ Then he grabs the mouse, highlights _Name:_ and moves over to the **B** for bold. This manner of formatting results in markup that is similar to writing `<span style="bold: true">Name:</span>` if you were typing out HTML. `docx` (the format) allows you to specify this for any of the four types of items. `docx` (the library) only supports this type of formatting for paragraphs and characters, using a _fluent_ api. Thus you could do:
```ts
const name = new TextRun({
text: "Name:",
bold: true,
font: "Calibri",
allCaps: true,
});
```
Or for paragraph formatting:
```ts
const para = new Paragraph({
text: "To whom it may concern:",
heading: HeadingLevel.HEADING_2,
alignment: AlignmentType.CENTER,
});
```
### Declaritive Styles (similar to external CSS)
`docx` files contain a styles section separate from the main content, much like how HTML includes CSS files. Unlike CSS, `docx` distinguishes between styles meant for tables (which show up in the table formatting toolbar), styles for lists (which show up under bullets and numbering), and styles for runs and paragraphs, which show up as dropdowns offering standard styles, like "Heading 1", "Caption", or any custom styles defined in that document. <!-- TODO: add pictures of the panes -->. `docx` allows you to define these styles using a fluent interface as well.
To add styles, define your custom styles in the `document`:
```ts
// The first argument is an ID you use to apply the style to paragraphs
// The second argument is a human-friendly name to show in the UI
const doc = new Document({
creator: "Clippy",
title: "Sample Document",
description: "A brief example of using docx",
styles: {
paragraphStyles: [
{
id: "myWonkyStyle",
name: "My Wonky Style",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
italics: true,
color: "999999",
},
paragraph: {
spacing: {
line: 276,
},
indent: {
left: 720,
},
},
},
{
id: "Heading2",
name: "Heading 2",
basedOn: "Normal",
next: "Normal",
quickFormat: true,
run: {
size: 26
bold: true,
color: "999999",
{
type: UnderlineType.DOUBLE,
color: "FF0000",
},
},
paragraph: {
spacing: {
before: 240,
after: 120
},
},
},
]
}
});
```
**Note**: If you are using the `.headingX` or `.title` methods of paragraphs, you must make sure to define `HeadingX` or `Title` styles for these. Otherwise they'll show up unstyled :(. If you are using the `.bullet` or `.setNumbering` methods, you need to define a `ListParagraph` style or the numbers may not show up.
### Document defaults
Setting document defaults acts like a `*` rule in CSS: it applies to every paragraph and run in the document, but at a low priority level. Other styles affecting this property will override these defaults.
## Advanced formatting
### Style inheritance
Styles may define a `basedOn` attribute that references another style of the same type. In this case, any unspecified properties are inherited from the parent style.
### Interactions between the 4 items
In addition to the 3-layer hierarchy spelled above, there is some interaction between the 4 items that you can style.
For instance numbering styles may also specify some styling for paragraphs (typically indentation and tab stops); paragraphs may specify character formatting (e.g., heading font sizes); etc.
The elements that each style may affect are summarized in the table below. So, e.g., table styles may specify table formatting, paragraph formatting, and character formatting.
| Style type | Table | Paragraph | List item | Characters |
| :---------------- | :---: | :-------: | :-------: | :--------: |
| Document defaults | | X | | X |
| Table | X | X | | X |
| Paragraph | | X | X | X |
| Numbering | | X | X | |
| Character | | | | X |
| Direct formatting | X | X | X | X |
To determine the value of a styling property, you must first identify whether it's a table, paragraph, list item, or character property. E.g., numbering definition is a list item property. Then you need to find the last row in the table for which that property has an "X" and the document has formatting of that type. So if a particular run was in a paragraph whose style specified color as `FF0000`, but it also had a character style specifying color as `00DD00`, then the character style (lower down on the table) would trump, and the character would have color `00DD00`.
### Toggle properties
The following properties are treated in a special manner; they're called toggle properties:
- Bold
- All caps
- Small caps
- Italics
- Single strike-through
- Hidden
- Imprint
- Emboss
- Character outline
- Character shadow
For these properties, the rules state the following conflict resolution in case the property is specified at multiple points for the same item:
- Direct formatting trumps all if specified (either true or false)
- Otherwise, if the property is true in document defaults, the property is set to true
- Otherwise, the property's value is an XOR of its effective table, paragraph, and character values. (So specifying bold `true` on a table style and a paragraph style would result in non-bold text if a paragraph inside the table had that style)
## Examples
### Declaritive styles
Importing Images from file system path
[Example](https://raw.githubusercontent.com/dolanmiu/docx/master/demo/2-declaritive-styles.ts ':include')
_Source: https://github.com/dolanmiu/docx/blob/master/demo/2-declaritive-styles.ts_

View File

@ -0,0 +1,47 @@
# Styling with XML
## Setup
1. Create a new word document in Microsoft Word
2. Customise the styles on the Ribbon Bar.
For example, modify the `Normal`, `Heading 1`, `Heading 2` like so:
![image](https://user-images.githubusercontent.com/2917613/41195113-65edebfa-6c1f-11e8-97b4-77de2d60044a.png)
![image](https://user-images.githubusercontent.com/2917613/41195126-ca99c36c-6c1f-11e8-9e58-19e5f69b3b87.png)
3. You can even create a totally new `Style`:
![image](https://user-images.githubusercontent.com/2917613/41195135-f0f7862a-6c1f-11e8-8be4-dd6d8fe5be03.png)
![image](https://user-images.githubusercontent.com/2917613/41195139-0ec52130-6c20-11e8-8fae-f6b44b43fdf8.png)
4. Save
5. Re-name the saved `.docx` file to `.zip` and un-zip
6. Find `styles.xml`
![image](https://user-images.githubusercontent.com/2917613/41195178-bb9ba9c4-6c20-11e8-850e-a7a6ada9a2f6.png)
## Usage
Read the styles using `fs`, and put it into the `Document` object in the constructor:
```ts
const styles = fs.readFileSync("./styles.xml", "utf-8");
const doc = new docx.Document({
title: "Title",
externalStyles: styles,
});
```
You can use paragraphs, `heading1()`, `heading2()` etc and it will be styled according to your `styles.xml` created earlier. You can even use your new style you made by calling the `style` method:
```ts
doc.createParagraph("Cool Heading Text").heading1();
const paragraph = new docx.Paragraph('This is a custom named style from the template "Cool New Style"');
paragraph.style("Cool New Style");
doc.add(paragraph);
doc.createParagraph("Some normal text");
```
Example: https://github.com/dolanmiu/docx/blob/master/demo/13-xml-styles.ts

53
docs/usage/symbols.md Normal file
View File

@ -0,0 +1,53 @@
# Symbol Runs
!> SymbolRuns require an understanding of [Paragraphs](paragraph.md).
You can add multiple `symbol runs` in `Paragraphs` along with [text runs](text.md) using the Paragraph's `children` property.
```ts
import { Paragraph, TextRun, SymbolRun } from "docx";
const paragraph = new Paragraph({
children: [
new TextRun("This is a checkbox: "),
new SymbolRun("F071")
],
});
```
## Specifying symbol font
By default symbol runs will use the `Wingdings` font. To switch fonts, pass an object instead of a string to the `SymbolRun` constructor and specify `char` and `symbolfont` properties:
```ts
const symbol = new SymbolRun({
char: "F071",
symbolfont: "Arial",
});
```
## Example symbols
Symbols are specified by their hexidecimal code. Ref http://officeopenxml.com/WPtextSpecialContent-symbol.php. Below are some examples.
- `F071`: empty checkbox
- `F043`: thumbs up
- `F04A`: smile
- `F04C`: frown
- `F022`: scissors
- `F0F0`: right arrow
- `F0FE`: checked box
## Typographical Emphasis
Symbol runs can have their display modified just like text runs. For example, they can be bolded and italicized:
```ts
const symbol = new SymbolRun({
char: "F071",
bold: true,
italics: true,
});
```
See the [text run](text.md) documentation for more info.

121
docs/usage/tab-stops.md Normal file
View File

@ -0,0 +1,121 @@
# Tab Stops
> Tab stops are useful, if you are unclear of what they are, [here is a link explaining](https://en.wikipedia.org/wiki/Tab_stop). It enables side by side text which is nicely laid out without the need for tables, or constantly pressing space bar.
!> **Note**: The unit of measurement for a tab stop is in [DXA](https://stackoverflow.com/questions/14360183/default-wordml-unit-measurement-pixel-or-point-or-inches)
![Word 2013 Tabs](http://www.teachucomp.com/wp-content/uploads/blog-4-22-2015-UsingTabStopsInWord-1024x577.png "Word 2013 Tab Stops")
Simply call the relevant methods on the paragraph listed below. Then just add a `tab()` method call to a text object. Adding multiple `tabStops` will mean you would have to chain `tab()` until the desired `tabStop` is selected. Example is shown below.
## Example
```ts
const paragraph = new Paragraph({
children: [new TextRun("Hey everyone").bold(), new TextRun(\t"11th November 1999")],
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
],
});
```
The example above will create a left aligned text, and a right aligned text on the same line. The laymans approach to this problem would be to either use text boxes or tables. Not ideal!
```ts
const paragraph = new Paragraph({
children: [new TextRun("Second tab stop here I come!")],
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
{
type: TabStopType.LEFT,
position: 1000,
},
],
});
```
The above shows the use of two tab stops, and how to select/use it.
You can add multiple tab stops of the same `type` too.
```ts
const paragraph = new Paragraph({
children: [new TextRun("Multiple tab stops!")],
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
{
type: TabStopType.RIGHT,
position: 1000,
},
],
});
```
## Left Tab Stop
```ts
const paragraph = new Paragraph({
tabStops: [
{
type: TabStopType.LEFT,
position: 2268,
},
],
});
```
2268 is the distance from the left side.
## Center Tab Stop
```ts
const paragraph = new Paragraph({
tabStops: [
{
type: TabStopType.CENTER,
position: 2268,
},
],
});
```
2268 is the distance from the center.
## Right Tab Stop
```ts
const paragraph = new Paragraph({
tabStops: [
{
type: TabStopType.RIGHT,
position: 2268,
},
],
});
```
2268 is the distance fro0oum the left side.
## Max Right Tab Stop
```ts
const paragraph = new Paragraph({
tabStops: [
{
type: TabStopType.RIGHT,
position: TabStopPosition.MAX,
},
],
});
```
This will create a tab stop on the very edge of the right hand side. Handy for right aligning and left aligning text on the same line.

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