Compare commits
1196 Commits
Author | SHA1 | Date | |
---|---|---|---|
0e033131b2 | |||
0be6f31611 | |||
e8a8b73ad0 | |||
953c6806ce | |||
1cf68c696e | |||
6d354674b2 | |||
137b9a06cb | |||
c43f04da52 | |||
1941721070 | |||
9f282952cd | |||
09b81017d0 | |||
4f58979096 | |||
898104ea2c | |||
7d15eeda88 | |||
cba3f77272 | |||
91dffc45ff | |||
47eb46e700 | |||
8271ddc78e | |||
6b08545ef9 | |||
9cddfb4ce7 | |||
19b26e1c5e | |||
936fffd0a1 | |||
2f24d062b3 | |||
4e373d4ab6 | |||
c01d3d9f67 | |||
d2f344b83f | |||
d7f5a44b45 | |||
0a9b98e1aa | |||
fd188870e8 | |||
c28e6ac22e | |||
9381bd8ddb | |||
454fc76e8d | |||
ba963b0360 | |||
19d3ed47c9 | |||
0757295213 | |||
76c677a6b1 | |||
ce8842b52f | |||
a039fe3223 | |||
a669b2148f | |||
53a7d87b03 | |||
388ab4f3b1 | |||
567713b7ba | |||
9547805ec2 | |||
89040e0237 | |||
dd657a9e88 | |||
fe21bb1702 | |||
a01d352925 | |||
e1fb07989f | |||
b0d6be1929 | |||
a2e0c66dc8 | |||
fe028c3ac1 | |||
92ef5805b8 | |||
e30f3b2035 | |||
cdcaba651c | |||
63aff461ed | |||
54565e2228 | |||
cce6d3fcbe | |||
26809a33c6 | |||
030594ccae | |||
396470886c | |||
0408a2808c | |||
14f9347311 | |||
40747603e8 | |||
608ba89c7c | |||
f34d4833a8 | |||
051a1226c0 | |||
5b2350c01c | |||
0ffc114005 | |||
ff25a4faa5 | |||
e73b12cd76 | |||
7a2f209430 | |||
0174e9b423 | |||
794571c7e1 | |||
c34a4f2613 | |||
f648ecf0b8 | |||
e1cc557bec | |||
2310b7f479 | |||
e64bb9c7b9 | |||
af98f80db0 | |||
8a704776d2 | |||
67a205cae7 | |||
1fb1f50756 | |||
50049113b5 | |||
49694a53fd | |||
ead04d0764 | |||
47099d0468 | |||
abbd620220 | |||
303b025aee | |||
1421b06df7 | |||
1e37282e06 | |||
7b992ed254 | |||
deba94d69c | |||
5e09c27a0d | |||
31563f53ec | |||
a967e560c6 | |||
c4427f7bb9 | |||
a563659eca | |||
caca11d807 | |||
c79d68d83e | |||
7af63f4b0c | |||
ea54f35317 | |||
820fb61a85 | |||
f602a097d2 | |||
0df72996b5 | |||
8d94fa9a78 | |||
54417af3d4 | |||
5a0727f2d9 | |||
d51a488303 | |||
ef28ba1866 | |||
6ede7000fa | |||
0883e3b0c6 | |||
86f58703a5 | |||
b6be7627bb | |||
4522c9bbfd | |||
1cf9255f3d | |||
bc2b677c86 | |||
297810d2f5 | |||
740f10f391 | |||
b895bc7457 | |||
133761a266 | |||
9ea940d2ca | |||
a7b9dc7730 | |||
bf5e6cfa57 | |||
cdc82268e6 | |||
d3035a29b8 | |||
cc6c696d99 | |||
0f273c5aaf | |||
d1837651f8 | |||
9ba1c233dc | |||
1727acf9ca | |||
60f59c1da5 | |||
e6a0f3e8f7 | |||
d881646e73 | |||
97d1025a0f | |||
309517b654 | |||
e13d734738 | |||
34da2f4289 | |||
b986403656 | |||
5cba664f70 | |||
9a35029f16 | |||
3c768c5630 | |||
f77ddb4037 | |||
536204e5ef | |||
1f078e0687 | |||
705b1f7cfc | |||
28233075bd | |||
f1627c378d | |||
0aa5510b9c | |||
3d9216e8bf | |||
054ece38ab | |||
951094c6fb | |||
ea01ddb337 | |||
34036bca8f | |||
0256968240 | |||
1f894303d3 | |||
c79e9ded71 | |||
0d72de7e53 | |||
750368ac08 | |||
4394a9b575 | |||
1b758b73e6 | |||
65a0e97c97 | |||
3c33931d99 | |||
e475779ba5 | |||
4c58e3c47d | |||
9fb77d9cee | |||
f315909dc0 | |||
fa9ffec601 | |||
636d114d44 | |||
2140ed63cd | |||
8d0f7d58bf | |||
3c48822cec | |||
547c05b05d | |||
e5ba625820 | |||
45e644ac43 | |||
9b14b9c925 | |||
0bc55208ec | |||
285eb0a85d | |||
d521e20c0e | |||
439f8ff4bc | |||
18791c99f5 | |||
9991700701 | |||
01bc6093dd | |||
5c08b889b1 | |||
7944a7064e | |||
1713358f0c | |||
b6465e15de | |||
5ca97ce96f | |||
5609b11188 | |||
eec084767f | |||
3a795401d1 | |||
23fd3b483f | |||
a2566e92d2 | |||
bf884c8d13 | |||
dae2898496 | |||
9555ddd648 | |||
755895ebef | |||
4283a6c7d9 | |||
dd7439b45c | |||
b4c7ed2347 | |||
9354b99897 | |||
a1fbbde149 | |||
607087d256 | |||
7d50194cbf | |||
ab5c5c0fb7 | |||
bc1bca762e | |||
75290aeaf5 | |||
996594da9b | |||
5018134e35 | |||
da9ebbdb9a | |||
eb5a4f9620 | |||
64cec50b84 | |||
ce2a949176 | |||
ff7756f8c5 | |||
4221b9085a | |||
76e7f40bd2 | |||
dc2f9c3bdc | |||
8eb5d6281e | |||
6d09355174 | |||
4e3a2fd90f | |||
463c282568 | |||
8c0ff0422a | |||
0fe1765b7f | |||
4accf65802 | |||
c6eb11d535 | |||
58cfb427e9 | |||
90bb670de6 | |||
727e741b08 | |||
41f516d64b | |||
366cd2b4b1 | |||
243d73542f | |||
44520bc54b | |||
831ef9a98c | |||
bef9ea28f2 | |||
7fa94b6996 | |||
c1cc211c7f | |||
9efee181ba | |||
631f561441 | |||
94592de477 | |||
ac204a5189 | |||
e48ca53660 | |||
5c2d4f729a | |||
03d6636262 | |||
74b3267294 | |||
83af11aa1b | |||
8cf9b83068 | |||
5dab97241e | |||
3b7394fe74 | |||
31c6f0a8ca | |||
890983c1e1 | |||
e8db8ec669 | |||
dcbe542fb2 | |||
ca695ad122 | |||
60bd9a84dd | |||
ecc3b2ef3f | |||
3e8d816614 | |||
dde54082d5 | |||
6845cd433f | |||
046ef0330a | |||
fcd0427fe4 | |||
4c4e253883 | |||
3a9f09b578 | |||
e9aea8b8a9 | |||
5c9b5e4322 | |||
33d6544aba | |||
3f257bf5a4 | |||
1ff31a2a42 | |||
14013273af | |||
b34127665c | |||
0fcd02aea8 | |||
d773148218 | |||
d52bf7b57d | |||
f378c37b62 | |||
d773972877 | |||
738b36b6a9 | |||
ad7ef22b63 | |||
e73e1f98f9 | |||
738e374bf2 | |||
c5861129c9 | |||
5f4c595a1a | |||
238b8b9a8d | |||
a92f3a7ba1 | |||
2a1685ab82 | |||
0088d58fea | |||
cbf4f828ab | |||
2ccf27162e | |||
5dffda8c7c | |||
e1c777738b | |||
0f531b2a9b | |||
d523b2dae7 | |||
f50c7f20cb | |||
f21fb06467 | |||
2fd4f064ae | |||
36a18c5af3 | |||
75587df420 | |||
43ea0bd406 | |||
ec2ad99e95 | |||
46deaa5a4a | |||
697baa3fd6 | |||
15829b53a6 | |||
56f1e4408a | |||
689d4d07bc | |||
b0049d8221 | |||
152a11d7fc | |||
31171330a2 | |||
3c0032cf68 | |||
0e44af1c06 | |||
39893a984c | |||
b75e194993 | |||
9fb58a5852 | |||
5c578a6bea | |||
3ba197a289 | |||
bbf50c34a0 | |||
6b6f2214f6 | |||
836ffd683f | |||
6c94a1382c | |||
c13cac899a | |||
ec1f9d5ecf | |||
a8115ff964 | |||
da744cbdec | |||
439ab8441e | |||
15b14579e6 | |||
1cb666fd03 | |||
bde4aa4657 | |||
709876a02d | |||
a0b74f24e3 | |||
ed15614023 | |||
c3e97a0aab | |||
b69968a99c | |||
82b12a99b9 | |||
1486519a98 | |||
7e194350d8 | |||
855c47954e | |||
dd3300506b | |||
154c7cb54b | |||
cd75c2e860 | |||
1b0f19d570 | |||
45026eb30e | |||
aeddcc7478 | |||
f88b588b60 | |||
f00844ad1b | |||
8e87437272 | |||
49b011280c | |||
37b94eeedc | |||
4053b5bbc2 | |||
46972a861d | |||
528dab5c10 | |||
d1ffc0bffa | |||
3741dd7ef2 | |||
c6c4b0cbcd | |||
804380f70e | |||
118f60f704 | |||
d556f97dbe | |||
b116b0a268 | |||
99f0297c4f | |||
4543016869 | |||
2b9c15a638 | |||
4ca5ea6046 | |||
2de55a1eb3 | |||
db20efa95b | |||
3822d8139d | |||
3a65f383e4 | |||
d05fef6b93 | |||
f02b6211a3 | |||
4b4f67f9c7 | |||
9f38e33a48 | |||
69ca5d8b0c | |||
809474e9c5 | |||
e5b56c4214 | |||
568a27367a | |||
c6f99fcbe5 | |||
309abbcc47 | |||
de145e0623 | |||
7f24abd104 | |||
edafbdb1ff | |||
034cd187ab | |||
8f04e0da4a | |||
90b8b8140b | |||
0b28bf02c4 | |||
2b169fc63a | |||
e2bb50d6ad | |||
730e33b164 | |||
6603aafa38 | |||
05a6ab77cc | |||
5a52541136 | |||
e4709a7f8d | |||
60b7ce4785 | |||
fd4afea9aa | |||
04d88fa592 | |||
87000d8656 | |||
776132ede0 | |||
b845e4daee | |||
da61a30eb8 | |||
3a02bc087c | |||
b05748da25 | |||
63cea76eac | |||
e198f0752a | |||
22e62ed950 | |||
c3e92c0709 | |||
d0036e64b5 | |||
7bfe8f26f0 | |||
4274c7674c | |||
8505e04e58 | |||
4466145d00 | |||
ce2a0fb864 | |||
a56119e7cd | |||
56eecef1a8 | |||
097c6a5962 | |||
ee105cdb83 | |||
7891402c72 | |||
bde13193d5 | |||
449e1ed963 | |||
dd6d1bc039 | |||
528be93191 | |||
1ea6017483 | |||
08bd2744b6 | |||
54ab55b92c | |||
5155cdaf45 | |||
496fcb55fa | |||
fcc393aca2 | |||
2611e0c74f | |||
acc23be297 | |||
bdc0aa26ea | |||
ff14fcae3a | |||
37d099b457 | |||
0344eb8e27 | |||
403e7a4228 | |||
aa336dc652 | |||
d8fca42eb7 | |||
10d1d15f73 | |||
ac55e0fcb3 | |||
780682a8f7 | |||
b627f0982a | |||
798cbb8628 | |||
15f79abf5e | |||
f5e35603ef | |||
06da596ffb | |||
4593464a15 | |||
30912e7aaf | |||
56b18d3793 | |||
d0a675fde6 | |||
45130bed0b | |||
faefb0d2a8 | |||
c4b7a7094b | |||
d527013451 | |||
bb8ac8b9d8 | |||
cdc97adaeb | |||
72f0ad9fdb | |||
0f55d70a19 | |||
6ac0375400 | |||
9048f8f271 | |||
23eaff2dab | |||
df4a381135 | |||
41dcf363b4 | |||
f143c017cb | |||
7463c0301f | |||
bb24c50bf4 | |||
70538a8062 | |||
085db9350c | |||
eabdefdaf4 | |||
9fc8e50691 | |||
dfc01f2d5a | |||
4e8aec9a0e | |||
c7e0554817 | |||
d77d59836f | |||
a035f4f411 | |||
53b1bba103 | |||
605536ce68 | |||
a9e4c88804 | |||
79c1db9c91 | |||
3b757ad4c8 | |||
ee07ff8282 | |||
85583a3dbd | |||
46daacfbc8 | |||
7acd9e1fde | |||
97e3f8bc78 | |||
ff378d6667 | |||
9930476f64 | |||
3e5223dd5d | |||
e3bb8258e5 | |||
77301a401e | |||
a09882b566 | |||
e72453c19a | |||
bd159b280f | |||
4d3d971a12 | |||
def503c53e | |||
74afae1850 | |||
7db166b19c | |||
0271e4ad40 | |||
2b010dbfec | |||
a8f38a3d01 | |||
bd69779a12 | |||
571ba2e2c3 | |||
7a25165046 | |||
977fdbb9eb | |||
2f05186730 | |||
38695c3c4b | |||
f2152b3da1 | |||
51dc538cdd | |||
c76bb2859a | |||
0b6f040bba | |||
149908ea62 | |||
98f745a3f7 | |||
9b840c0d63 | |||
0085b1d128 | |||
c3ddd576e2 | |||
cf237bcc10 | |||
c6ce7fe3a3 | |||
712e612ab1 | |||
161038cc75 | |||
24aee70b67 | |||
b486bcf372 | |||
97147bc3d7 | |||
6a0b01e05c | |||
e60d9cbbce | |||
594045644b | |||
e36022d044 | |||
2b0acc2980 | |||
2058f72c2e | |||
0788b10106 | |||
7b431e50bc | |||
633487ca16 | |||
43d1f40baa | |||
aec7f09031 | |||
790dfa320e | |||
260482d9d4 | |||
b699481ae3 | |||
0f7260c152 | |||
d43d742875 | |||
fceefcf290 | |||
488711dae0 | |||
901847db3e | |||
dd7a83753b | |||
04d2b01e16 | |||
ca9f1c9af4 | |||
eed7cb9537 | |||
ec54c7f762 | |||
c7b69a3ff5 | |||
6892c7aa6c | |||
09ec3e682f | |||
e3ac9bc9bf | |||
958045e5c7 | |||
0f6f7b8a15 | |||
401e4851e1 | |||
abc7c8dc72 | |||
7a0cc2f2e7 | |||
b374dc0fac | |||
ed409ac1b7 | |||
4842630e09 | |||
d29286ab6d | |||
ebaf0dfbf0 | |||
72389e25a1 | |||
799bdcc2f0 | |||
9ec7b4969d | |||
e78696fbac | |||
f4102d2e30 | |||
658814d9ca | |||
fd86122881 | |||
ce335c7a3d | |||
bd456d3864 | |||
2414c7c356 | |||
bc6644be0b | |||
46846b6e6c | |||
ac4b5839c2 | |||
9cf7f3cf54 | |||
77afb55167 | |||
e86997576f | |||
a67e306737 | |||
48ea634e08 | |||
ea29f515b0 | |||
41d27cb78c | |||
ff45c182ce | |||
0519ed6d09 | |||
f41e19c251 | |||
329a70c312 | |||
419fef5759 | |||
3299c557a0 | |||
4783812044 | |||
6e21cdbf17 | |||
caf188caae | |||
c8db70b3b7 | |||
eb0479d80b | |||
181d56ca80 | |||
b1d1b9e9b7 | |||
28685a8761 | |||
ecd1596682 | |||
6746f81da5 | |||
c7075d740f | |||
0faac01f6b | |||
bdfaee2cb3 | |||
131183ae19 | |||
8b2aa58198 | |||
4fe2973473 | |||
93ec9eed7a | |||
ba5cb1483b | |||
1436f4d4b2 | |||
107e6ce1d9 | |||
2d5e08588c | |||
24f95aee8b | |||
c5e9e3b2a0 | |||
0b85e07701 | |||
40b3bc0b90 | |||
bd40b11ce4 | |||
a3febae8a3 | |||
18ce200cdb | |||
cc32a7b2d3 | |||
e7eca14e1e | |||
7f86385b09 | |||
2fa8df7cf4 | |||
f0e50dd21f | |||
0bc36d924f | |||
4bc0421055 | |||
cc9a966f53 | |||
8aa804db18 | |||
b3ffa60f14 | |||
8724fbe7a7 | |||
2391375ac0 | |||
12817957f4 | |||
58f7e5a9a3 | |||
0b88cb0ca5 | |||
dbaa493ebd | |||
4b5d2d98f9 | |||
9864cdea16 | |||
566ac03f9a | |||
cf6c4998d0 | |||
0891e2a8c3 | |||
48d9e75707 | |||
cd501bba0a | |||
57f80e636e | |||
89c2e14979 | |||
8c2ba7a452 | |||
cd232496e2 | |||
0cdb1a9286 | |||
7ebef8b3b5 | |||
e98fe5921c | |||
98253c3445 | |||
9bda9e8375 | |||
bf4498061a | |||
13d0f33af6 | |||
d4bc89d141 | |||
0c42298dce | |||
f997515af4 | |||
624afb8fba | |||
71f8bcffe7 | |||
e8bdeed63f | |||
2b7ca92ade | |||
fdf0764245 | |||
993782129c | |||
65302dd39b | |||
a0d8911e18 | |||
2d4a452d2e | |||
3f2ad04d65 | |||
283c42cb55 | |||
0ec3b64ad7 | |||
b972f1789e | |||
90495d08a6 | |||
5fc28cb67d | |||
bb6abe5e09 | |||
d1a8f983d3 | |||
e169e01002 | |||
e5da573041 | |||
9557015c6c | |||
512d81649f | |||
fc1e0dad3f | |||
ec22720244 | |||
9743dfa8cc | |||
805bd94a25 | |||
c3faf3bbd8 | |||
5b3427cada | |||
df7a90d3c1 | |||
f3f65da207 | |||
9326a0a998 | |||
909a86df7f | |||
a5da9f44e8 | |||
2f732e7378 | |||
31269c85d2 | |||
95556e57df | |||
2aa93e6105 | |||
a026e5bd1f | |||
9327f2bfa1 | |||
603dd36458 | |||
53ababf3a7 | |||
3e58910bfc | |||
736ca6a46d | |||
f90e84a88d | |||
a79b1e36dc | |||
dd503996a0 | |||
694ac22dad | |||
8435ece00d | |||
cdd22efd79 | |||
c6e9696be0 | |||
655b40d418 | |||
60664a2a83 | |||
e750735fa4 | |||
0de7116b78 | |||
45b1f6f9a3 | |||
4159be5644 | |||
10455a534f | |||
84f48446df | |||
32ceaa415e | |||
5e06d73f45 | |||
bfd0f0c7bb | |||
858a994d13 | |||
bb2f77aa67 | |||
48c1559a77 | |||
a6f77d01ca | |||
4dafa62e17 | |||
49314ea9d0 | |||
acaaf98e20 | |||
0e2bfe9e3f | |||
d6f363b275 | |||
118ea57412 | |||
7c8be4c8a7 | |||
fa9021596f | |||
3ccf4bdfe3 | |||
f2480673ec | |||
e93b8032d8 | |||
5de2d8c7fb | |||
e355fd3d2e | |||
d41ef99c85 | |||
5ec18d6e01 | |||
b4cd3a319c | |||
d894bfa167 | |||
d74db948ba | |||
3ef26c747b | |||
38c8220e9e | |||
86f8259b33 | |||
502db14bba | |||
ef12ada5d7 | |||
977b2b302d | |||
17d02a3d1c | |||
6100ff4c4e | |||
8bb73fb25e | |||
d6cce4ae15 | |||
058304d16b | |||
345d34a2e1 | |||
3839a49d47 | |||
0afe0929a3 | |||
a14a1fbd10 | |||
52f0a6958a | |||
8bdde98db1 | |||
19fc900045 | |||
6bdd9b882a | |||
0d97d428fa | |||
a0b42d7bdb | |||
69ba312a96 | |||
a0c13214e6 | |||
4c8829df28 | |||
3ee3e95410 | |||
806deeaf78 | |||
feb121707d | |||
31c7f034ec | |||
30ab92652c | |||
0407548113 | |||
277845626c | |||
b2af8b970e | |||
542866e18b | |||
f54192809f | |||
f3ba62fd88 | |||
8d4a07302b | |||
d504231124 | |||
173b1e118c | |||
ffba276f0d | |||
b210608e56 | |||
74353104dc | |||
825136d1c9 | |||
b2fea471f1 | |||
e9adb8b0ed | |||
5d6bc039d0 | |||
27638063c8 | |||
f6a4d78ab7 | |||
4061e31400 | |||
74db67689f | |||
2213eb28cb | |||
d1b45d416b | |||
f72f7e7514 | |||
0165cfb3e5 | |||
ef747486c0 | |||
e0b2f59c2f | |||
82bdb301f9 | |||
c7ea26e422 | |||
34b2029efe | |||
37e610d2b3 | |||
4882235d20 | |||
1552ebde11 | |||
d263d0c8a5 | |||
610b2388bb | |||
bcb16cef9b | |||
0f3afd94f3 | |||
60eb686d05 | |||
7f5e43fba9 | |||
ed52ef358b | |||
214afab711 | |||
18a1677588 | |||
cae372e9ad | |||
ea5f9a48ab | |||
dcf755e756 | |||
d445c21ea1 | |||
6db0449ed0 | |||
ae37b1980f | |||
96f76906c4 | |||
19d9619785 | |||
5be195fd91 | |||
e36e9e1cf4 | |||
102d6aa55c | |||
daea8d2868 | |||
700a74fd4c | |||
32a84a5ad0 | |||
3c9f9474ce | |||
1e10686315 | |||
cae6405d9a | |||
a884ce94e5 | |||
065c17de74 | |||
09db2c528a | |||
2adfe532dd | |||
6cbe40cecb | |||
6b9467393e | |||
5125e77431 | |||
ab68ae0092 | |||
38079b6171 | |||
d584290f3d | |||
9b9baa9b4a | |||
c258310560 | |||
af0bf5ced5 | |||
57c480a6c6 | |||
25f7423533 | |||
0c068bb03b | |||
1822473abc | |||
93a7d607b2 | |||
d45213636c | |||
e196d9d917 | |||
cf88e50afd | |||
64e5814c31 | |||
37251c84f8 | |||
a576098639 | |||
2450fe83ce | |||
e1004440d2 | |||
491c7abd1c | |||
364ce6d856 | |||
ffb6b73bb7 | |||
6041c39a26 | |||
c54f0a52f6 | |||
6b87d9c038 | |||
1285304f97 | |||
58fae6b201 | |||
dc1f3aebe9 | |||
8a189161f2 | |||
6667595627 | |||
33befaab09 | |||
c91f135c28 | |||
08f9926e60 | |||
f323b293fb | |||
adc91929b0 | |||
c63cba5a0c | |||
e65e7d6a32 | |||
7a48da440b | |||
05dda37b71 | |||
fc87a73259 | |||
ec4c4fb5c4 | |||
ee43585210 | |||
870c222dd5 | |||
a6eb8e01df | |||
8c45c30753 | |||
d18cfbc26f | |||
f4af5f9e33 | |||
69adbbc1c1 | |||
4f6a9f734c | |||
8b78f2d200 | |||
26a3fa6946 | |||
f955a18936 | |||
ee1a7818b6 | |||
8e455f1097 | |||
827c46cf47 | |||
61cbee829d | |||
f0ad1e9194 | |||
bbd339f0e4 | |||
858af64dc3 | |||
01e34c1b28 | |||
41acb475a9 | |||
20978f8c24 | |||
265a3dbe21 | |||
627f5b4bf0 | |||
1538c1aaeb | |||
839661e5f8 | |||
fff6244597 | |||
b2280f64a1 | |||
21d53c41d0 | |||
6e94bbb5e5 | |||
7d655cd3f7 | |||
00821677c8 | |||
784de3e430 | |||
3213c4838d | |||
1b9bc8eb1d | |||
bf58d0b864 | |||
28ca8392ed | |||
5238c55bc2 | |||
901f10c387 | |||
defa22ffe5 | |||
84919c0cc0 | |||
1e8ca123b0 | |||
3ae7c6aedf | |||
6a3ed4bbf8 | |||
e632d323c9 | |||
d2b35ab8f2 | |||
e60f39df41 | |||
076431e04d | |||
75ab44403c | |||
e2d6097819 | |||
ab12ff1257 | |||
25a0212f4e | |||
a8993f14d6 | |||
1834cd86da | |||
437de27ed8 | |||
96f08482da | |||
edec2eca7a | |||
9202524d83 | |||
0461907533 | |||
6b3d1d5579 | |||
445a2896d2 | |||
e2d8f1b6b1 | |||
7baa696a76 | |||
3f7ca6bbff | |||
36e1c5fe6a | |||
75a03f1576 | |||
437e83ab78 | |||
b8232f7a02 | |||
49eadb0efc | |||
40dc90e585 | |||
0de302d192 | |||
80bab95f6c | |||
ba3d551c9f | |||
d14fe31f97 | |||
057f41e355 | |||
8c9b61b37a | |||
11e54b3e2c | |||
fa7cb0bef1 | |||
3977c8ab3b | |||
e8f92efe05 | |||
994df8531b | |||
3cdf96ee0c | |||
e2f55d52e9 | |||
d6fa33035a | |||
f11bca728f | |||
596761d78d | |||
8a3c8d4664 | |||
fdfce79e87 | |||
88340aa336 | |||
d0f53fdd4b | |||
d657f61e11 | |||
20e6b98770 | |||
5ae824358c | |||
3ea106bd22 | |||
538264dec5 | |||
6bcd1c2c24 | |||
120c3a7bbe | |||
2654799822 | |||
6245635b86 | |||
b4f1c4dd6a | |||
25a7ce3742 | |||
08bc069cbf | |||
0ebdcc30ed | |||
3eca81d3f5 | |||
faefbae3a1 | |||
370fb098ac | |||
c73019d84c | |||
250a1de71e | |||
012963e90a | |||
632f3cd19b | |||
5bca7d155f | |||
1c8cd325d7 | |||
7bcdaab2f2 | |||
5b58e520f9 | |||
78f6ea6c44 | |||
b5172e73f9 | |||
5cf534ad26 | |||
d53cdb0558 | |||
212adbbffb | |||
99ab2f0ef5 | |||
a8201b2658 | |||
f13e676c3b | |||
61b01836bc | |||
2ee918b845 | |||
db7c4da609 | |||
9c11653313 | |||
e9579d75c4 | |||
97824f1bb5 | |||
884c134b25 | |||
4f3cb49076 | |||
152285ed5a | |||
49b7ac212d | |||
83450e6277 | |||
6d6155c742 | |||
f8da2c311b | |||
f6bcaef5b5 | |||
1a9e71bfa1 | |||
3591e11637 | |||
47533cf4e2 | |||
de03f19b46 | |||
d1472368f6 | |||
b83d2c388f | |||
ee5425bef7 | |||
3fdbca939e | |||
c68dc8c52a | |||
96471ecb45 | |||
a13f898ad3 | |||
b4cce534a5 | |||
e0698554ad | |||
1649d2a0fa | |||
9683e89159 | |||
2bece0bb61 | |||
deb6c42d86 | |||
2b0953bb19 | |||
d25d22508c | |||
6db37eb4fb | |||
af461f8418 | |||
8bdbd1de39 | |||
1bdc93ef59 | |||
c12101fbc6 | |||
d5ba6578b3 | |||
b37aefdc8d | |||
0be7c26798 | |||
bf1d10e893 | |||
7dfb016faa | |||
b2aeb2d83c | |||
8f4c78e2a8 | |||
bd1f5898a8 | |||
05a4ef1702 | |||
da9e6d6664 | |||
e9d3853d93 | |||
5a9d6120a5 | |||
e8410ff692 | |||
3427d220c7 | |||
643e3c2f84 | |||
9b40b5e55e | |||
a622c210ef | |||
9495f30e2d | |||
617af87065 | |||
9aab68a8f8 | |||
c1dd421b27 | |||
8eff6bd0cf | |||
8566c64eab | |||
afd468277e | |||
ca9c992237 | |||
c93b74661b | |||
08ff092638 | |||
2276572902 | |||
43ddeec6e1 | |||
2100b7b7d2 | |||
2cf1cce06d | |||
4ca44d335d | |||
358d578cd7 | |||
c61d24d8d4 | |||
9eaf04f4c7 | |||
c3c29bb119 | |||
ddb34e6a46 | |||
ef3055430b | |||
75cdae1473 | |||
860afe8f28 | |||
f685dbe0d1 | |||
50911fff57 | |||
a7064f4728 | |||
564e9600ea | |||
fcc4202598 | |||
bfbe59cb84 | |||
06abde2425 | |||
75c3c2f985 | |||
fefefdd473 | |||
db59474f1e | |||
1d5e806ff4 | |||
bf4885c7cf | |||
3b289be5ce | |||
2bb7e08ade | |||
b571a7550f | |||
721de30587 | |||
f16126e948 | |||
40d1a3a7c2 | |||
0d4c7a5fc0 | |||
5d401dfb27 | |||
a37c9d8f2f | |||
10ab3c70bf | |||
591b2f4e04 | |||
2536fbe752 | |||
33549d5ec3 | |||
720c6172e3 | |||
bbad2f5cde | |||
d2a0baa221 | |||
ad62f5459b | |||
dfb910defb | |||
04b6d8e54a | |||
d2dded860d | |||
38f2638ea0 | |||
2b874e3f69 | |||
b43ed12c84 | |||
59be381213 | |||
172c333357 | |||
c5eb3d5670 | |||
44b95f2f15 | |||
bd888219fc | |||
2842619196 | |||
b2de74a0e6 | |||
7aa4134e2b | |||
cc36ea7542 | |||
c11af71ed7 | |||
a9d4ebc898 | |||
d2f82052b4 | |||
f88a309d55 | |||
418adca9f3 | |||
993f8f81f7 | |||
99718784f1 | |||
59fc1ed632 | |||
cb74868247 | |||
bd6ae2c0dc | |||
60a599a550 | |||
4ac55a787e | |||
cb52a1ef42 | |||
7827d158d7 | |||
535f2d75b0 | |||
4f8d435e16 | |||
5ecdb48d43 | |||
a1b9be453b | |||
2502fe7f39 | |||
02487fbb22 | |||
2abff6991f | |||
49e85275c3 | |||
96efdf8b1a | |||
b52a4adaff | |||
a9fc40dad4 | |||
b609a17362 | |||
4b49fdbf8e | |||
fd52c8cf47 | |||
a54c2714db | |||
ad4a843a1e | |||
183062a977 | |||
e685da8cc2 | |||
eea38a6709 | |||
9fdd07e7fe | |||
d8b60d82f3 | |||
629e6a5095 | |||
65c5177daf | |||
b741db3050 | |||
82fef4c2b1 | |||
e45e7ffe06 | |||
099eb1d202 | |||
9da9f31c77 | |||
820e5edc1e | |||
0f1f398e6d | |||
b5503e7b9b | |||
5a005365b2 | |||
2a5e3729e0 | |||
ebc7dca949 | |||
fa710d1ba6 | |||
4b19131dbd | |||
cb699e17b3 | |||
c2c05b0140 | |||
3263984f03 | |||
6f6f1e249c | |||
6380b2d8f3 | |||
9938a8bcc0 | |||
ac5b15d0e3 | |||
ec5a678f05 | |||
bf80311ef7 | |||
58346a8937 | |||
f33d6da65a | |||
9e8d67c4a9 | |||
cbbc4a80e7 | |||
1f51fd7a31 | |||
120d97bc64 | |||
a531713214 | |||
564a055316 | |||
6c29c4fb1f | |||
edbb4ce9f2 | |||
e2574ec23b | |||
3ef8f5311d | |||
552580bc47 | |||
0998d43b8f | |||
b08354494c | |||
f54b9a197d | |||
2d4412ce51 | |||
b566b0f765 | |||
384d144a85 | |||
c97d15cb9f | |||
dfe986331d | |||
72c32378c5 | |||
0c79c0ac83 | |||
1dfc27ba08 | |||
427dc86915 | |||
7bc00926eb | |||
fb65bb4207 | |||
a1cd5e9573 | |||
5497dabaf9 | |||
58dc6fe389 | |||
34c3285426 | |||
cb42c74a8d | |||
a5afce458d | |||
2f687125d1 | |||
8f133ff93a | |||
1f12e159ef |
@ -7,6 +7,7 @@ indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal 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']
|
9
.github/ISSUE_TEMPLATE.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Thank you for raising an issue to `docx`
|
||||
|
||||
Please do not raise an issue unless it is an **issue**.
|
||||
|
||||
- Is your issue a feature request? Are you giving ideas to the community? Are you asking for help? Please raise a ticket in the `Discussions` section:
|
||||
|
||||
https://github.com/dolanmiu/docx/discussions
|
||||
|
||||
- Is your issue a previously asked? Please respond to that thread instead
|
40
.github/dependabot.yml
vendored
Normal file
40
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: "@types/node"
|
||||
versions:
|
||||
- 14.14.22
|
||||
- 14.14.24
|
||||
- 14.14.25
|
||||
- 14.14.26
|
||||
- 14.14.28
|
||||
- 14.14.29
|
||||
- 14.14.30
|
||||
- 15.0.0
|
||||
- dependency-name: webpack
|
||||
versions:
|
||||
- 5.31.2
|
||||
- 5.35.0
|
||||
- dependency-name: ts-loader
|
||||
versions:
|
||||
- 9.1.0
|
||||
- dependency-name: awesome-typescript-loader
|
||||
versions:
|
||||
- 5.2.1
|
||||
- dependency-name: chai
|
||||
versions:
|
||||
- 4.2.0
|
||||
- 4.3.0
|
||||
- 4.3.1
|
||||
- 4.3.3
|
||||
- dependency-name: replace-in-file
|
||||
versions:
|
||||
- 6.1.0
|
||||
- dependency-name: "@types/chai"
|
||||
versions:
|
||||
- 4.2.14
|
60
.github/workflows/default.yml
vendored
Normal file
60
.github/workflows/default.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
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
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
verbose: true
|
||||
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
|
690
.github/workflows/demos.yml
vendored
Normal file
690
.github/workflows/demos.yml
vendored
Normal file
@ -0,0 +1,690 @@
|
||||
name: Demos
|
||||
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
|
||||
demos:
|
||||
name: Run Demos and Validate
|
||||
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 Demo
|
||||
run: npm run ts-node -- ./demo/1-basic.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/2-declaritive-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/4-basic-table.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/5-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/6-page-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/7-landscape.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/8-header-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/10-my-cv.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/11-declaritive-styles-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/12-scaling-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/13-xml-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/14-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/15-page-break-before.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/16-multiple-sections.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/17-footnotes.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/18-image-from-buffer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/19-export-to-base64.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/20-table-cell-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/21-bookmarks.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# Bad ID - need numeric ID
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/22-right-to-left-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/23-base64-images.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/24-images-to-table-cell.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/25-table-xml-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/26-paragraph-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/27-declaritive-styles-3.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/28-table-of-contents.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/29-numbered-lists.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/30-template-document.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/31-tables.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/33-sequential-captions.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/34-floating-tables.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element tblpPr: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblpPr', attribute 'overlap': The attribute 'overlap' is not allowed.
|
||||
# element tblpPr: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tblpPr': Element content is not allowed, because the content type is empty.
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/35-hyperlinks.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/36-image-to-table-cell.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/37-images-to-header-and-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/38-text-wrapping.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/39-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/40-line-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/41-merge-table-cells-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/42-restart-page-numbers.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/43-images-to-table-cell-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/44-multiple-columns.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/45-highlighting-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/46-shading-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/47-number-of-total-pages-section.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/48-vertical-align.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/49-table-borders.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/50-readme-demo.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/51-character-styles.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/52-japanese.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/53-chinese.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/54-custom-properties.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/55-math.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
#: element subHide: Schemas validity error : Element '{http://schemas.openxmlformats.org/officeDocument/2006/math}subHide': This element is not expected. Expected is ( {http://schemas.openxmlformats.org/officeDocument/2006/math}ctrlPr ).
|
||||
#: element e: Schemas validity error : Element '{http://schemas.openxmlformats.org/officeDocument/2006/math}e': This element is not expected. Expected is ( {http://schemas.openxmlformats.org/officeDocument/2006/math}sub ).
|
||||
#: element e: Schemas validity error : Element '{http://schemas.openxmlformats.org/officeDocument/2006/math}e': This element is not expected. Expected is ( {http://schemas.openxmlformats.org/officeDocument/2006/math}sup ).
|
||||
#: element e: Schemas validity error : Element '{http://schemas.openxmlformats.org/officeDocument/2006/math}e': This element is not expected. Expected is ( {http://schemas.openxmlformats.org/officeDocument/2006/math}sub ).
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/56-background-color.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/57-add-parent-numbered-lists.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/58-section-types.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/59-header-footer-margins.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/60-track-revisions.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/61-text-frame.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element left: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}left': This element is not expected. Expected is one of ( {http://schemas.openxmlformats.org/wordprocessingml/2006/main}right, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}between, {http://schemas.openxmlformats.org/wordprocessingml/2006/main}bar ).
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/62-paragraph-spacing.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/63-odd-even-header-footer.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/64-complex-numbering-text.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/65-page-sizes.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/66-fields.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
# element bookmarkStart: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}bookmarkStart', attribute '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}id': '-irrswq-ln94j4fdgdjxs' is not a valid value of the atomic type '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_DecimalNumber'.
|
||||
# element bookmarkEnd: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}bookmarkEnd', attribute '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}id': '-irrswq-ln94j4fdgdjxs' is not a valid value of the atomic type '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_DecimalNumber'.
|
||||
# - name: Validate XML
|
||||
# uses: ChristophWurst/xmllint-action@v1
|
||||
# with:
|
||||
# xml-file: build/extracted-doc/word/document.xml
|
||||
# xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/67-column-break.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/68-numbering-instances-and-starting-number.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/69-different-width-columns.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/70-line-numbers-suppression.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
||||
- name: Run Demo
|
||||
run: npm run ts-node -- ./demo/71-page-borders-2.ts
|
||||
- name: Extract Word Document
|
||||
run: npm run extract
|
||||
- name: Validate XML
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: build/extracted-doc/word/document.xml
|
||||
xml-schema-file: ooxml-schemas/microsoft/wml-2010.xsd
|
43
.github/workflows/github-pages.yml
vendored
Normal file
43
.github/workflows/github-pages.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: Github Pages
|
||||
on:
|
||||
push:
|
||||
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 typedoc
|
||||
echo "docx.js.org" > docs/.nojekyll
|
||||
echo "docx.js.org" > docs/CNAME
|
||||
- name: Archive Production Artifact
|
||||
uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: docs
|
||||
path: docs
|
||||
deploy:
|
||||
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: docs
|
||||
path: docs
|
||||
- name: Deploy 🚀
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.5
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: docs
|
26
.github/workflows/remove-old-artifacts.yml
vendored
Normal file
26
.github/workflows/remove-old-artifacts.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Remove old artifacts
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Every day at 1am
|
||||
- cron: "0 1 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
logLevel:
|
||||
description: "Log level"
|
||||
required: true
|
||||
default: "warning"
|
||||
|
||||
jobs:
|
||||
remove-old-artifacts:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Remove old artifacts
|
||||
uses: c-hive/gha-remove-artifacts@v1
|
||||
with:
|
||||
age: "1 week"
|
||||
# Optional inputs
|
||||
# skip-tags: true
|
||||
# skip-recent: 5
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -52,7 +52,6 @@ docs/.nojekyll
|
||||
.idea
|
||||
|
||||
# Lock files
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# Documents
|
||||
|
12
.nycrc
12
.nycrc
@ -1,14 +1,15 @@
|
||||
{
|
||||
"check-coverage": true,
|
||||
"lines": 87.54,
|
||||
"functions": 83.61,
|
||||
"branches": 72.57,
|
||||
"statements": 87.32,
|
||||
"lines": 99.32,
|
||||
"functions": 99.11,
|
||||
"branches": 96.27,
|
||||
"statements": 99.32,
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"src/**/*.spec.ts"
|
||||
"src/**/*.spec.ts",
|
||||
"src/import-dotx/import-dotx.ts"
|
||||
],
|
||||
"reporter": [
|
||||
"lcov",
|
||||
@ -20,6 +21,5 @@
|
||||
],
|
||||
"cache": true,
|
||||
"all": true,
|
||||
"instrument": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
|
63
.travis.yml
63
.travis.yml
@ -1,63 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 9
|
||||
install:
|
||||
- npm install
|
||||
- npm install -g codecov
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run test.coverage
|
||||
- npm run style
|
||||
- npm run build
|
||||
- npm run ts-node -- ./demo/demo1.ts
|
||||
- npm run e2e "My Document.docx"
|
||||
- npm run ts-node -- ./demo/demo2.ts
|
||||
- npm run ts-node -- ./demo/demo3.ts
|
||||
- npm run ts-node -- ./demo/demo4.ts
|
||||
- npm run ts-node -- ./demo/demo5.ts
|
||||
- npm run ts-node -- ./demo/demo6.ts
|
||||
- npm run ts-node -- ./demo/demo7.ts
|
||||
- npm run ts-node -- ./demo/demo8.ts
|
||||
- npm run ts-node -- ./demo/demo9.ts
|
||||
- npm run ts-node -- ./demo/demo10.ts
|
||||
- npm run e2e "My Document.docx"
|
||||
- npm run ts-node -- ./demo/demo11.ts
|
||||
- npm run ts-node -- ./demo/demo12.ts
|
||||
- npm run ts-node -- ./demo/demo13.ts
|
||||
- npm run ts-node -- ./demo/demo14.ts
|
||||
- npm run ts-node -- ./demo/demo15.ts
|
||||
- npm run ts-node -- ./demo/demo16.ts
|
||||
- npm run ts-node -- ./demo/demo17.ts
|
||||
- npm run ts-node -- ./demo/demo18.ts
|
||||
- npm run ts-node -- ./demo/demo19.ts
|
||||
- npm run ts-node -- ./demo/demo20.ts
|
||||
- npm run ts-node -- ./demo/demo21.ts
|
||||
- npm run ts-node -- ./demo/demo22.ts
|
||||
- npm run ts-node -- ./demo/demo23.ts
|
||||
- npm run ts-node -- ./demo/demo24.ts
|
||||
# - npm run ts-node -- ./demo/demo25.ts
|
||||
- npm run ts-node -- ./demo/demo26.ts
|
||||
- npm run ts-node -- ./demo/demo27.ts
|
||||
- npm run ts-node -- ./demo/demo28.ts
|
||||
- npm run ts-node -- ./demo/demo29.ts
|
||||
- npm run ts-node -- ./demo/demo30.ts
|
||||
- npm run ts-node -- ./demo/demo31.ts
|
||||
- npm run ts-node -- ./demo/demo32.ts
|
||||
# - npm run e2e "My Document.docx" // Need to fix
|
||||
- npm run ts-node -- ./demo/demo33.ts
|
||||
- npm run ts-node -- ./demo/demo34.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
|
45
README.md
45
README.md
@ -10,7 +10,7 @@
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![Downloads per month][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
|
||||
[![Dependency Status][daviddm-image]][daviddm-url]
|
||||
[![Known Vulnerabilities][snky-image]][snky-url]
|
||||
[![Chat on Gitter][gitter-image]][gitter-url]
|
||||
@ -18,7 +18,7 @@
|
||||
[![codecov][codecov-image]][codecov-url]
|
||||
|
||||
<p align="center">
|
||||
<img src="https://i.imgur.com/H5FA1Qy.gif" alt="drawing" width="800"/>
|
||||
<img src="https://i.imgur.com/QeL1HuU.png" alt="drawing"/>
|
||||
</p>
|
||||
|
||||
# Demo
|
||||
@ -27,12 +27,21 @@
|
||||
|
||||
Here are examples of `docx` being used with basic `HTML/JS` in a browser environment:
|
||||
|
||||
* https://codepen.io/anon/pen/dqoVgQ
|
||||
* https://jsfiddle.net/3xhezb5w/2
|
||||
* https://codepen.io/dolanmiu/pen/RwNeObg
|
||||
* https://jsfiddle.net/dolanmiu/onadx1gu/
|
||||
|
||||
Here is an example of `docx` working in `Angular`:
|
||||
|
||||
* https://stackblitz.com/edit/angular-afvxtz
|
||||
* https://stackblitz.com/edit/angular-docx
|
||||
|
||||
Here is an example of `docx` working in `React`:
|
||||
|
||||
* https://stackblitz.com/edit/react-docx
|
||||
* https://stackblitz.com/edit/react-docx-images (adding images to Word Document)
|
||||
|
||||
Here is an example of `docx` working in `Vue.js`:
|
||||
|
||||
* https://stackblitz.com/edit/vuejs-docx
|
||||
|
||||
## Node
|
||||
|
||||
@ -50,7 +59,7 @@ Press `endpoint` on the `RunKit` website:
|
||||
* https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
|
||||
* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
|
||||
|
||||
More [here](https://docx.js.org/#/examples) and [here](https://github.com/dolanmiu/docx/tree/master/demo)
|
||||
More [here](https://github.com/dolanmiu/docx/tree/master/demo)
|
||||
|
||||
# How to use & Documentation
|
||||
|
||||
@ -58,7 +67,7 @@ Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/
|
||||
|
||||
# Examples
|
||||
|
||||
Check the `examples` section in the [documentation](https://docx.js.org/#/examples) and the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
||||
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
||||
|
||||
# Contributing
|
||||
|
||||
@ -66,9 +75,21 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
|
||||
|
||||
# Used by
|
||||
|
||||
[<img src="https://i.imgur.com/zy5qWmI.png" alt="drawing" height="200"/>](https://hfour.com/)
|
||||
[<img src="https://i.imgur.com/OYP5tgS.png" alt="drawing" height="200"/>](https://fuzzproductions.com/)
|
||||
[<img src="https://i.imgur.com/zUDMfZ3.png" alt="drawing" height="200"/>](https://www.mettzer.com/)
|
||||
[<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://i.imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
|
||||
[<img src="https://i.imgur.com/fn1xccG.png" alt="drawing" height="50"/>](http://www.ativer.com.br/)
|
||||
[<img src="https://i.imgur.com/cmykN7c.png" alt="drawing" />](https://www.arity.co/)
|
||||
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
||||
|
||||
|
||||
...and many more!
|
||||
|
||||
---
|
||||
|
||||
@ -81,8 +102,8 @@ Made with 💖
|
||||
[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
|
||||
|
31
demo/1-basic.ts
Normal file
31
demo/1-basic.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
new TextRun({
|
||||
text: "\tGithub is the best",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
389
demo/10-my-cv.ts
Normal file
389
demo/10-my-cv.ts
Normal file
@ -0,0 +1,389 @@
|
||||
// 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";
|
||||
|
||||
interface Experience {
|
||||
readonly isCurrent: boolean;
|
||||
readonly summary: string;
|
||||
readonly title: string;
|
||||
readonly startDate: {
|
||||
readonly month: number;
|
||||
readonly year: number;
|
||||
};
|
||||
readonly endDate?: {
|
||||
readonly month: number;
|
||||
readonly year: number;
|
||||
};
|
||||
readonly company: {
|
||||
readonly name: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface Education {
|
||||
readonly degree: string;
|
||||
readonly fieldOfStudy: string;
|
||||
readonly notes: string;
|
||||
readonly schoolName: string;
|
||||
readonly startDate: {
|
||||
readonly year: number;
|
||||
};
|
||||
readonly endDate: {
|
||||
readonly year: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface Skill {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
interface Achivement {
|
||||
readonly issuer: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
const experiences: Experience[] = [
|
||||
{
|
||||
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: 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: Skill[] = [
|
||||
{
|
||||
name: "Angular",
|
||||
},
|
||||
{
|
||||
name: "TypeScript",
|
||||
},
|
||||
{
|
||||
name: "JavaScript",
|
||||
},
|
||||
{
|
||||
name: "NodeJS",
|
||||
},
|
||||
];
|
||||
|
||||
const achievements: Achivement[] = [
|
||||
{
|
||||
issuer: "Oracle",
|
||||
name: "Oracle Certified Expert",
|
||||
},
|
||||
];
|
||||
|
||||
class DocumentCreator {
|
||||
// tslint:disable-next-line: typedef
|
||||
public create([experiences, educations, skills, achivements]: [Experience[], Education[], Skill[], Achivement[]]): Document {
|
||||
const document = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Dolan Miu",
|
||||
heading: HeadingLevel.TITLE,
|
||||
}),
|
||||
this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL),
|
||||
this.createHeading("Education"),
|
||||
...educations
|
||||
.map((education) => {
|
||||
const arr: Paragraph[] = [];
|
||||
arr.push(
|
||||
this.createInstitutionHeader(
|
||||
education.schoolName,
|
||||
`${education.startDate.year} - ${education.endDate.year}`,
|
||||
),
|
||||
);
|
||||
arr.push(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
|
||||
|
||||
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({
|
||||
text: "Address: 58 Elm Avenue, Kent ME4 6ER, UK",
|
||||
break: 1,
|
||||
}),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
314
demo/11-declaritive-styles-2.ts
Normal file
314
demo/11-declaritive-styles-2.ts
Normal file
@ -0,0 +1,314 @@
|
||||
// Setting styles with JavaScript configuration
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
AlignmentType,
|
||||
convertInchesToTwip,
|
||||
Document,
|
||||
Footer,
|
||||
HeadingLevel,
|
||||
ImageRun,
|
||||
Packer,
|
||||
Paragraph,
|
||||
Table,
|
||||
TableCell,
|
||||
TableRow,
|
||||
TabStopPosition,
|
||||
UnderlineType,
|
||||
LevelFormat,
|
||||
} from "../build";
|
||||
|
||||
const table = new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Test cell 1.")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Test cell 2.")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Test cell 3.")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Test cell 4.")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
numbering:{
|
||||
config:[{
|
||||
reference: 'ref1',
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: '%1)',
|
||||
start: 50,
|
||||
}
|
||||
],
|
||||
}]
|
||||
},
|
||||
styles: {
|
||||
default: {
|
||||
heading1: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 52,
|
||||
bold: true,
|
||||
color: "000000",
|
||||
underline: {
|
||||
type: UnderlineType.SINGLE,
|
||||
color: "000000",
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.CENTER,
|
||||
spacing: { line: 340 },
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 340 },
|
||||
},
|
||||
},
|
||||
heading3: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: { line: 276 },
|
||||
},
|
||||
},
|
||||
heading4: {
|
||||
run: {
|
||||
font: "Calibri",
|
||||
size: 26,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
alignment: AlignmentType.JUSTIFIED,
|
||||
},
|
||||
},
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
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: convertInchesToTwip(0.5) },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "wellSpaced",
|
||||
name: "Well Spaced",
|
||||
basedOn: "Normal",
|
||||
paragraph: {
|
||||
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "numberedPara",
|
||||
name: "Numbered 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,
|
||||
numbering : {
|
||||
reference: 'ref1',
|
||||
instance: 0,
|
||||
level: 0,
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
margin: {
|
||||
top: 700,
|
||||
right: 700,
|
||||
bottom: 700,
|
||||
left: 700,
|
||||
},
|
||||
},
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "1",
|
||||
style: "normalPara",
|
||||
alignment: AlignmentType.RIGHT,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "HEADING",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
alignment: AlignmentType.CENTER,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Ref. :",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Date :",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "To,",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "The Superindenting Engineer,(O &M)",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Sub : ",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Ref. : ",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Sir,",
|
||||
style: "normalPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "BRIEF DESCRIPTION",
|
||||
style: "normalPara",
|
||||
}),
|
||||
table,
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Test",
|
||||
style: "normalPara2",
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Test 2",
|
||||
style: "normalPara2",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Numbered paragraph that has numbering attached to custom styles",
|
||||
style: "numberedPara",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Numbered para would show up in the styles pane at Word",
|
||||
style: "numberedPara",
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
62
demo/12-scaling-images.ts
Normal file
62
demo/12-scaling-images.ts
Normal file
@ -0,0 +1,62 @@
|
||||
// Scaling images
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, ImageRun, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph("Hello World"),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 50,
|
||||
height: 50,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 250,
|
||||
height: 250,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 400,
|
||||
height: 400,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
33
demo/13-xml-styles.ts
Normal file
33
demo/13-xml-styles.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// 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,
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Cool Heading Text",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: 'This is a custom named style from the template "MyFancyStyle"',
|
||||
style: "MyFancyStyle",
|
||||
}),
|
||||
new Paragraph("Some normal text"),
|
||||
new Paragraph({
|
||||
text: "MyFancyStyle again",
|
||||
style: "MyFancyStyle",
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
80
demo/14-page-numbers.ts
Normal file
80
demo/14-page-numbers.ts
Normal file
@ -0,0 +1,80 @@
|
||||
// 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, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
titlePage: true,
|
||||
},
|
||||
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],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("My Title "),
|
||||
new TextRun({
|
||||
children: ["Footer - Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
first: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("First Page Footer "),
|
||||
new TextRun({
|
||||
children: ["Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [new TextRun("First Page"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph("Second Page"),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
22
demo/15-page-break-before.ts
Normal file
22
demo/15-page-break-before.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
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);
|
||||
});
|
147
demo/16-multiple-sections.ts
Normal file
147
demo/16-multiple-sections.ts
Normal file
@ -0,0 +1,147 @@
|
||||
// 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, NumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [new Paragraph("First Default Header on another page")],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [new Paragraph("Footer on another page")],
|
||||
}),
|
||||
},
|
||||
|
||||
children: [new Paragraph("hello")],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.LANDSCAPE,
|
||||
},
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [new Paragraph("Second Default Header on another page")],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [new Paragraph("Footer on another page")],
|
||||
}),
|
||||
},
|
||||
children: [new Paragraph("hello in landscape")],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
children: ["Page number: ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
|
||||
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
},
|
||||
pageNumbers: {
|
||||
formatType: NumberFormat.UPPER_ROMAN,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
children: ["Page number: ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph(
|
||||
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
},
|
||||
pageNumbers: {
|
||||
start: 25,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
children: ["Page number: ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph(
|
||||
"Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section.",
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
55
demo/17-footnotes.ts
Normal file
55
demo/17-footnotes.ts
Normal 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: {
|
||||
1: { children: [new Paragraph("Foo"), new Paragraph("Bar")] },
|
||||
2: { children: [new Paragraph("Test")] },
|
||||
3: { children: [new Paragraph("My amazing reference")] },
|
||||
4: { children: [new Paragraph("Foo1")] },
|
||||
5: { children: [new Paragraph("Test1")] },
|
||||
6: { children: [new Paragraph("My amazing reference1")] },
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new 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)],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
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);
|
||||
});
|
@ -1,17 +1,30 @@
|
||||
// Insert image from a buffer
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer } from "../build";
|
||||
|
||||
const doc = new Document();
|
||||
import { Document, ImageRun, Packer, Paragraph } from "../build";
|
||||
|
||||
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyAjHSAjHR4hHR4hHR4hHx8iHyAjHyAjHyAjHSAhHR4hHR4hHR4hHx8jHyAjHyAjHyAjHyC9S2xeAAAA7nRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFxgZGhscHR4fICEiIyQlJicoKSorLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZISUpLTE1OUFFSU1RVVllaW1xdXmBhYmNkZWZnaGprbG1ub3Byc3R1dnd4eXp8fn+AgYKDhIWGiImKi4yNj5CRkpOUlZaXmJmam5ydnp+goaKjpKaoqqusra6vsLGys7S1tri5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+fkZpVQAABcBJREFUGBntwftjlQMcBvDnnLNL22qzJjWlKLHFVogyty3SiFq6EZliqZGyhnSxsLlMRahYoZKRFcul5dKFCatYqWZaNKvWtrPz/A2+7/b27qRzec/lPfvl/XxgMplMJpPJZDKZAtA9HJ3ppnIez0KnSdtC0RCNznHdJrbrh85wdSlVVRaEXuoGamYi5K5430HNiTiEWHKJg05eRWgNfKeV7RxbqUhGKPV/207VupQ8is0IoX5vtFC18SqEHaK4GyHTZ2kzVR8PBTCO4oANIZL4ShNVZcOhKKeYg9DoWdhI1ec3os2VFI0JCIUez5+i6st0qJZRrEAIJCw+QdW223BG/EmKwTBc/IJ/qfp2FDrkUnwFo8U9dZyqnaPhxLqfYjyM1S3vb6p+GGOBszsojoTDSDFz6qj66R4LzvYJxVMwUNRjf1H1ywQr/megg2RzLximy8waqvbda8M5iijegVEiHjlM1W/3h+FcXesphsMY4dMOUnUgOxyuPEzxPQwRNvV3qg5Nj4BreyimwADWe/dRVTMjEm6MoGLzGwtystL6RyOY3qSqdlYU3FpLZw1VW0sK5943MvUCKwJ1noNtjs6Ohge76Zq9ZkfpigU5WWkDYuCfbs1U5HWFR8/Qq4a9W0uK5k4ZmdrTCl8spGIePLPlbqqsc1Afe83O0hULc8alDYiBd7ZyitYMeBfR55rR2fOKP6ioPk2dGvZ+UVI0d8rtqT2tcCexlqK2F3wRn5Q+YVbBqrLKOupkr9lZujAOrmS0UpTb4JeIPkNHZ+cXr6uoPk2vyuBSPhWLEKj45PQJuQWryyqP0Z14uGLdROHIRNBEXDR09EP5r62rOHCazhrD4VKPwxTH+sIA3ZPTJ+YuWV22n+IruHFDC8X2CBjnPoolcGc2FYUwzmsUWXDHsoGKLBhmN0VvuBVfTVE/AAbpaid5CB4MbaLY1QXGuIViLTyZQcVyGGMuxWPwaA0Vk2GI9RRp8Ci2iuLkIBjhT5LNUfAspZFiTwyC72KK7+DNg1SsRvCNp3gZXq2k4iEEXSHFJHgVXUlxejCCbTvFAHiXdIJiXxyCK7KJ5FHoMZGK9xBcwyg2QpdlVMxEUM2iyIMuXXZQNF+HswxMsSAAJRQjoE//eoqDCXBSTO6f1xd+O0iyNRY6jaWi1ALNYCocZROj4JdEikroVkjFk9DcStXxpdfCD2MoXodu4RUU9ptxxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
|
||||
|
||||
// doc.createImage(Buffer.from(imageBase64Data, 'base64'));
|
||||
doc.createImage(Buffer.from(imageBase64Data, "base64"), 100, 100);
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: Buffer.from(imageBase64Data, "base64"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
30
demo/19-export-to-base64.ts
Normal file
30
demo/19-export-to-base64.ts
Normal file
@ -0,0 +1,30 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
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);
|
||||
});
|
192
demo/2-declaritive-styles.ts
Normal file
192
demo/2-declaritive-styles.ts
Normal file
@ -0,0 +1,192 @@
|
||||
// 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,
|
||||
convertInchesToTwip,
|
||||
Document,
|
||||
HeadingLevel,
|
||||
LevelFormat,
|
||||
Packer,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
UnderlineType,
|
||||
} from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
creator: "Clippy",
|
||||
title: "Sample Document",
|
||||
description: "A brief example of using docx",
|
||||
styles: {
|
||||
default: {
|
||||
heading1: {
|
||||
run: {
|
||||
size: 28,
|
||||
bold: true,
|
||||
italics: true,
|
||||
color: "FF0000",
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
size: 26,
|
||||
bold: true,
|
||||
underline: {
|
||||
type: UnderlineType.DOUBLE,
|
||||
color: "FF0000",
|
||||
},
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 240,
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
listParagraph: {
|
||||
run: {
|
||||
color: "#FF0000",
|
||||
},
|
||||
},
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: "aside",
|
||||
name: "Aside",
|
||||
basedOn: "Normal",
|
||||
next: "Normal",
|
||||
run: {
|
||||
color: "999999",
|
||||
italics: true,
|
||||
},
|
||||
paragraph: {
|
||||
indent: {
|
||||
left: convertInchesToTwip(0.5),
|
||||
},
|
||||
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 },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
reference: "my-crazy-numbering",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.LOWER_LETTER,
|
||||
text: "%1)",
|
||||
alignment: AlignmentType.LEFT,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
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,
|
||||
},
|
||||
style: "aside",
|
||||
}),
|
||||
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.",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
style: "Strong",
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Strong Style",
|
||||
}),
|
||||
new TextRun({
|
||||
text: " - Very strong.",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
107
demo/20-table-cell-borders.ts
Normal file
107
demo/20-table-cell-borders.ts
Normal file
@ -0,0 +1,107 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Hello")],
|
||||
borders: {
|
||||
top: {
|
||||
style: BorderStyle.DASH_DOT_STROKED,
|
||||
size: 3,
|
||||
color: "FF0000",
|
||||
},
|
||||
bottom: {
|
||||
style: BorderStyle.DOUBLE,
|
||||
size: 3,
|
||||
color: "0000FF",
|
||||
},
|
||||
left: {
|
||||
style: BorderStyle.DASH_DOT_STROKED,
|
||||
size: 3,
|
||||
color: "00FF00",
|
||||
},
|
||||
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: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
77
demo/21-bookmarks.ts
Normal file
77
demo/21-bookmarks.ts
Normal file
@ -0,0 +1,77 @@
|
||||
// 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, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun, PageReference } 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",
|
||||
sections: [
|
||||
{
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new InternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Click here!",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
anchor: "myAnchorId",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
children: [
|
||||
new Bookmark({
|
||||
id: "myAnchorId",
|
||||
children: [new TextRun("Lorem Ipsum")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph("\n"),
|
||||
new Paragraph(LOREM_IPSUM),
|
||||
new Paragraph({
|
||||
children: [new PageBreak()],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new InternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Styled",
|
||||
bold: true,
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
new TextRun({
|
||||
text: " Anchor Text",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
anchor: "myAnchorId",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [new TextRun("The bookmark can be seen on page "), new PageReference("myAnchorId")],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
71
demo/22-right-to-left-text.ts
Normal file
71
demo/22-right-to-left-text.ts
Normal file
@ -0,0 +1,71 @@
|
||||
// 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, Table, TableCell, TableRow, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
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,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Table({
|
||||
visuallyRightToLeft: true,
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("שלום עולם")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("שלום עולם")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,34 +1,86 @@
|
||||
// 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 } from "../build";
|
||||
|
||||
const doc = new Document();
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png"));
|
||||
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"));
|
||||
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/parrots.bmp"));
|
||||
const image5 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
||||
import { Document, ImageRun, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const imageBase64Data = `iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAACzVBMVEUAAAAAAAAAAAAAAAA/AD8zMzMqKiokJCQfHx8cHBwZGRkuFxcqFSonJyckJCQiIiIfHx8eHh4cHBwoGhomGSYkJCQhISEfHx8eHh4nHR0lHBwkGyQjIyMiIiIgICAfHx8mHh4lHh4kHR0jHCMiGyIhISEgICAfHx8lHx8kHh4jHR0hHCEhISEgICAlHx8kHx8jHh4jHh4iHSIhHCEhISElICAkHx8jHx8jHh4iHh4iHSIhHSElICAkICAjHx8jHx8iHh4iHh4hHiEhHSEkICAjHx8iHx8iHx8hHh4hHiEkHSEjHSAjHx8iHx8iHx8hHh4kHiEkHiEjHSAiHx8hHx8hHh4kHiEjHiAjHSAiHx8iHx8hHx8kHh4jHiEjHiAjHiAiICAiHx8kHx8jHh4jHiEjHiAiHiAiHSAiHx8jHx8jHx8jHiAiHiAiHiAiHSAiHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8jHx8iHiAiHiAiHiAjHx8jHx8jHx8iHx8iHSAiHiAjHiAjHx8jHx8hHx8iHx8iHyAiHiAjHiAjHiAjHh4hHx8iHx8iHx8iHyAjHSAjHiAjHiAjHh4hHx8iHx8iHx8jHyAjHiAhHh4iHx8iHx8jHyAjHSAjHSAhHiAhHh4iHx8iHx8jHx8jHyAjHSAjHSAiHh4iHh4jHx8jHx8jHyAjHyAhHSAhHSAiHh4iHh4jHx8jHx8jHyAhHyAhHSAiHSAiHh4jHh4jHx8jHx8jHyAhHyAhHSAiHSAjHR4jHh4jHx8jHx8hHyAhHyAiHSAjHSAjHR4jHh4jHx8hHx8hHyAhHyAiHyAjHSAjHR4jHR4hHh4hHx8hHyAiHyAjHyAjHSAjHR4jHR4hHh4hHx8hHyAjHyAjHyAjHSAjHR4hHR4hHR4hHx8iHyAjHyAjHyAjHSAhHR4hHR4hHR4hHx8jHyAjHyAjHyAjHyC9S2xeAAAA7nRSTlMAAQIDBAUGBwgJCgsMDQ4PEBESExQVFxgZGhscHR4fICEiIyQlJicoKSorLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZISUpLTE1OUFFSU1RVVllaW1xdXmBhYmNkZWZnaGprbG1ub3Byc3R1dnd4eXp8fn+AgYKDhIWGiImKi4yNj5CRkpOUlZaXmJmam5ydnp+goaKjpKaoqqusra6vsLGys7S1tri5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+fkZpVQAABcBJREFUGBntwftjlQMcBvDnnLNL22qzJjWlKLHFVogyty3SiFq6EZliqZGyhnSxsLlMRahYoZKRFcul5dKFCatYqWZaNKvWtrPz/A2+7/b27qRzec/lPfvl/XxgMplMJpPJZDKZAtA9HJ3ppnIez0KnSdtC0RCNznHdJrbrh85wdSlVVRaEXuoGamYi5K5430HNiTiEWHKJg05eRWgNfKeV7RxbqUhGKPV/207VupQ8is0IoX5vtFC18SqEHaK4GyHTZ2kzVR8PBTCO4oANIZL4ShNVZcOhKKeYg9DoWdhI1ec3os2VFI0JCIUez5+i6st0qJZRrEAIJCw+QdW223BG/EmKwTBc/IJ/qfp2FDrkUnwFo8U9dZyqnaPhxLqfYjyM1S3vb6p+GGOBszsojoTDSDFz6qj66R4LzvYJxVMwUNRjf1H1ywQr/megg2RzLximy8waqvbda8M5iijegVEiHjlM1W/3h+FcXesphsMY4dMOUnUgOxyuPEzxPQwRNvV3qg5Nj4BreyimwADWe/dRVTMjEm6MoGLzGwtystL6RyOY3qSqdlYU3FpLZw1VW0sK5943MvUCKwJ1noNtjs6Ohge76Zq9ZkfpigU5WWkDYuCfbs1U5HWFR8/Qq4a9W0uK5k4ZmdrTCl8spGIePLPlbqqsc1Afe83O0hULc8alDYiBd7ZyitYMeBfR55rR2fOKP6ioPk2dGvZ+UVI0d8rtqT2tcCexlqK2F3wRn5Q+YVbBqrLKOupkr9lZujAOrmS0UpTb4JeIPkNHZ+cXr6uoPk2vyuBSPhWLEKj45PQJuQWryyqP0Z14uGLdROHIRNBEXDR09EP5r62rOHCazhrD4VKPwxTH+sIA3ZPTJ+YuWV22n+IruHFDC8X2CBjnPoolcGc2FYUwzmsUWXDHsoGKLBhmN0VvuBVfTVE/AAbpaid5CB4MbaLY1QXGuIViLTyZQcVyGGMuxWPwaA0Vk2GI9RRp8Ci2iuLkIBjhT5LNUfAspZFiTwyC72KK7+DNg1SsRvCNp3gZXq2k4iEEXSHFJHgVXUlxejCCbTvFAHiXdIJiXxyCK7KJ5FHoMZGK9xBcwyg2QpdlVMxEUM2iyIMuXXZQNF+HswxMsSAAJRQjoE//eoqDCXBSTO6f1xd+O0iyNRY6jaWi1ALNYCocZROj4JdEikroVkjFk9DcStXxpdfCD2MoXodu4RUU9ptxxmXssOfxnvDVcxRTod9FxyhqLoAqis5aPhwTDp9spRgEH2Q6KLbYoKqlaKTm6Isp0C/sJMnjFvhiERXPQvUNRe9p29lhR04CdBpC8Sl8YiuncIxEuzUUg4Dkgj+paVozygY9plPMh28SaymO9kabAopREGF3vt9MzeFFl8G7lRSZ8FFGK8XX4VA8QjEd7XrM3M0OXz8YCy+qKBLgq3wqnofiTorF0Ax56Rg1J1elW+BBAsVe+My6iYq7IK6keBdOIseV2qn5Pb8f3MqkWAXf9ThM8c8lAOIotuFsF875lRrH5klRcG0+xcPwQ1oLxfeRAP4heQTnGL78X2rqlw2DK59SXAV/zKaiGMAuko5InCt68mcOan5+ohf+z1pP8lQY/GHZQMV4YD3FpXDp4qerqbF/lBWBswyi+AL+ia+maLgcRRQj4IYlY/UpauqKBsPJAxQF8NM1TRQ/RudSPAD34rK3scOuR8/HGcspxsJfOVS8NZbiGXiUtPgINU3v3WFDmx8pEuG3EiqKKVbCC1vm2iZqap5LAtCtleQf8F9sFYWDohzeJczYyQ4V2bEZFGsQgJRGqqqhS2phHTWn9lDkIhBTqWqxQZ+IsRvtdHY9AvI2VX2hW68nfqGmuQsCEl3JdjfCF8OW1bPdtwhQ0gm2mQzfRE3a7KCYj0BNZJs8+Kxf/r6WtTEI2FIqlsMfFgRB5A6KUnSe/vUkX0AnuvUIt8SjM1m6wWQymUwmk8lkMgXRf5vi8rLQxtUhAAAAAElFTkSuQmCC`;
|
||||
const image6 = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100, 100);
|
||||
|
||||
// I am adding an image to the paragraph rather than the document to make the image inline
|
||||
paragraph.addImage(image5);
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/dog.png"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: Buffer.from(imageBase64Data, "base64"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
doc.addImage(image);
|
||||
doc.addImage(image2);
|
||||
doc.addImage(image3);
|
||||
doc.addImage(image4);
|
||||
doc.addImage(image5);
|
||||
doc.addImage(image6);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
97
demo/24-images-to-table-cell.ts
Normal file
97
demo/24-images-to-table-cell.ts
Normal file
@ -0,0 +1,97 @@
|
||||
// Add image to table cell
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Hello")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
51
demo/25-table-xml-styles.ts
Normal file
51
demo/25-table-xml-styles.ts
Normal file
@ -0,0 +1,51 @@
|
||||
// Example of how you would create a table and add data to it
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
|
||||
|
||||
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
||||
|
||||
// Create a table and pass the XML Style
|
||||
const table = new Table({
|
||||
style: "MyCustomTableStyle",
|
||||
width: {
|
||||
size: 9070,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Header Colum 1")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Header Colum 2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Column Content 3")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Column Content 2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
title: "Title",
|
||||
externalStyles: styles,
|
||||
sections: [
|
||||
{
|
||||
children: [table],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
35
demo/26-paragraph-borders.ts
Normal file
35
demo/26-paragraph-borders.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 { BorderStyle, Document, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph("No border!"),
|
||||
new Paragraph({
|
||||
text: "I have borders on my top and bottom sides!",
|
||||
border: {
|
||||
top: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
bottom: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
68
demo/27-declaritive-styles-3.ts
Normal file
68
demo/27-declaritive-styles-3.ts
Normal file
@ -0,0 +1,68 @@
|
||||
// Custom styles using JavaScript configuration
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, convertInchesToTwip, 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: convertInchesToTwip(0.5),
|
||||
},
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
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);
|
||||
});
|
67
demo/28-table-of-contents.ts
Normal file
67
demo/28-table-of-contents.ts
Normal file
@ -0,0 +1,67 @@
|
||||
// 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";
|
||||
|
||||
// WordprocessingML docs for TableOfContents can be found here:
|
||||
// http://officeopenxml.com/WPtableOfContents.php
|
||||
|
||||
// Let's define the properties for generate a TOC for heading 1-5 and MySpectacularStyle,
|
||||
// making the entries be hyperlinks for the paragraph
|
||||
const doc = new File({
|
||||
features: {
|
||||
updateFields: true,
|
||||
},
|
||||
styles: {
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: "MySpectacularStyle",
|
||||
name: "My Spectacular Style",
|
||||
basedOn: "Heading1",
|
||||
next: "Heading1",
|
||||
quickFormat: true,
|
||||
run: {
|
||||
italics: true,
|
||||
color: "990000",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new TableOfContents("Summary", {
|
||||
hyperlink: true,
|
||||
headingStyleRange: "1-5",
|
||||
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Header #1",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
pageBreakBefore: true,
|
||||
}),
|
||||
new Paragraph("I'm a little text very nicely written.'"),
|
||||
new Paragraph({
|
||||
text: "Header #2",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
pageBreakBefore: true,
|
||||
}),
|
||||
new Paragraph("I'm a other text very nicely written.'"),
|
||||
new Paragraph({
|
||||
text: "Header #2.1",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
new Paragraph("I'm a another text very nicely written.'"),
|
||||
new Paragraph({
|
||||
text: "My Spectacular Style #1",
|
||||
style: "MySpectacularStyle",
|
||||
pageBreakBefore: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
285
demo/29-numbered-lists.ts
Normal file
285
demo/29-numbered-lists.ts
Normal file
@ -0,0 +1,285 @@
|
||||
// Numbered lists
|
||||
// The lists can also be restarted by specifying the instance number
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.UPPER_ROMAN,
|
||||
text: "%1",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
reference: "my-crazy-reference",
|
||||
},
|
||||
{
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
reference: "my-number-numbering-reference",
|
||||
},
|
||||
{
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL_ZERO,
|
||||
text: "[%1]",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
reference: "padded-numbering-reference",
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "line with contextual spacing",
|
||||
numbering: {
|
||||
reference: "my-crazy-reference",
|
||||
level: 0,
|
||||
},
|
||||
contextualSpacing: true,
|
||||
spacing: {
|
||||
before: 200,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "line with contextual spacing",
|
||||
numbering: {
|
||||
reference: "my-crazy-reference",
|
||||
level: 0,
|
||||
},
|
||||
contextualSpacing: true,
|
||||
spacing: {
|
||||
before: 200,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "line without contextual spacing",
|
||||
numbering: {
|
||||
reference: "my-crazy-reference",
|
||||
level: 0,
|
||||
},
|
||||
contextualSpacing: false,
|
||||
spacing: {
|
||||
before: 200,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "line without contextual spacing",
|
||||
numbering: {
|
||||
reference: "my-crazy-reference",
|
||||
level: 0,
|
||||
},
|
||||
contextualSpacing: false,
|
||||
spacing: {
|
||||
before: 200,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 1 - Add sugar",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 2 - Add wheat",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 3 - Put in oven",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Next",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
instance: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
instance: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Next",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
instance: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
instance: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
instance: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Next",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "test",
|
||||
numbering: {
|
||||
reference: "padded-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
256
demo/3-numbering-and-bullet-points.ts
Normal file
256
demo/3-numbering-and-bullet-points.ts
Normal file
@ -0,0 +1,256 @@
|
||||
// Numbering and bullet points example
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
reference: "my-crazy-numbering",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.UPPER_ROMAN,
|
||||
text: "%1",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 1,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%2.",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.68) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 2,
|
||||
format: LevelFormat.LOWER_LETTER,
|
||||
text: "%3)",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(1.5), hanging: convertInchesToTwip(1.18) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 3,
|
||||
format: LevelFormat.UPPER_LETTER,
|
||||
text: "%4)",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: 2880, hanging: 2420 },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
reference: "my-unique-bullet-points",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.BULLET,
|
||||
text: "\u1F60",
|
||||
alignment: AlignmentType.LEFT,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.25) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 1,
|
||||
format: LevelFormat.BULLET,
|
||||
text: "\u00A5",
|
||||
alignment: AlignmentType.LEFT,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.25) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 2,
|
||||
format: LevelFormat.BULLET,
|
||||
text: "\u273F",
|
||||
alignment: AlignmentType.LEFT,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: 2160, hanging: convertInchesToTwip(0.25) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 3,
|
||||
format: LevelFormat.BULLET,
|
||||
text: "\u267A",
|
||||
alignment: AlignmentType.LEFT,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: 2880, hanging: convertInchesToTwip(0.25) },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 4,
|
||||
format: LevelFormat.BULLET,
|
||||
text: "\u2603",
|
||||
alignment: AlignmentType.LEFT,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: 3600, hanging: convertInchesToTwip(0.25) },
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Hello World 2",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Yeah boi",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
bullet: {
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
bullet: {
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Hello World 2",
|
||||
bullet: {
|
||||
level: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Yeah boi",
|
||||
bullet: {
|
||||
level: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "101 MSXFM",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "back to level 1",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "back to level 0",
|
||||
numbering: {
|
||||
reference: "my-crazy-numbering",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Custom Bullet points",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Hey you",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "What's up fam",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Hello World 2",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Yeah boi",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 3,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "my Awesome numbering",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 4,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Back to level 1",
|
||||
numbering: {
|
||||
reference: "my-unique-bullet-points",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -12,19 +12,23 @@ fs.readFile(filePath, (err, data) => {
|
||||
}
|
||||
|
||||
importDotx.extract(data).then((templateDocument) => {
|
||||
// This any needs fixing
|
||||
const sectionProps = {
|
||||
const doc = new Document(
|
||||
{
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
titlePage: templateDocument.titlePageIsDefined,
|
||||
} as any;
|
||||
|
||||
const doc = new Document(undefined, sectionProps, {
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
template: templateDocument,
|
||||
});
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
doc.addParagraph(paragraph);
|
||||
},
|
||||
);
|
||||
|
||||
const packer = new Packer();
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
||||
});
|
78
demo/31-tables.ts
Normal file
78
demo/31-tables.ts
Normal file
@ -0,0 +1,78 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
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,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
409
demo/32-merge-and-shade-table-cells.ts
Normal file
409
demo/32-merge-and-shade-table-cells.ts
Normal file
@ -0,0 +1,409 @@
|
||||
// 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,
|
||||
convertInchesToTwip,
|
||||
Document,
|
||||
HeadingLevel,
|
||||
Packer,
|
||||
Paragraph,
|
||||
ShadingType,
|
||||
Table,
|
||||
TableCell,
|
||||
TableRow,
|
||||
WidthType,
|
||||
} from "../build";
|
||||
|
||||
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: convertInchesToTwip(0.69),
|
||||
bottom: convertInchesToTwip(0.69),
|
||||
left: convertInchesToTwip(0.69),
|
||||
right: convertInchesToTwip(0.69),
|
||||
},
|
||||
columnSpan: 3,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
width: {
|
||||
size: 100,
|
||||
type: WidthType.AUTO,
|
||||
},
|
||||
columnWidths: [convertInchesToTwip(0.69), convertInchesToTwip(0.69), convertInchesToTwip(0.69)],
|
||||
});
|
||||
|
||||
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",
|
||||
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||
color: "auto",
|
||||
},
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Bar2")],
|
||||
shading: {
|
||||
fill: "42c5f4",
|
||||
type: ShadingType.PERCENT_95,
|
||||
color: "auto",
|
||||
},
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Bar3")],
|
||||
shading: {
|
||||
fill: "880aa8",
|
||||
type: ShadingType.PERCENT_10,
|
||||
color: "e2df0b",
|
||||
},
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("Bar4")],
|
||||
shading: {
|
||||
fill: "FF0000",
|
||||
type: ShadingType.CLEAR,
|
||||
color: "auto",
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
width: {
|
||||
size: convertInchesToTwip(4.86),
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
margins: {
|
||||
top: convertInchesToTwip(0.27),
|
||||
bottom: convertInchesToTwip(0.27),
|
||||
right: convertInchesToTwip(0.27),
|
||||
left: convertInchesToTwip(0.27),
|
||||
},
|
||||
});
|
||||
|
||||
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: "FF0000",
|
||||
},
|
||||
bottom: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "FF0000",
|
||||
},
|
||||
left: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "FF0000",
|
||||
},
|
||||
right: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "FF0000",
|
||||
},
|
||||
};
|
||||
|
||||
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,
|
||||
},
|
||||
});
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
table,
|
||||
new Paragraph({
|
||||
text: "Another table",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
table2,
|
||||
new Paragraph({
|
||||
text: "Another table",
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
table3,
|
||||
new Paragraph("Merging columns 1"),
|
||||
table4,
|
||||
new Paragraph("Merging columns 2"),
|
||||
table5,
|
||||
new Paragraph("Merging columns 3"),
|
||||
table6,
|
||||
new Paragraph("Merging columns 4"),
|
||||
table7,
|
||||
new Paragraph("Merging columns 5"),
|
||||
table8,
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
49
demo/33-sequential-captions.ts
Normal file
49
demo/33-sequential-captions.ts
Normal file
@ -0,0 +1,49 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
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);
|
||||
});
|
68
demo/34-floating-tables.ts
Normal file
68
demo/34-floating-tables.ts
Normal file
@ -0,0 +1,68 @@
|
||||
// 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 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,
|
||||
leftFromText: 1000,
|
||||
rightFromText: 2000,
|
||||
topFromText: 1500,
|
||||
bottomFromText: 30,
|
||||
},
|
||||
width: {
|
||||
size: 4535,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
layout: TableLayoutType.FIXED,
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [table],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
151
demo/35-hyperlinks.ts
Normal file
151
demo/35-hyperlinks.ts
Normal file
@ -0,0 +1,151 @@
|
||||
// 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, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
footnotes: {
|
||||
1: {
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Click here for the "),
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Footnotes external hyperlink",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "http://www.example.com",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Click here for the "),
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Footer external hyperlink",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "http://www.example.com",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
headers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Click here for the "),
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Header external hyperlink",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "http://www.google.com",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Anchor Text",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "http://www.example.com",
|
||||
}),
|
||||
new FootnoteReferenceRun(1),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
link: "http://www.google.com",
|
||||
}),
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "BBC News Link",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "https://www.bbc.co.uk/news",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "This is a hyperlink with formatting: ",
|
||||
}),
|
||||
new ExternalHyperlink({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "A ",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
new TextRun({
|
||||
text: "single ",
|
||||
bold: true,
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
new TextRun({
|
||||
text: "link",
|
||||
doubleStrike: true,
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
new TextRun({
|
||||
text: "1",
|
||||
superScript: true,
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
new TextRun({
|
||||
text: "!",
|
||||
style: "Hyperlink",
|
||||
}),
|
||||
],
|
||||
link: "http://www.example.com",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
85
demo/36-image-to-table-cell.ts
Normal file
85
demo/36-image-to-table-cell.ts
Normal file
@ -0,0 +1,85 @@
|
||||
// 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, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
||||
|
||||
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({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
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
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [table],
|
||||
}),
|
||||
},
|
||||
children: [table],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
55
demo/37-images-to-header-and-footer.ts
Normal file
55
demo/37-images-to-header-and-footer.ts
Normal file
@ -0,0 +1,55 @@
|
||||
// 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, ImageRun, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
54
demo/38-text-wrapping.ts
Normal file
54
demo/38-text-wrapping.ts
Normal file
@ -0,0 +1,54 @@
|
||||
// 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, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
|
||||
),
|
||||
new Paragraph(
|
||||
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
|
||||
),
|
||||
new Paragraph(
|
||||
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
|
||||
),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
},
|
||||
floating: {
|
||||
horizontalPosition: {
|
||||
offset: 2014400,
|
||||
},
|
||||
verticalPosition: {
|
||||
offset: 2014400,
|
||||
},
|
||||
wrap: {
|
||||
type: TextWrappingType.SQUARE,
|
||||
side: TextWrappingSide.BOTH_SIDES,
|
||||
},
|
||||
margins: {
|
||||
top: 201440,
|
||||
bottom: 201440,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
75
demo/39-page-numbers.ts
Normal file
75
demo/39-page-numbers.ts
Normal file
@ -0,0 +1,75 @@
|
||||
// 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, NumberFormat, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
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],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
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);
|
||||
});
|
132
demo/4-basic-table.ts
Normal file
132
demo/4-basic-table.ts
Normal file
@ -0,0 +1,132 @@
|
||||
// Example of how you would create a table and add data to it
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "../build";
|
||||
|
||||
const table = new Table({
|
||||
columnWidths: [3505, 5505],
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 3505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [new Paragraph("Hello")],
|
||||
}),
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 5505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 3505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 5505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [new Paragraph("World")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const table2 = new Table({
|
||||
columnWidths: [4505, 4505],
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 4505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [new Paragraph("Hello")],
|
||||
}),
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 4505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 4505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
width: {
|
||||
size: 4505,
|
||||
type: WidthType.DXA,
|
||||
},
|
||||
children: [new Paragraph("World")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const table3 = new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph("Hello")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("World")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({ text: "Table with skewed widths" }),
|
||||
table,
|
||||
new Paragraph({ text: "Table with equal widths" }),
|
||||
table2,
|
||||
new Paragraph({ text: "Table without setting widths" }),
|
||||
table3,
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
33
demo/40-line-numbers.ts
Normal file
33
demo/40-line-numbers.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
lineNumbers: {
|
||||
countBy: 1,
|
||||
restart: LineNumberRestartFormat.CONTINUOUS,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hello",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph(
|
||||
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
|
||||
),
|
||||
new Paragraph(
|
||||
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
263
demo/41-merge-table-cells-2.ts
Normal file
263
demo/41-merge-table-cells-2.ts
Normal file
@ -0,0 +1,263 @@
|
||||
// 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 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: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [table, new Paragraph(""), table2],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
93
demo/42-restart-page-numbers.ts
Normal file
93
demo/42-restart-page-numbers.ts
Normal file
@ -0,0 +1,93 @@
|
||||
// Page numbers - Start from 0 on a new section
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("My Title "),
|
||||
new TextRun({
|
||||
children: ["Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
first: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("First Page Header "),
|
||||
new TextRun({
|
||||
children: ["Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [new TextRun("First Page"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph("Second Page"),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
separator: PageNumberSeparator.EM_DASH,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("My Title "),
|
||||
new TextRun({
|
||||
children: ["Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
first: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun("First Page Header of Second section"),
|
||||
new TextRun({
|
||||
children: ["Page ", PageNumber.CURRENT],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [new TextRun("Third Page"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph("Fourth Page"),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
86
demo/43-images-to-table-cell-2.ts
Normal file
86
demo/43-images-to-table-cell-2.ts
Normal file
@ -0,0 +1,86 @@
|
||||
// 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 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: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [table],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
56
demo/44-multiple-columns.ts
Normal file
56
demo/44-multiple-columns.ts
Normal file
@ -0,0 +1,56 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
column: {
|
||||
space: 708,
|
||||
count: 2,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph("This text will be split into 2 columns on a page."),
|
||||
new Paragraph(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
column: {
|
||||
space: 708,
|
||||
count: 3,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph("This text will be split into 3 columns on a page."),
|
||||
new Paragraph(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
column: {
|
||||
space: 708,
|
||||
count: 2,
|
||||
separate: true,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph("This text will be split into 2 columns on a page."),
|
||||
new Paragraph(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
37
demo/45-highlighting-text.ts
Normal file
37
demo/45-highlighting-text.ts
Normal file
@ -0,0 +1,37 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Hello World",
|
||||
color: "FF0000",
|
||||
bold: true,
|
||||
size: 24,
|
||||
font: {
|
||||
name: "Garamond",
|
||||
},
|
||||
highlight: "yellow",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
66
demo/46-shading-text.ts
Normal file
66
demo/46-shading-text.ts
Normal file
@ -0,0 +1,66 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Hello World",
|
||||
color: "FF0000",
|
||||
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: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
emboss: true,
|
||||
text: "Embossed text - hello world",
|
||||
}),
|
||||
new TextRun({
|
||||
imprint: true,
|
||||
text: "Imprinted text - hello world",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
76
demo/47-number-of-total-pages-section.ts
Normal file
76
demo/47-number-of-total-pages-section.ts
Normal file
@ -0,0 +1,76 @@
|
||||
// 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, NumberFormat, Paragraph, TextRun } from "../build";
|
||||
|
||||
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. ")],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: header,
|
||||
},
|
||||
footers: {
|
||||
default: footer,
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [new TextRun("Section 1"), new PageBreak(), new TextRun("Section 1"), new PageBreak()],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
pageNumbers: {
|
||||
start: 1,
|
||||
formatType: NumberFormat.DECIMAL,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: header,
|
||||
},
|
||||
footers: {
|
||||
default: footer,
|
||||
},
|
||||
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);
|
||||
});
|
33
demo/48-vertical-align.ts
Normal file
33
demo/48-vertical-align.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// 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, VerticalAlign, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
verticalAlign: VerticalAlign.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);
|
||||
});
|
167
demo/49-table-borders.ts
Normal file
167
demo/49-table-borders.ts
Normal file
@ -0,0 +1,167 @@
|
||||
// Add custom borders and no-borders to the table itself
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
BorderStyle,
|
||||
Document,
|
||||
HeadingLevel,
|
||||
Packer,
|
||||
Paragraph,
|
||||
Table,
|
||||
TableBorders,
|
||||
TableCell,
|
||||
TableRow,
|
||||
TextDirection,
|
||||
VerticalAlign,
|
||||
} from "../build";
|
||||
|
||||
const table = new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
borders: {
|
||||
top: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "ff0000",
|
||||
},
|
||||
bottom: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "ff0000",
|
||||
},
|
||||
left: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "ff0000",
|
||||
},
|
||||
right: {
|
||||
style: BorderStyle.DASH_SMALL_GAP,
|
||||
size: 1,
|
||||
color: "ff0000",
|
||||
},
|
||||
},
|
||||
children: [new Paragraph("Hello")],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph("World")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// Using the no-border convenience object. It is the same as writing this manually:
|
||||
// const borders = {
|
||||
// top: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// bottom: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// left: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// right: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// insideHorizontal: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// insideVertical: {
|
||||
// style: BorderStyle.NONE,
|
||||
// size: 0,
|
||||
// color: "auto",
|
||||
// },
|
||||
// };
|
||||
const noBorderTable = new Table({
|
||||
borders: TableBorders.NONE,
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [new Paragraph({}), new Paragraph({})],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph({}), new Paragraph({})],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
|
||||
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
|
||||
}),
|
||||
new TableCell({
|
||||
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
|
||||
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text:
|
||||
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "This text should be in the middle of the cell",
|
||||
}),
|
||||
],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
}),
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Text above should be vertical from bottom to top",
|
||||
}),
|
||||
],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
}),
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Text above should be vertical from top to bottom",
|
||||
}),
|
||||
],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [{ children: [table, new Paragraph("Hello"), noBorderTable] }],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
136
demo/5-images.ts
Normal file
136
demo/5-images.ts
Normal file
@ -0,0 +1,136 @@
|
||||
// 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,
|
||||
HorizontalPositionAlign,
|
||||
HorizontalPositionRelativeFrom,
|
||||
ImageRun,
|
||||
Packer,
|
||||
Paragraph,
|
||||
VerticalPositionAlign,
|
||||
VerticalPositionRelativeFrom,
|
||||
} from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph("Hello World"),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/dog.png").toString("base64"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
flip: {
|
||||
vertical: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 150,
|
||||
height: 150,
|
||||
flip: {
|
||||
horizontal: true,
|
||||
},
|
||||
rotation: 225,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
flip: {
|
||||
horizontal: true,
|
||||
vertical: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
rotation: 45,
|
||||
},
|
||||
floating: {
|
||||
zIndex: 10,
|
||||
horizontalPosition: {
|
||||
offset: 1014400,
|
||||
},
|
||||
verticalPosition: {
|
||||
offset: 1014400,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
},
|
||||
floating: {
|
||||
zIndex: 5,
|
||||
horizontalPosition: {
|
||||
relative: HorizontalPositionRelativeFrom.PAGE,
|
||||
align: HorizontalPositionAlign.RIGHT,
|
||||
},
|
||||
verticalPosition: {
|
||||
relative: VerticalPositionRelativeFrom.PAGE,
|
||||
align: VerticalPositionAlign.BOTTOM,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
94
demo/50-readme-demo.ts
Normal file
94
demo/50-readme-demo.ts
Normal file
@ -0,0 +1,94 @@
|
||||
// The demo on the README.md
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
|
||||
|
||||
const table = new Table({
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
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({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hello World",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
table,
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
58
demo/51-character-styles.ts
Normal file
58
demo/51-character-styles.ts
Normal file
@ -0,0 +1,58 @@
|
||||
// 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,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "strong",
|
||||
name: "Strong",
|
||||
basedOn: "Normal",
|
||||
run: {
|
||||
bold: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "Foo bar",
|
||||
style: "myRedStyle",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "First Word",
|
||||
style: "strong",
|
||||
}),
|
||||
new TextRun({
|
||||
text:
|
||||
" - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
38
demo/52-japanese.ts
Normal file
38
demo/52-japanese.ts
Normal file
@ -0,0 +1,38 @@
|
||||
// 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",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "KFCを食べるのが好き",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "こんにちは",
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
91
demo/53-chinese.ts
Normal file
91
demo/53-chinese.ts
Normal file
@ -0,0 +1,91 @@
|
||||
// Chinese text - Chinese text need to use a Chinese font. And ascii text need to use a ascii font.
|
||||
// Different from the `52-japanese.ts`.
|
||||
// `52-japanese.ts` will set all characters to use Japanese font.
|
||||
// `53-chinese.ts` will set Chinese characters to use Chinese font, and set ascii characters to use ascii font.
|
||||
|
||||
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
|
||||
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
styles: {
|
||||
default: {
|
||||
document: {
|
||||
run: {
|
||||
font: {
|
||||
ascii: "minorHAnsi",
|
||||
eastAsia: "minorEastAsia",
|
||||
cs: "minorBidi",
|
||||
hAnsi: "minorHAnsi",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: "Normal",
|
||||
name: "Normal",
|
||||
basedOn: "Normal",
|
||||
next: "Normal",
|
||||
quickFormat: true,
|
||||
run: {
|
||||
font: {
|
||||
ascii: "minorHAnsi", // Can also use minorHAnsi
|
||||
eastAsia: "minorEastAsia", // Can also use minorEastAsia
|
||||
cs: "minorBidi",
|
||||
hAnsi: "minorHAnsi",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "中文和英文 Chinese and English",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "中文和英文 Chinese and English",
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: "中文和英文 Chinese and English",
|
||||
font: { eastAsia: "SimSun" }, // set eastAsia to "SimSun".
|
||||
// The ascii characters will use the default font ("Times") specified in paragraphStyles
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
text: `店様付旅母正役基社発破班。発治治京岡局本因追意金紀統責郵滴尽。立功日庁重天富評界明済不着法返祉経正引行。載区列防新目治日群付無人道言越名。界安無死専体風木人教録覧訃。女問堂容県作先芸便効証帯債土全極的日。能山中岡仕関攻井季接店線幌温後率事阜止。成間路行究今式歌像祉帯式媛読徹。安行息古入出文侵監株登部席内文第珍鶴問用。
|
||||
|
||||
編竹入俳多応日氏陸福芸北供動。情績拠僧肺軍油能認郷翌南対韓短東食束兵晶。政予任習口佐所当止市告号。悩申無式立医毎部観潟訴菱権。発臼背郎上予配光記芸注然出。梨場株以政囲下球品材県動政押婚面見。米共試使落帳遅毅間三子開。問与大八地芸第線体架辺今死。押構草齢戦重最変社豪記目盗連報準周込。系貸劇様重鷲始能質村異社学動導勤。
|
||||
|
||||
残様的荻仲刺局標績供質球就雄。考和母問者役尊紙推新経革個事編安観。益学北日著楽車山勢流泉四犯投台戒設対臨百。危謄初治穴委済本索労刊回。月写政覧女事棋違年終索情響白子泉転企堀社。江遊著西高開面毎分芸責成創査全判調目止懇。原育会夏作売望人転乱融抜心。制川供健水示囲阜厚高右断季人役。持面必日暮気管像冬間影図健行格阪。
|
||||
|
||||
来入工速会健評下町慮大貸社一見園外申憶。服豊舞入面沢交使奥見記写意岩。北観提女刊液城共五擦相売田合是由読。回歳売苦定記点郎意増賛治北渡本応。受送文携村陸情静了申注際。順負子研済老上変女産第内無費携投展達。東初乗回動合語学待聴暮沢流全場導敷記賞次。更物中備著後渡売第部時禁新田木下昨。備護起織服久権意全海馬適応。
|
||||
|
||||
幸速団供地信討川安矛場消学年。去茂玉東今要出約元教負限載始今簡。編掲証的情仕渡室手映法部始。紙反語清阪曜税受知選謝個印観聞。教人超死準無者参生撤技真価椿景破市見国。左需臓道力趣暮際丁高会近部敗岡力当社。壊態毒期波超長写島断兆国世行共絞私報。反野番点図択女撃脱案情王援。減属考論月院催者門料約覧市戦。
|
||||
|
||||
山部午金査投立集争教殺巣作世動北部応。通負考隙問粛中帯閉要程規化小。橋棋互界時引就現省竹去子無系容米。竹転起日本新田強済購書区庁集作容同会窓教。文公神転待究挙登投川選囲針能楽路断出歌。祥新現寄公史真玉属元始員金抜関前百衝能。国眺暮囲世嘘面外営国内報夜九掲事春葉。来月刊台先良理著自供法投。通渡請当月学安首一押実展介況。
|
||||
|
||||
法優分独込右得里記域目順供進乗。憂婚転峰大写医投社曲題任能務熱県展覧港専。栄余歯真著改追事作果石芸。青感将南便再転領鈴投提鉄索競虎師体物想。牲打迎達携度開技書催掲安去変念座。革混疑生採就枢当住回県組北意寛。爆新和級掲交象温十賛展木開有結日。新海辺小除京物興量写界裁上。文師建関面取質也底沼画者図空医心無季。
|
||||
|
||||
高館湯転名気業以際置講詰方活礎組調軽際。発変東作訪乃小化理利提目気。極季本問号面帯勤戦行新禁情堀郎携。座所転再祥業必変昌今歩佐王立抗後養崩。支物猪躍芸整縦焦供防続相護治時語朝分刊定。綿田幸崎責本欲間載神調崎答志政報与速美載。飯治止稿原先明画森群進見情幕。女民館終調質並伝車慌供科。支田国傷自動献疑討医足公成公主断的望。
|
||||
|
||||
責開児食福実帰治師今策今。水重寺圧医観送連東者秒途。選央力律式開作掲写様階組戦写型紙。式国販時天遣国出難共前次領体康稲住転。査見保重議原速群者内月正連。爾天膨装芸別巨平運数準三浜念載創県奈飛提。素京発揮田談気党示見象定電類代級。善返跡国有話権入猛府週亡辞馬脳。関残主祐雪塚去集村完海関文受載表川護照立。
|
||||
|
||||
発闘美慎健育旅布容広互無秋認天歌媛芸。転器合読県増認会賞倒点系。食気母服絵知去祝芸車報熱勝。能貿月更障文的欠賞現覇声敏施会。懲病写昼法族業律記聡生開緊楽暮護。東地二員者説盟治害討面提。第北乗査庭年近的禁疑報方店記必迷都流通。聞有力前愛院梨野関業前訳本清滋補。蒲読火死勝広保会婚際気二由保国。用君込村需起相点選紙拡氏訃不。`,
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
27
demo/54-custom-properties.ts
Normal file
27
demo/54-custom-properties.ts
Normal file
@ -0,0 +1,27 @@
|
||||
// Custom Properties
|
||||
// Custom properties are incredibly useful if you want to be able to apply quick parts or custom cover pages
|
||||
// to the document in Word after the document has been generated. Standard properties (such as creator, title
|
||||
// and subject) cover typical use cases, but sometimes custom properties are required.
|
||||
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer } from "../build";
|
||||
|
||||
const doc = new Document(
|
||||
// Standard properties
|
||||
{
|
||||
creator: "Creator",
|
||||
title: "Title",
|
||||
subject: "Subject",
|
||||
description: "Description",
|
||||
customProperties: [
|
||||
{ name: "Subtitle", value: "Subtitle" },
|
||||
{ name: "Address", value: "Address" },
|
||||
],
|
||||
sections: [],
|
||||
},
|
||||
);
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
296
demo/55-math.ts
Normal file
296
demo/55-math.ts
Normal file
@ -0,0 +1,296 @@
|
||||
// Simple example to add text to a document
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
Document,
|
||||
Math,
|
||||
MathAngledBrackets,
|
||||
MathCurlyBrackets,
|
||||
MathFraction,
|
||||
MathFunction,
|
||||
MathPreSubSuperScript,
|
||||
MathRadical,
|
||||
MathRoundBrackets,
|
||||
MathRun,
|
||||
MathSquareBrackets,
|
||||
MathSubScript,
|
||||
MathSubSuperScript,
|
||||
MathSum,
|
||||
MathSuperScript,
|
||||
Packer,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
} from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathRun("2+2"),
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("hi")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [
|
||||
new MathRun("1"),
|
||||
new MathRadical({
|
||||
children: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSum({
|
||||
children: [new MathRun("test")],
|
||||
}),
|
||||
new MathSum({
|
||||
children: [
|
||||
new MathSuperScript({
|
||||
children: [new MathRun("e")],
|
||||
superScript: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
subScript: [new MathRun("i")],
|
||||
}),
|
||||
new MathSum({
|
||||
children: [
|
||||
new MathRadical({
|
||||
children: [new MathRun("i")],
|
||||
}),
|
||||
],
|
||||
subScript: [new MathRun("i")],
|
||||
superScript: [new MathRun("10")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSuperScript({
|
||||
children: [new MathRun("test")],
|
||||
superScript: [new MathRun("hello")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSubScript({
|
||||
children: [new MathRun("test")],
|
||||
subScript: [new MathRun("hello")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSubScript({
|
||||
children: [new MathRun("x")],
|
||||
subScript: [
|
||||
new MathSuperScript({
|
||||
children: [new MathRun("y")],
|
||||
superScript: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSubSuperScript({
|
||||
children: [new MathRun("test")],
|
||||
superScript: [new MathRun("hello")],
|
||||
subScript: [new MathRun("world")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathPreSubSuperScript({
|
||||
children: [new MathRun("test")],
|
||||
superScript: [new MathRun("hello")],
|
||||
subScript: [new MathRun("world")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSubScript({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
subScript: [new MathRun("4")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathSubScript({
|
||||
children: [
|
||||
new MathRadical({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
degree: [new MathRun("4")],
|
||||
}),
|
||||
],
|
||||
subScript: [new MathRun("x")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathRadical({
|
||||
children: [new MathRun("4")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathFunction({
|
||||
name: [
|
||||
new MathSuperScript({
|
||||
children: [new MathRun("cos")],
|
||||
superScript: [new MathRun("-1")],
|
||||
}),
|
||||
],
|
||||
children: [new MathRun("100")],
|
||||
}),
|
||||
new MathRun("×"),
|
||||
new MathFunction({
|
||||
name: [new MathRun("sin")],
|
||||
children: [new MathRun("360")],
|
||||
}),
|
||||
new MathRun("= x"),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathRoundBrackets({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new MathSquareBrackets({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new MathCurlyBrackets({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new MathAngledBrackets({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [new MathRun("1")],
|
||||
denominator: [new MathRun("2")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new Math({
|
||||
children: [
|
||||
new MathFraction({
|
||||
numerator: [
|
||||
new MathRadical({
|
||||
children: [new MathRun("4")],
|
||||
}),
|
||||
],
|
||||
denominator: [new MathRun("2a")],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
34
demo/56-background-color.ts
Normal file
34
demo/56-background-color.ts
Normal file
@ -0,0 +1,34 @@
|
||||
// Change background colour of whole document
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
background: {
|
||||
color: "C45911",
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
new TextRun({
|
||||
text: "\tGithub is the best",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
89
demo/57-add-parent-numbered-lists.ts
Normal file
89
demo/57-add-parent-numbered-lists.ts
Normal file
@ -0,0 +1,89 @@
|
||||
// Numbered lists - Add parent number in sub number
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: convertInchesToTwip(0.5), hanging: 260 },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
level: 1,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1.%2",
|
||||
alignment: AlignmentType.START,
|
||||
style: {
|
||||
paragraph: {
|
||||
indent: { left: 1.25 * convertInchesToTwip(0.5), hanging: 1.25 * 260 },
|
||||
},
|
||||
run: {
|
||||
bold: true,
|
||||
size: 18,
|
||||
font: "Times New Roman",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
reference: "my-number-numbering-reference",
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "How to make cake",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 1 - Add sugar",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 2 - Add wheat",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 2a - Stir the wheat in a circle",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Step 3 - Put in oven",
|
||||
numbering: {
|
||||
reference: "my-number-numbering-reference",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "How to make cake",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
91
demo/58-section-types.ts
Normal file
91
demo/58-section-types.ts
Normal file
@ -0,0 +1,91 @@
|
||||
// Usage of different Section Types
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, TextRun, SectionType } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
type: SectionType.CONTINUOUS,
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
type: SectionType.ODD_PAGE,
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
type: SectionType.EVEN_PAGE,
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
type: SectionType.NEXT_PAGE,
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
54
demo/59-header-footer-margins.ts
Normal file
54
demo/59-header-footer-margins.ts
Normal file
@ -0,0 +1,54 @@
|
||||
// Move + offset header and footer
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Footer, Header, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
margin: {
|
||||
header: 100,
|
||||
footer: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Header text",
|
||||
indent: {
|
||||
left: -400,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Some more header text",
|
||||
indent: {
|
||||
left: -600,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Footer text",
|
||||
indent: {
|
||||
left: -400,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
46
demo/6-page-borders.ts
Normal file
46
demo/6-page-borders.ts
Normal file
@ -0,0 +1,46 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
margin: {
|
||||
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);
|
||||
});
|
153
demo/60-track-revisions.ts
Normal file
153
demo/60-track-revisions.ts
Normal file
@ -0,0 +1,153 @@
|
||||
// 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 setting `features: { trackRevisions: true }` adds an element `<w:trackRevisions />` to the `settings.xml` file.
|
||||
This specifies that the application shall track *new* revisions made to the existing document.
|
||||
See also https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.trackrevisions
|
||||
|
||||
Note that this setting enables to track *new changes* after teh file is generated, so this example will still
|
||||
show inserted and deleted text runs when you remove it.
|
||||
*/
|
||||
|
||||
const paragraph = new Paragraph({
|
||||
children: [
|
||||
new TextRun("This is a simple demo "),
|
||||
new TextRun({
|
||||
text: "on how to ",
|
||||
}),
|
||||
new InsertedTextRun({
|
||||
text: "mark a text as an insertion ",
|
||||
id: 0,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:00:00Z",
|
||||
}),
|
||||
new DeletedTextRun({
|
||||
text: "or a deletion.",
|
||||
id: 1,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:00:00Z",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const doc = new Document({
|
||||
footnotes: {
|
||||
1: {
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("This is a footnote"),
|
||||
new DeletedTextRun({
|
||||
text: " with some extra text which was deleted",
|
||||
id: 0,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:05:00Z",
|
||||
}),
|
||||
new InsertedTextRun({
|
||||
text: " and new content",
|
||||
id: 1,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:05:00Z",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
features: {
|
||||
trackRevisions: true,
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
paragraph,
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("This is a demo "),
|
||||
new DeletedTextRun({
|
||||
break: 1,
|
||||
text: "in order",
|
||||
color: "ff0000",
|
||||
bold: true,
|
||||
size: 24,
|
||||
font: {
|
||||
name: "Garamond",
|
||||
},
|
||||
shading: {
|
||||
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||
color: "00FFFF",
|
||||
fill: "FF0000",
|
||||
},
|
||||
id: 2,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:00:00Z",
|
||||
}),
|
||||
new InsertedTextRun({
|
||||
text: "to show how to ",
|
||||
bold: false,
|
||||
id: 3,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:05:00Z",
|
||||
}),
|
||||
new TextRun({
|
||||
bold: true,
|
||||
children: ["\tuse Inserted and Deleted TextRuns.", new FootnoteReferenceRun(1)],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.CENTER,
|
||||
children: [
|
||||
new TextRun("Awesome LLC"),
|
||||
new TextRun({
|
||||
children: ["Page Number: ", PageNumber.CURRENT],
|
||||
}),
|
||||
new DeletedTextRun({
|
||||
children: [" to ", PageNumber.TOTAL_PAGES],
|
||||
id: 4,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:05:00Z",
|
||||
}),
|
||||
new InsertedTextRun({
|
||||
children: [" from ", PageNumber.TOTAL_PAGES],
|
||||
bold: true,
|
||||
id: 5,
|
||||
author: "Firstname Lastname",
|
||||
date: "2020-10-06T09:05:00Z",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
82
demo/61-text-frame.ts
Normal file
82
demo/61-text-frame.ts
Normal file
@ -0,0 +1,82 @@
|
||||
// Text Frame (Text Box) example
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import {
|
||||
BorderStyle,
|
||||
Document,
|
||||
FrameAnchorType,
|
||||
HorizontalPositionAlign,
|
||||
Packer,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
VerticalPositionAlign,
|
||||
} from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
frame: {
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
alignment: {
|
||||
x: HorizontalPositionAlign.CENTER,
|
||||
y: VerticalPositionAlign.TOP,
|
||||
},
|
||||
},
|
||||
border: {
|
||||
top: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
bottom: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
left: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
right: {
|
||||
color: "auto",
|
||||
space: 1,
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 6,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new TextRun("Hello World"),
|
||||
new TextRun({
|
||||
text: "Foo Bar",
|
||||
bold: true,
|
||||
}),
|
||||
new TextRun({
|
||||
text: "\tGithub is the best",
|
||||
bold: true,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
36
demo/62-paragraph-spacing.ts
Normal file
36
demo/62-paragraph-spacing.ts
Normal file
@ -0,0 +1,36 @@
|
||||
// Simple example to add text to a document
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
spacing: {
|
||||
after: 5000,
|
||||
before: 5000,
|
||||
},
|
||||
children: [new TextRun("Hello World")],
|
||||
}),
|
||||
new Paragraph({
|
||||
spacing: {
|
||||
line: 2000,
|
||||
lineRule: LineRuleType.AUTO,
|
||||
},
|
||||
children: [
|
||||
new TextRun(
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed turpis ex, aliquet et faucibus quis, euismod in odio. Fusce gravida tempor nunc sed lacinia. Nulla sed dolor fringilla, fermentum libero ut, egestas ex. Donec pellentesque metus non orci lacinia bibendum. Cras porta ex et mollis hendrerit. Suspendisse id lectus suscipit, elementum lacus eu, convallis felis. Fusce sed bibendum dolor, id posuere ligula. Aliquam eu elit ut urna eleifend vestibulum. Praesent condimentum at turpis sed scelerisque. Suspendisse porttitor metus nec vestibulum egestas. Sed in eros sapien. Morbi efficitur placerat est a consequat. Nunc bibendum porttitor mi nec tempus. Morbi dictum augue porttitor nisi sodales sodales.",
|
||||
),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
71
demo/63-odd-even-header-footer.ts
Normal file
71
demo/63-odd-even-header-footer.ts
Normal file
@ -0,0 +1,71 @@
|
||||
// Move + offset header and footer
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
evenAndOddHeaderAndFooters: true,
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Odd Header text",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Odd - Some more header text",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
even: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Even header text",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Even - Some more header text",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Odd Footer text",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
even: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Even Cool Footer text",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [new TextRun("Hello World 1"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [new TextRun("Hello World 2"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [new TextRun("Hello World 3"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [new TextRun("Hello World 4"), new PageBreak()],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [new TextRun("Hello World 5"), new PageBreak()],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
111
demo/64-complex-numbering-text.ts
Normal file
111
demo/64-complex-numbering-text.ts
Normal file
@ -0,0 +1,111 @@
|
||||
// Numbered lists - With complex number text
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, LevelFormat } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
reference: "ref1",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1",
|
||||
},
|
||||
{
|
||||
level: 1,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1.%2",
|
||||
},
|
||||
{
|
||||
level: 2,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1.%2.%3",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:1",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 1,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:2",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 2,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "Random text",
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 1,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 0,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 0,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Used to export the file into a .docx file
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("6-numbering.docx", buffer);
|
||||
});
|
38
demo/65-page-sizes.ts
Normal file
38
demo/65-page-sizes.ts
Normal file
@ -0,0 +1,38 @@
|
||||
// Example of how to set the document page sizes
|
||||
// Reference from https://papersizes.io/a/a3
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.LANDSCAPE,
|
||||
height: convertMillimetersToTwip(210),
|
||||
width: convertMillimetersToTwip(148),
|
||||
},
|
||||
},
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
height: convertMillimetersToTwip(420),
|
||||
width: convertMillimetersToTwip(297),
|
||||
},
|
||||
},
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
43
demo/66-fields.ts
Normal file
43
demo/66-fields.ts
Normal file
@ -0,0 +1,43 @@
|
||||
// Use fields to include dynamic text
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
creator: 'Me',
|
||||
sections: [
|
||||
{
|
||||
properties: {},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("This document is called "),
|
||||
new SimpleField("FILENAME", "My Document.docx"),
|
||||
new TextRun(", was created on "),
|
||||
new SimpleField('CREATEDATE \\@ "d MMMM yyyy"'),
|
||||
new TextRun(" by "),
|
||||
new SimpleField("AUTHOR"),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun("The document has "),
|
||||
new SimpleField("NUMWORDS", "34"),
|
||||
new TextRun(" words and if you'd print it "),
|
||||
new Bookmark({
|
||||
id: "TimesPrinted",
|
||||
children: [new TextRun("42")],
|
||||
}),
|
||||
new TextRun(" times two-sided, you would need "),
|
||||
new SimpleField("=INT((TimesPrinted+1)/2)"),
|
||||
new TextRun(" sheets of paper."),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
28
demo/67-column-break.ts
Normal file
28
demo/67-column-break.ts
Normal file
@ -0,0 +1,28 @@
|
||||
// Section with 2 columns including a column break
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
column: {
|
||||
space: 708,
|
||||
count: 2,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph({ children: [
|
||||
new TextRun('This text will be in the first column.'),
|
||||
new ColumnBreak(),
|
||||
new TextRun('This text will be in the second column.'),
|
||||
] }),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
88
demo/68-numbering-instances-and-starting-number.ts
Normal file
88
demo/68-numbering-instances-and-starting-number.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, LevelFormat } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
numbering: {
|
||||
config: [
|
||||
{
|
||||
reference: "ref1",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1",
|
||||
start: 10,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
reference: "ref2",
|
||||
levels: [
|
||||
{
|
||||
level: 0,
|
||||
format: LevelFormat.DECIMAL,
|
||||
text: "%1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 0,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 0,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 1,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF1 - inst:1 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref1",
|
||||
instance: 1,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF2 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref2",
|
||||
instance: 1,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
new Paragraph({
|
||||
text: "REF2 - inst:0 - lvl:0",
|
||||
numbering: {
|
||||
reference: "ref2",
|
||||
instance: 1,
|
||||
level: 0,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
31
demo/69-different-width-columns.ts
Normal file
31
demo/69-different-width-columns.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// Sections with multiple columns
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Column, Document, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
column: {
|
||||
count: 2,
|
||||
space: 720,
|
||||
equalWidth: false,
|
||||
children: [new Column({ width: 2880, space: 720 }), new Column({ width: 5760 })],
|
||||
},
|
||||
},
|
||||
children: [
|
||||
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.",
|
||||
),
|
||||
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.",
|
||||
),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
23
demo/7-landscape.ts
Normal file
23
demo/7-landscape.ts
Normal file
@ -0,0 +1,23 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.LANDSCAPE,
|
||||
},
|
||||
},
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
37
demo/70-line-numbers-suppression.ts
Normal file
37
demo/70-line-numbers-suppression.ts
Normal file
@ -0,0 +1,37 @@
|
||||
// Example demonstrating line numbers with suppression.
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
lineNumbers: {
|
||||
countBy: 1,
|
||||
restart: LineNumberRestartFormat.CONTINUOUS,
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
text: "Hello",
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph(
|
||||
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
|
||||
),
|
||||
new Paragraph({
|
||||
text: "Enim mollit nostrud ut dolor eiusmod id sit occaecat dolore culpa amet. Veniam dolor consequat dolor labore ullamco laborum dolore eiusmod qui adipisicing. Elit nulla cupidatat et magna. Id eiusmod tempor non laborum ipsum. Veniam et aliqua excepteur duis officia enim elit excepteur fugiat duis. Sit sunt ullamco non dolor est qui deserunt consequat magna. Esse pariatur esse dolor ut excepteur dolor nisi nisi non est cupidatat mollit.",
|
||||
suppressLineNumbers: true,
|
||||
}),
|
||||
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);
|
||||
});
|
63
demo/71-page-borders-2.ts
Normal file
63
demo/71-page-borders-2.ts
Normal file
@ -0,0 +1,63 @@
|
||||
// Example demonstrating page borders with style, colors and size
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
borders: {
|
||||
pageBorderBottom: {
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 2 * 8, //2pt;
|
||||
color: "000000",
|
||||
},
|
||||
pageBorderLeft: {
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 1 * 8, //1pt;
|
||||
color: "000000",
|
||||
},
|
||||
pageBorderRight: {
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 1 * 8, //1pt;
|
||||
color: "FF00AA",
|
||||
},
|
||||
pageBorderTop: {
|
||||
style: BorderStyle.SINGLE,
|
||||
size: 1 * 8, //1pt;
|
||||
color: "000000",
|
||||
},
|
||||
pageBorders: {
|
||||
display: PageBorderDisplay.ALL_PAGES,
|
||||
offsetFrom: PageBorderOffsetFrom.TEXT,
|
||||
zOrder: PageBorderZOrder.FRONT,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Used to export the file into a .docx file
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
26
demo/8-header-footer.ts
Normal file
26
demo/8-header-footer.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// 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({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [new Paragraph("Header text")],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [new Paragraph("Footer text")],
|
||||
}),
|
||||
},
|
||||
children: [new Paragraph("Hello World")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
50
demo/9-images-in-header-and-footer.ts
Normal file
50
demo/9-images-in-header-and-footer.ts
Normal file
@ -0,0 +1,50 @@
|
||||
// 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, ImageRun, Packer, Paragraph } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
headers: {
|
||||
default: new Header({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
footers: {
|
||||
default: new Footer({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
},
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
},
|
||||
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
@ -1,39 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<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>
|
||||
</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 Document();
|
||||
const doc = new docx.Document({
|
||||
sections: [
|
||||
{
|
||||
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,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
const institutionText = new TextRun("Foo Bar").bold();
|
||||
const dateText = new TextRun("Github is the best").tab().bold();
|
||||
paragraph.addRun(institutionText);
|
||||
paragraph.addRun(dateText);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBlob(doc).then(blob => {
|
||||
docx.Packer.toBlob(doc).then((blob) => {
|
||||
console.log(blob);
|
||||
saveAs(blob, "example.docx");
|
||||
console.log("Document created successfully");
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,20 +0,0 @@
|
||||
// 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();
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
const institutionText = new TextRun("Foo Bar").bold();
|
||||
const dateText = new TextRun("Github is the best").tab().bold();
|
||||
paragraph.addRun(institutionText);
|
||||
paragraph.addRun(dateText);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
328
demo/demo10.ts
328
demo/demo10.ts
@ -1,328 +0,0 @@
|
||||
// Generate a CV
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, 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 {
|
||||
public create(data: object[]): Document {
|
||||
// tslint:disable-next-line:no-any
|
||||
const experiences = data[0] as any[];
|
||||
// tslint:disable-next-line:no-any
|
||||
const educations = data[1] as any[];
|
||||
const skills = data[2] as object[];
|
||||
const achivements = data[3] as object[];
|
||||
const document = new Document();
|
||||
document.addParagraph(new Paragraph("Dolan Miu").title());
|
||||
|
||||
document.addParagraph(this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL));
|
||||
document.addParagraph(this.createHeading("Education"));
|
||||
|
||||
for (const education of educations) {
|
||||
document.addParagraph(
|
||||
this.createInstitutionHeader(education.schoolName, `${education.startDate.year} - ${education.endDate.year}`),
|
||||
);
|
||||
document.addParagraph(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
|
||||
|
||||
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
|
||||
bulletPoints.forEach((bulletPoint) => {
|
||||
document.addParagraph(this.createBullet(bulletPoint));
|
||||
});
|
||||
}
|
||||
|
||||
document.addParagraph(this.createHeading("Experience"));
|
||||
|
||||
for (const position of experiences) {
|
||||
document.addParagraph(
|
||||
this.createInstitutionHeader(
|
||||
position.company.name,
|
||||
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
|
||||
),
|
||||
);
|
||||
document.addParagraph(this.createRoleText(position.title));
|
||||
|
||||
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
|
||||
|
||||
bulletPoints.forEach((bulletPoint) => {
|
||||
document.addParagraph(this.createBullet(bulletPoint));
|
||||
});
|
||||
}
|
||||
|
||||
document.addParagraph(this.createHeading("Skills, Achievements and Interests"));
|
||||
|
||||
document.addParagraph(this.createSubHeading("Skills"));
|
||||
document.addParagraph(this.createSkillList(skills));
|
||||
|
||||
document.addParagraph(this.createSubHeading("Achievements"));
|
||||
|
||||
for (const achievementParagraph of this.createAchivementsList(achivements)) {
|
||||
document.addParagraph(achievementParagraph);
|
||||
}
|
||||
|
||||
document.addParagraph(this.createSubHeading("Interests"));
|
||||
|
||||
document.addParagraph(this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."));
|
||||
|
||||
document.addParagraph(this.createHeading("References"));
|
||||
|
||||
document.addParagraph(
|
||||
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",
|
||||
),
|
||||
);
|
||||
document.addParagraph(new Paragraph("More references upon request"));
|
||||
document.addParagraph(
|
||||
new Paragraph(
|
||||
"This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
|
||||
).center(),
|
||||
);
|
||||
return document;
|
||||
}
|
||||
|
||||
public createContactInfo(phoneNumber: string, profileUrl: string, email: string): Paragraph {
|
||||
const paragraph = new Paragraph().center();
|
||||
const contactInfo = new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`);
|
||||
const address = new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break();
|
||||
|
||||
paragraph.addRun(contactInfo);
|
||||
paragraph.addRun(address);
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
public createHeading(text: string): Paragraph {
|
||||
return new Paragraph(text).heading1().thematicBreak();
|
||||
}
|
||||
|
||||
public createSubHeading(text: string): Paragraph {
|
||||
return new Paragraph(text).heading2();
|
||||
}
|
||||
|
||||
public createInstitutionHeader(institutionName: string, dateText: string): Paragraph {
|
||||
const paragraph = new Paragraph().maxRightTabStop();
|
||||
const institution = new TextRun(institutionName).bold();
|
||||
const date = new TextRun(dateText).tab().bold();
|
||||
|
||||
paragraph.addRun(institution);
|
||||
paragraph.addRun(date);
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
public createRoleText(roleText: string): Paragraph {
|
||||
const paragraph = new Paragraph();
|
||||
const role = new TextRun(roleText).italics();
|
||||
|
||||
paragraph.addRun(role);
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
public createBullet(text: string): Paragraph {
|
||||
return new Paragraph(text).bullet();
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
public createSkillList(skills: any[]): Paragraph {
|
||||
const paragraph = new Paragraph();
|
||||
const skillConcat = skills.map((skill) => skill.name).join(", ") + ".";
|
||||
|
||||
paragraph.addRun(new TextRun(skillConcat));
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:no-any
|
||||
public createAchivementsList(achivements: any[]): Paragraph[] {
|
||||
const arr: Paragraph[] = [];
|
||||
|
||||
for (const achievement of achivements) {
|
||||
const paragraph = new Paragraph(achievement.name).bullet();
|
||||
arr.push(paragraph);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
public createInterests(interests: string): Paragraph {
|
||||
const paragraph = new Paragraph();
|
||||
|
||||
paragraph.addRun(new TextRun(interests));
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
140
demo/demo11.ts
140
demo/demo11.ts
@ -1,140 +0,0 @@
|
||||
// Setting styles with JavaScript configuration
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, Paragraph, Table } from "../build";
|
||||
|
||||
const doc = new Document(undefined, {
|
||||
top: 700,
|
||||
right: 700,
|
||||
bottom: 700,
|
||||
left: 700,
|
||||
});
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading1", "Heading 1")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.quickFormat()
|
||||
.font("Calibri")
|
||||
.size(52)
|
||||
.center()
|
||||
.bold()
|
||||
.color("000000")
|
||||
.spacing({ line: 340 })
|
||||
.underline("single", "000000");
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading2", "Heading 2")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.font("Calibri")
|
||||
.quickFormat()
|
||||
.size(26)
|
||||
.bold()
|
||||
.spacing({ line: 340 });
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading3", "Heading 3")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.font("Calibri")
|
||||
.quickFormat()
|
||||
.size(26)
|
||||
.bold()
|
||||
.spacing({ line: 276 });
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading4", "Heading 4")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.justified()
|
||||
.font("Calibri")
|
||||
.size(26)
|
||||
.bold();
|
||||
|
||||
doc.Styles.createParagraphStyle("normalPara", "Normal Para")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.font("Calibri")
|
||||
.quickFormat()
|
||||
.leftTabStop(453.543307087)
|
||||
.maxRightTabStop()
|
||||
.size(26)
|
||||
.spacing({ line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 });
|
||||
|
||||
doc.Styles.createParagraphStyle("normalPara2", "Normal Para2")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.quickFormat()
|
||||
.font("Calibri")
|
||||
.size(26)
|
||||
.justified()
|
||||
.spacing({ line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 });
|
||||
|
||||
doc.Styles.createParagraphStyle("aside", "Aside")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.color("999999")
|
||||
.italics()
|
||||
.indent({ left: 720 })
|
||||
.spacing({ line: 276 });
|
||||
|
||||
doc.Styles.createParagraphStyle("wellSpaced", "Well Spaced")
|
||||
.basedOn("Normal")
|
||||
.spacing({ line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 });
|
||||
|
||||
doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
|
||||
.quickFormat()
|
||||
.basedOn("Normal");
|
||||
|
||||
doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
|
||||
doc.createParagraph("HEADING")
|
||||
.heading1()
|
||||
.center();
|
||||
|
||||
doc.Footer.createParagraph("1")
|
||||
.style("normalPara")
|
||||
.right();
|
||||
|
||||
doc.createParagraph("Ref. :").style("normalPara");
|
||||
doc.createParagraph("Date :").style("normalPara");
|
||||
|
||||
doc.createParagraph("To,").style("normalPara");
|
||||
doc.createParagraph("The Superindenting Engineer,(O &M)").style("normalPara");
|
||||
|
||||
doc.createParagraph("Sub : ").style("normalPara");
|
||||
|
||||
doc.createParagraph("Ref. : ").style("normalPara");
|
||||
|
||||
doc.createParagraph("Sir,").style("normalPara");
|
||||
|
||||
doc.createParagraph("BRIEF DESCRIPTION").style("normalPara");
|
||||
|
||||
const table = new Table({
|
||||
rows: 4,
|
||||
columns: 4,
|
||||
});
|
||||
table
|
||||
.getRow(0)
|
||||
.getCell(0)
|
||||
.addParagraph(new Paragraph("Pole No."));
|
||||
|
||||
doc.addTable(table);
|
||||
|
||||
const arrboth = [
|
||||
{
|
||||
image: "./demo/images/pizza.gif",
|
||||
comment: "Test",
|
||||
},
|
||||
{
|
||||
image: "./demo/images/pizza.gif",
|
||||
comment: "Test 2",
|
||||
},
|
||||
];
|
||||
|
||||
arrboth.forEach((item) => {
|
||||
doc.createImage(fs.readFileSync(item.image));
|
||||
doc.createParagraph(item.comment).style("normalPara2");
|
||||
});
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
// Scaling images
|
||||
// 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();
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const image = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
|
||||
const image2 = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
|
||||
const image3 = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
|
||||
const image4 = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
|
||||
|
||||
image.scale(0.5);
|
||||
image2.scale(1);
|
||||
image3.scale(2.5);
|
||||
image4.scale(4);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
// 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, Packer, Paragraph } from "../build";
|
||||
|
||||
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
||||
const doc = new Document({
|
||||
title: "Title",
|
||||
externalStyles: styles,
|
||||
});
|
||||
|
||||
doc.createParagraph("Cool Heading Text").heading1();
|
||||
|
||||
const paragraph = new Paragraph('This is a custom named style from the template "MyFancyStyle"');
|
||||
paragraph.style("MyFancyStyle");
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
doc.createParagraph("Some normal text");
|
||||
|
||||
doc.createParagraph("MyFancyStyle again").style("MyFancyStyle");
|
||||
paragraph.style("MyFancyStyle");
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
// Page numbers
|
||||
// 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.createParagraph("First Page").pageBreak();
|
||||
doc.createParagraph("Second Page");
|
||||
|
||||
const pageNumber = new TextRun("Page ").pageNumber();
|
||||
|
||||
const pageoneheader = new Paragraph("First Page Header ").right();
|
||||
|
||||
pageoneheader.addRun(pageNumber);
|
||||
const firstPageHeader = doc.createFirstPageHeader();
|
||||
firstPageHeader.addParagraph(pageoneheader);
|
||||
|
||||
const pagetwoheader = new Paragraph("My Title ").right();
|
||||
|
||||
pagetwoheader.addRun(pageNumber);
|
||||
doc.Header.addParagraph(pagetwoheader);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,18 +0,0 @@
|
||||
// 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();
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
const paragraph2 = new Paragraph("Hello World on another page").pageBreakBefore();
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
doc.addParagraph(paragraph2);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,84 +0,0 @@
|
||||
// Multiple sections and headers
|
||||
// Import from 'docx' rather than '../build' if you install from npm
|
||||
import * as fs from "fs";
|
||||
import { Document, Packer, PageNumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
|
||||
|
||||
const doc = new Document();
|
||||
|
||||
const paragraph = new Paragraph("Hello World").pageBreak();
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const header = doc.createHeader();
|
||||
header.createParagraph("Header on another page");
|
||||
const footer = doc.createFooter();
|
||||
footer.createParagraph("Footer on another page");
|
||||
|
||||
doc.addSection({
|
||||
headers: {
|
||||
default: header,
|
||||
},
|
||||
footers: {
|
||||
default: footer,
|
||||
},
|
||||
pageNumberStart: 1,
|
||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
||||
});
|
||||
|
||||
doc.createParagraph("hello");
|
||||
|
||||
doc.addSection({
|
||||
headers: {
|
||||
default: header,
|
||||
},
|
||||
footers: {
|
||||
default: footer,
|
||||
},
|
||||
pageNumberStart: 1,
|
||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
||||
orientation: PageOrientation.LANDSCAPE,
|
||||
});
|
||||
|
||||
doc.createParagraph("hello in landscape");
|
||||
|
||||
const header2 = doc.createHeader();
|
||||
const pageNumber = new TextRun("Page number: ").pageNumber();
|
||||
header2.createParagraph().addRun(pageNumber);
|
||||
|
||||
doc.addSection({
|
||||
headers: {
|
||||
default: header2,
|
||||
},
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
});
|
||||
|
||||
doc.createParagraph("Page number in the header must be 2, because it continues from the previous section.");
|
||||
|
||||
doc.addSection({
|
||||
headers: {
|
||||
default: header2,
|
||||
},
|
||||
pageNumberFormatType: PageNumberFormat.UPPER_ROMAN,
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
});
|
||||
|
||||
doc.createParagraph(
|
||||
"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: header2,
|
||||
},
|
||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
||||
pageNumberStart: 25,
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
});
|
||||
|
||||
doc.createParagraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section.");
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,21 +0,0 @@
|
||||
// Footnotes
|
||||
// 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();
|
||||
|
||||
const paragraph = new Paragraph("Hello World").referenceFootnote(1);
|
||||
const paragraph2 = new Paragraph("Hello World").referenceFootnote(2);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
doc.addParagraph(paragraph2);
|
||||
|
||||
doc.createFootnote(new Paragraph("Test"));
|
||||
doc.createFootnote(new Paragraph("My amazing reference"));
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
// 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();
|
||||
|
||||
const paragraph = new Paragraph("Hello World");
|
||||
const institutionText = new TextRun("Foo").bold();
|
||||
const dateText = new TextRun("Bar").tab().bold();
|
||||
paragraph.addRun(institutionText);
|
||||
paragraph.addRun(dateText);
|
||||
|
||||
doc.addParagraph(paragraph);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBase64String(doc).then((str) => {
|
||||
fs.writeFileSync("My Document.docx", str);
|
||||
});
|
@ -1,78 +0,0 @@
|
||||
// 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 { Document, Packer } from "../build";
|
||||
|
||||
const doc = new Document({
|
||||
creator: "Clippy",
|
||||
title: "Sample Document",
|
||||
description: "A brief example of using docx",
|
||||
});
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading1", "Heading 1")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.quickFormat()
|
||||
.size(28)
|
||||
.bold()
|
||||
.italics()
|
||||
.spacing({ after: 120 });
|
||||
|
||||
doc.Styles.createParagraphStyle("Heading2", "Heading 2")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.quickFormat()
|
||||
.size(26)
|
||||
.bold()
|
||||
.underline("double", "FF0000")
|
||||
.spacing({ before: 240, after: 120 });
|
||||
|
||||
doc.Styles.createParagraphStyle("aside", "Aside")
|
||||
.basedOn("Normal")
|
||||
.next("Normal")
|
||||
.color("999999")
|
||||
.italics()
|
||||
.indent({ left: 720 })
|
||||
.spacing({ line: 276 });
|
||||
|
||||
doc.Styles.createParagraphStyle("wellSpaced", "Well Spaced")
|
||||
.basedOn("Normal")
|
||||
.spacing({ line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 });
|
||||
|
||||
doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
|
||||
.quickFormat()
|
||||
.basedOn("Normal");
|
||||
|
||||
const numberedAbstract = doc.Numbering.createAbstractNumbering();
|
||||
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "left");
|
||||
|
||||
doc.createParagraph("Test heading1, bold and italicized").heading1();
|
||||
doc.createParagraph("Some simple content");
|
||||
doc.createParagraph("Test heading2 with double red underline").heading2();
|
||||
|
||||
const letterNumbering = doc.Numbering.createConcreteNumbering(numberedAbstract);
|
||||
const letterNumbering5 = doc.Numbering.createConcreteNumbering(numberedAbstract);
|
||||
letterNumbering5.overrideLevel(0, 5);
|
||||
|
||||
doc.createParagraph("Option1").setNumbering(letterNumbering, 0);
|
||||
doc.createParagraph("Option5 -- override 2 to 5").setNumbering(letterNumbering5, 0);
|
||||
doc.createParagraph("Option3").setNumbering(letterNumbering, 0);
|
||||
|
||||
doc
|
||||
.createParagraph()
|
||||
.createTextRun("Some monospaced content")
|
||||
.font("Monospace");
|
||||
|
||||
doc.createParagraph("An aside, in light gray italics and indented").style("aside");
|
||||
doc.createParagraph("This is normal, but well-spaced text").style("wellSpaced");
|
||||
const para = doc.createParagraph();
|
||||
para.createTextRun("This is a bold run,").bold();
|
||||
para.createTextRun(" switching to normal ");
|
||||
para.createTextRun("and then underlined ").underline();
|
||||
para.createTextRun("and back to normal.");
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,24 +0,0 @@
|
||||
// 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 } from "../build";
|
||||
|
||||
const doc = new Document();
|
||||
|
||||
const table = doc.createTable({
|
||||
rows: 4,
|
||||
columns: 4,
|
||||
});
|
||||
table
|
||||
.getCell(2, 2)
|
||||
.addParagraph(new Paragraph("Hello"))
|
||||
.Borders.addTopBorder(BorderStyle.DASH_DOT_STROKED, 3, "red")
|
||||
.addBottomBorder(BorderStyle.DOUBLE, 3, "blue")
|
||||
.addStartBorder(BorderStyle.DOT_DOT_DASH, 3, "green")
|
||||
.addEndBorder(BorderStyle.DOT_DOT_DASH, 3, "#ff8000");
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,37 +0,0 @@
|
||||
// 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 { Document, Packer } from "../build";
|
||||
|
||||
const loremIpsum =
|
||||
"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",
|
||||
});
|
||||
|
||||
const anchorId = "anchorID";
|
||||
|
||||
// First create the bookmark
|
||||
const bookmark = doc.createBookmark(anchorId, "Lorem Ipsum");
|
||||
// That has header styling
|
||||
doc
|
||||
.createParagraph()
|
||||
.addBookmark(bookmark)
|
||||
.heading1();
|
||||
doc.createParagraph("\n");
|
||||
|
||||
doc.createParagraph(loremIpsum);
|
||||
doc.createParagraph().pageBreak();
|
||||
|
||||
// Now the link back up to the bookmark
|
||||
const hyperlink = doc.createInternalHyperLink(anchorId, `Click me!`);
|
||||
doc.createParagraph().addHyperLink(hyperlink);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
@ -1,27 +0,0 @@
|
||||
// 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();
|
||||
|
||||
const paragraph1 = new Paragraph().bidirectional();
|
||||
const textRun1 = new TextRun("שלום עולם").rightToLeft();
|
||||
paragraph1.addRun(textRun1);
|
||||
doc.addParagraph(paragraph1);
|
||||
|
||||
const paragraph2 = new Paragraph().bidirectional();
|
||||
const textRun2 = new TextRun("שלום עולם").bold().rightToLeft();
|
||||
paragraph2.addRun(textRun2);
|
||||
doc.addParagraph(paragraph2);
|
||||
|
||||
const paragraph3 = new Paragraph().bidirectional();
|
||||
const textRun3 = new TextRun("שלום עולם").italics().rightToLeft();
|
||||
paragraph3.addRun(textRun3);
|
||||
doc.addParagraph(paragraph3);
|
||||
|
||||
const packer = new Packer();
|
||||
|
||||
packer.toBuffer(doc).then((buffer) => {
|
||||
fs.writeFileSync("My Document.docx", buffer);
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user