Compare commits
2178 Commits
feat/parag
...
9.1.1
Author | SHA1 | Date | |
---|---|---|---|
eb2174e566 | |||
2a56360875 | |||
ba862766a6 | |||
71291dab8f | |||
974ba7b450 | |||
8f7df39c07 | |||
ca3d8f0121 | |||
46c517d195 | |||
ff37f3b460 | |||
7b9b474484 | |||
e80a50d36c | |||
df99f96469 | |||
f87ad6a43c | |||
8bf5220e31 | |||
da8148251a | |||
01183ac34d | |||
d553e4763a | |||
213c3d29f3 | |||
697c1d91c6 | |||
b22de4ac4f | |||
0af9d27dcc | |||
b89b571c4e | |||
64505a295f | |||
c247bbf409 | |||
4c60e6a0c0 | |||
086e5ef184 | |||
7e81f7b368 | |||
defa431aa9 | |||
17eb4fe8c4 | |||
3997ce538d | |||
3654eb0800 | |||
c6bb255641 | |||
05a3cf5b43 | |||
dece0f58e1 | |||
7f3c5615c9 | |||
56d23176b7 | |||
958538c96a | |||
9fa6d5392b | |||
d7fdbf9736 | |||
0af1279b1d | |||
2bb2333cb9 | |||
78c511cab9 | |||
4016e961a9 | |||
9f3888d94f | |||
316891a1f2 | |||
0a9d844dcc | |||
15b8d85562 | |||
d1f3df5600 | |||
0fc0921aa9 | |||
7ad4c5409c | |||
a645accf5d | |||
b64cb2d448 | |||
cfcea6c863 | |||
d1cd17ff6e | |||
408869fa96 | |||
ed146fbffd | |||
e49e1cc7b9 | |||
2c9233c021 | |||
b2ad04e4e7 | |||
2381ba8a05 | |||
9cff0b2a57 | |||
a4754ebcfe | |||
8988f471c3 | |||
5f4ff94e26 | |||
6f531c5abc | |||
c761a362d1 | |||
2e155ddebc | |||
9c8a07eadc | |||
9cb9c8c462 | |||
4268c9d466 | |||
26f77eb45f | |||
dea23e4349 | |||
0ade4b1557 | |||
165d48323b | |||
179598cc07 | |||
a8656ca3fe | |||
020e0eb669 | |||
e5dfce523a | |||
b53b4a77b4 | |||
dd86cf3d27 | |||
32953b3696 | |||
cfec058c9d | |||
a1c07d5a8e | |||
5be745b081 | |||
b4fcfd6386 | |||
6e371d42a7 | |||
e8564d58c6 | |||
368aa431a0 | |||
afcd1ae060 | |||
244d2b8904 | |||
6dae62e1ab | |||
5810cb5f02 | |||
11c26af3a9 | |||
1b9b815214 | |||
c342137c6f | |||
eefc8bd8a5 | |||
9873861210 | |||
cf7a05e05d | |||
6eb11d8842 | |||
3ad68337e7 | |||
07f363fcb7 | |||
2d2e4cdab2 | |||
0cadec7f58 | |||
e86dbd3398 | |||
021f1b0c4d | |||
5aa2027252 | |||
2fc297ef3c | |||
3fe216846c | |||
649a50f7c5 | |||
dc14123a5a | |||
048a035a5d | |||
f212cf0251 | |||
1f2f5988e1 | |||
f1359a4750 | |||
f2775ed13c | |||
3ae749278e | |||
0bcc6910f4 | |||
c15951550c | |||
8308b6413e | |||
5b75875684 | |||
28029f4c1c | |||
824d7f9893 | |||
b3aea4b9a0 | |||
32377d187d | |||
a80815822d | |||
c198154fdc | |||
618c7a8578 | |||
ef7b930d4d | |||
8296895cc6 | |||
1dce6fee15 | |||
444e7771b4 | |||
962795743c | |||
f98f852a55 | |||
e379a7fe04 | |||
022b25cfcd | |||
e20bd66663 | |||
6b8e22368b | |||
4304e82751 | |||
75715fde37 | |||
e779f6ea62 | |||
9280cdba50 | |||
8410d0c06d | |||
d47d85bdcf | |||
6ae45327fe | |||
464cd946dc | |||
cbff540b6e | |||
a8e6ba4c49 | |||
efc1ceaf1a | |||
c4ed19e589 | |||
13cf3eee5a | |||
24c159de37 | |||
7570fc2bf5 | |||
6929dee846 | |||
d4ac2a08ee | |||
010ef05ce3 | |||
fa401297da | |||
ce0e9936c3 | |||
c13e9938cf | |||
b8f97553b3 | |||
2550da199d | |||
682b679bdb | |||
e0fd7e751c | |||
9b57db4716 | |||
d23f453d28 | |||
6c28f8bab0 | |||
10b87b5a70 | |||
6b6f9d7ed4 | |||
0434d00ff7 | |||
7e3acc25b9 | |||
62ad8f12b7 | |||
a6a656f1a0 | |||
1bf36009e8 | |||
86bdf3e199 | |||
a3c796aae3 | |||
dbe0586f70 | |||
7e2538dffc | |||
c3080ff9d9 | |||
772fc8462a | |||
e194780cd1 | |||
5b80ea32d7 | |||
31b7e07ab3 | |||
939d418af1 | |||
4258dd2a2e | |||
b7334a1ab5 | |||
9229f45d59 | |||
2bd4aacdd5 | |||
abbd695a8f | |||
f7b98bcde8 | |||
a756a7697c | |||
fd1ea5b4dc | |||
d83e089cd3 | |||
33715cc50c | |||
f3f1f2d0b1 | |||
c35e706fa8 | |||
35cebfe1a2 | |||
d04c42cbe8 | |||
8744e613ac | |||
cbeecbf3e1 | |||
f8ab2d1701 | |||
adc5c6f594 | |||
c9524cc497 | |||
90de6ba7e1 | |||
78d74ae60b | |||
579593a467 | |||
b5393dadae | |||
528ab1933e | |||
36181f8c91 | |||
45af681db1 | |||
ad6b482136 | |||
a6e1c2b019 | |||
3eb98533ae | |||
f5f021834e | |||
35702c3f77 | |||
8fbbd571ad | |||
2dd228be69 | |||
562835cfe7 | |||
6bac06e84d | |||
88436168ee | |||
0c3206d2e2 | |||
033debd339 | |||
d4f160732a | |||
4238fc9ab4 | |||
0d042b8dd1 | |||
afdd5f2d8f | |||
70c7b3d1b3 | |||
7b1cd5fe86 | |||
09ab169ffd | |||
35a82cf12e | |||
8d33cb01dd | |||
438d11dd86 | |||
d23b0d0789 | |||
1fa8c7ac82 | |||
3d6ead0359 | |||
379050dccd | |||
f9d1c197cf | |||
a89ee463e6 | |||
036caaacc8 | |||
80c37afe2b | |||
3a36d912fe | |||
c741d5d8ac | |||
0fa7dd13ad | |||
d5d80550e7 | |||
23a0a59454 | |||
066aa56f6a | |||
3997b7a5d6 | |||
ccc391607a | |||
9577192d41 | |||
968c3aed0f | |||
9c7a80729b | |||
5f26ca1c94 | |||
f2b1587bff | |||
3b9f80fb1a | |||
8da57bec51 | |||
63db9f290c | |||
e8bd4bd6c6 | |||
28d93b0c42 | |||
95f8e37006 | |||
87083cb264 | |||
1e8dc95c9c | |||
abfa242c28 | |||
56b5414152 | |||
8f46060be2 | |||
93b17ca2af | |||
66008115b8 | |||
55697a7c32 | |||
e9b259db6b | |||
55c51f7af1 | |||
4e7fd6a6dc | |||
6294ec448f | |||
668198b5d1 | |||
56b2ffe706 | |||
2ab06ffe36 | |||
0c51082bb9 | |||
9a9a2019f6 | |||
d94348f5ca | |||
4c10741862 | |||
222a25e4e2 | |||
5fd4490c4f | |||
e1cc65cb97 | |||
991f837bc1 | |||
87b3035465 | |||
4498305a6c | |||
cac7abba91 | |||
b9b55b2829 | |||
11365d5be5 | |||
47a5aff40c | |||
721fbbac67 | |||
bcca50fb40 | |||
229d2eb689 | |||
3ef80cc7b3 | |||
f1f11f36e4 | |||
28f187064e | |||
c391ca533a | |||
0ca92b80f9 | |||
84501b6038 | |||
dcd3e90b19 | |||
be7d84dfa0 | |||
b0d60109c9 | |||
b4659f9901 | |||
25f657b842 | |||
dfffb066f3 | |||
4f06d760a3 | |||
aea2531111 | |||
16707201b4 | |||
c7c9652095 | |||
05378f58ae | |||
d7549a1140 | |||
e3ee455186 | |||
210d9c58f2 | |||
db85c3dd2f | |||
4976a75ab3 | |||
414d0248f5 | |||
fa400bcf39 | |||
9e9ca526fe | |||
41c0fb5fc0 | |||
58e7dbf445 | |||
20e0213c7d | |||
b8f83fd6ad | |||
d1f75e3a42 | |||
337ff464cf | |||
cad4a5510b | |||
aa8438d8bd | |||
79363c2c2c | |||
f706d8e62d | |||
e7ee2a0fdf | |||
bd17df8e98 | |||
e237326319 | |||
a368ed7fd3 | |||
a9fa31ebac | |||
6b4a78ed41 | |||
9b93a15323 | |||
17774c50be | |||
a63095a7b4 | |||
9aba21e64c | |||
6288bb0701 | |||
2061854778 | |||
e4eeb3f87f | |||
a168dc1c15 | |||
99dee460ae | |||
36e9ac1179 | |||
df619ffe49 | |||
b1513d4ce9 | |||
7d0a71acef | |||
307a651e6d | |||
b7f6a7da6b | |||
1d9ff920e8 | |||
810846c49a | |||
cb66d68980 | |||
1badd6a53f | |||
7e37d8d27a | |||
5c950e1a07 | |||
adbb16f7eb | |||
dd088bf584 | |||
a27cb7db47 | |||
2e41387a50 | |||
9bb4803ac5 | |||
8bf2b6c9ce | |||
37f60c1766 | |||
7bce84eba0 | |||
46bedaa241 | |||
9a6d8c0e8b | |||
1571b7a1a7 | |||
16f5e5bbbc | |||
e3a8def43e | |||
40c11bae22 | |||
3a3415a3da | |||
222024fdde | |||
c5511bb3d9 | |||
5c4696a660 | |||
2812bef532 | |||
91379070d3 | |||
668f4f4e78 | |||
28ad740473 | |||
d08349f8eb | |||
b6e5b23f89 | |||
8dd8c079e7 | |||
eeee01a0e0 | |||
09ab91eeef | |||
a0a88412ff | |||
972fa77265 | |||
e69b063687 | |||
a89919397d | |||
0cbb5fb0a3 | |||
352cde743f | |||
b59fa6bb16 | |||
c0c62001fe | |||
e77a7dfdcd | |||
a26292a0fd | |||
18b2e91da2 | |||
a0437381e7 | |||
bb686bbcbe | |||
c898d0a3c3 | |||
704c678333 | |||
c59c5350fd | |||
accb1d44d0 | |||
b61f798cd9 | |||
be2ec9d4cf | |||
514fbb1c09 | |||
8ce397f61e | |||
3b0dfb8489 | |||
f4933deaf2 | |||
add2273551 | |||
91b00466a0 | |||
d0612e115e | |||
e4a6cbe887 | |||
0386810714 | |||
d4585f60b3 | |||
18f015a959 | |||
10c866bdea | |||
680c938dcf | |||
c3a617fefd | |||
6362b498a6 | |||
5e14bc6c2a | |||
2e30ab29be | |||
44568023cd | |||
c57aaa856d | |||
0f4f24c3f3 | |||
2fe7a2e3d3 | |||
20b62f5768 | |||
ab063eee08 | |||
66c7624b40 | |||
bfc302023f | |||
3505912f74 | |||
ec379f2e4d | |||
2d17954104 | |||
01c834b16b | |||
2aeb2c2e88 | |||
be88086434 | |||
28f0cc681d | |||
def29c535b | |||
168e5e6e11 | |||
ce71f19826 | |||
4fd3f3a6b8 | |||
39763d3869 | |||
36f90edc67 | |||
b0cbd6f609 | |||
d23d4a4557 | |||
07c58ee43c | |||
1037e8f1b9 | |||
f0ae8396f7 | |||
1ae5995f9c | |||
751ad9d304 | |||
0bd1514826 | |||
16bfc78d8d | |||
528008406a | |||
9e3010ac6a | |||
7c1fa6f4bf | |||
f58d31cc3d | |||
286c742ece | |||
3edc51d5a0 | |||
05d4c9688e | |||
d4401d1597 | |||
90358e73f6 | |||
a77ca02ea9 | |||
7785f0df02 | |||
0e6ed6e5ea | |||
70e84c8d38 | |||
11c3886659 | |||
6104e5bc35 | |||
c748b9a7fc | |||
714dbc0179 | |||
7f16cfc359 | |||
78757753c8 | |||
8343edcdf1 | |||
1ab9e08eb9 | |||
e1bc7f34c9 | |||
d5b495df5b | |||
d6256d2acb | |||
f1c7e448ae | |||
b600fd9324 | |||
3bf40ecb33 | |||
ffb650daa9 | |||
d2122e7806 | |||
6b6eb1d7a2 | |||
c80d881105 | |||
3c223c69e9 | |||
2420321008 | |||
29d5421cea | |||
71953cf45a | |||
325866d9c3 | |||
457e9c12e3 | |||
ff4a66466a | |||
cc142cc052 | |||
6e0dc69217 | |||
33332bcf66 | |||
b94f9ac25b | |||
0a7be48dcb | |||
3f3397620e | |||
154bc1df95 | |||
715e436c4c | |||
f5a9bcf839 | |||
31d2da86ff | |||
9dad3ca356 | |||
355e01edc6 | |||
c19bf1c404 | |||
970450074d | |||
91e8295648 | |||
3e40ae862b | |||
236cce604f | |||
0388a564b5 | |||
cd77ceba69 | |||
5ae8731abe | |||
7bb90c55d1 | |||
a07d6378e8 | |||
4fb8d277b4 | |||
73186ce920 | |||
d02f98956f | |||
d186d42bb6 | |||
338f7be967 | |||
b63a6e6e16 | |||
7e9884081e | |||
262f6323d0 | |||
811dd61562 | |||
9801879063 | |||
e30836c935 | |||
352511bb55 | |||
8ce057e25c | |||
0775ecb08b | |||
e909ab9886 | |||
e03bb155b9 | |||
91620d61d8 | |||
0fba450c9a | |||
ca604fb004 | |||
9e998d233c | |||
6c0fd3adec | |||
6ad18420e5 | |||
ef95a16f39 | |||
53861ec18d | |||
81b1569ad2 | |||
66a1992da0 | |||
100356c344 | |||
31905a27b1 | |||
08916176a2 | |||
ffb3d63c92 | |||
22005428ba | |||
a70acd6d63 | |||
af9e0b0d3f | |||
a0c2be8af2 | |||
df9d4b4219 | |||
cdf5015920 | |||
fe9b438a51 | |||
59cbf8c9cb | |||
7af8175034 | |||
bf0393b485 | |||
83a8822cf7 | |||
eada41b8a1 | |||
2c03377c47 | |||
484fc4aa2d | |||
2846014db0 | |||
c9d86619de | |||
ce485dbc29 | |||
4e875b4744 | |||
3f6c006716 | |||
f8f5d43b0c | |||
8c0fe00c6f | |||
c37d9ca5b3 | |||
f3dc1f0712 | |||
a4d96bbf6e | |||
90c40178aa | |||
2ee96b419a | |||
773900b620 | |||
ece440340f | |||
5233b4b5e6 | |||
86de252a52 | |||
c206d23480 | |||
5a53a138d9 | |||
5b5deb198e | |||
88a30e5af7 | |||
0b9ffa9a7b | |||
5052bcde4f | |||
d5409678ee | |||
72c39a9eb2 | |||
2ed7a28d1e | |||
7b2ff00c83 | |||
d5b0083d77 | |||
406183d104 | |||
c6d3e60314 | |||
be71037a13 | |||
c8c64b320b | |||
8514e8ad31 | |||
d505281a7e | |||
58575342e0 | |||
60ad6d6ab5 | |||
f9dec1cb3c | |||
ffd998cbf5 | |||
c713e6f371 | |||
3c55f9fc1f | |||
c9a8a99278 | |||
b309d327f0 | |||
58bad10bfe | |||
26ea6c518f | |||
d4594a97a2 | |||
68f951ef79 | |||
12e29c6a75 | |||
05eedb2ac1 | |||
8cbc6c15fe | |||
2c21f64b9f | |||
7ec9cff433 | |||
3f979b9981 | |||
3077ca96a7 | |||
46ded68369 | |||
b3a53d341d | |||
afcd5e70a1 | |||
ae48999e38 | |||
4c38e45455 | |||
ec847dccf9 | |||
ca47a1dc3f | |||
cc53ff417b | |||
fcba817a4a | |||
bcd8249d17 | |||
bc0a197ba1 | |||
2e16279d7b | |||
87590aedbd | |||
0fef7763d5 | |||
e55698d221 | |||
d410b5e96f | |||
8587601411 | |||
5b67cb21c6 | |||
42fd9d06de | |||
1e0b74fd27 | |||
21934ec85b | |||
b4f01fb6ec | |||
fbf6329500 | |||
41549443c3 | |||
92630af4e1 | |||
4db633da16 | |||
dac02f13ae | |||
1a52dec1c2 | |||
be1ca51162 | |||
768e20bb79 | |||
26b9b15de8 | |||
42713095b6 | |||
3acafeca38 | |||
7ca75c8c5a | |||
c00ad454a9 | |||
16d04eb4d3 | |||
816845f271 | |||
12eeda8d33 | |||
3d622c2ef1 | |||
21a6767c6f | |||
7a7326ec09 | |||
9b3af4e217 | |||
cee0114f81 | |||
03399aedf0 | |||
2739b94bd8 | |||
c720441d62 | |||
00b5898fe0 | |||
0d0940b7a5 | |||
f28c949ac6 | |||
63317d6ac8 | |||
6406ba831f | |||
7a7575964a | |||
d75c833717 | |||
40344b57d9 | |||
6fc26d1da3 | |||
a012a0e418 | |||
bf1a2f3059 | |||
ca316b4e6d | |||
1fb5c581c9 | |||
efa64b451a | |||
38059ea6b9 | |||
c2110622ca | |||
0452959b85 | |||
0eca8389b6 | |||
66e043137b | |||
d684654625 | |||
7749f6b20f | |||
15c9c0ae3e | |||
74fddc2ada | |||
cff866ecdc | |||
e952c02c83 | |||
546983c6ba | |||
c7134564a3 | |||
984a3573eb | |||
defe94a2b2 | |||
e23c8c4b46 | |||
7941ff487a | |||
7b7df33a0f | |||
68b04f2511 | |||
db3e017a7d | |||
c21d45a79e | |||
6defb686bb | |||
f68796dae1 | |||
b1872bcb95 | |||
3006f4d2c1 | |||
7f88a38219 | |||
aeb2487c70 | |||
e42e50dd39 | |||
f4572b9720 | |||
7646f3a845 | |||
e4e5b1e4f6 | |||
a481518470 | |||
2435ebf16e | |||
414fa70e5d | |||
f255d4c141 | |||
4513bb529b | |||
5907132062 | |||
69bf313f18 | |||
fe8b0a6b2b | |||
abcfd79f2f | |||
41e3b078ec | |||
4eb2f92c1f | |||
9bfb5bf681 | |||
473ad2947c | |||
ee28f6ad84 | |||
11bebd42ac | |||
49b4ca67e0 | |||
3282f762df | |||
d335106b46 | |||
cefa01f7ec | |||
b7ba2b3306 | |||
03d5152e7c | |||
af3b7f2613 | |||
1405841565 | |||
211d2dc0d6 | |||
82f431465f | |||
247afe56ce | |||
91e874eee5 | |||
ff67c3660b | |||
58c580b9ca | |||
a9da151026 | |||
83c72d0dbb | |||
2c31367851 | |||
3b618f3a2c | |||
4c5bc6232d | |||
694835bdac | |||
c8b75c19da | |||
c0181aa83a | |||
c5b615ae2a | |||
54cbd56f42 | |||
c8914a109e | |||
62d0767ceb | |||
8509bccc4f | |||
4ce53a3d76 | |||
8024c01a82 | |||
1b380c3fdb | |||
06b67bd292 | |||
8a1087f601 | |||
ff09d6515c | |||
ebe85d8e14 | |||
5dc27ac46a | |||
1dcc8ee761 | |||
ec69f9ac07 | |||
f789f60e22 | |||
32e3f07d57 | |||
9ea41ab3ce | |||
4b8d062862 | |||
d9408029f3 | |||
9fe0406078 | |||
5a4fe5d5da | |||
e6af9b4b73 | |||
361f9231d8 | |||
4215932550 | |||
29da523579 | |||
fbb4d7cfde | |||
3ea453a07f | |||
984e762a53 | |||
1592aa7117 | |||
62b4522c94 | |||
8b86751c95 | |||
afa380e336 | |||
feebff9077 | |||
028b50ff99 | |||
559e81c3fe | |||
4da6b98437 | |||
5b2409c76f | |||
ff027d172e | |||
3f23290a46 | |||
f1a10d32e6 | |||
a71f40e873 | |||
7f449319cd | |||
ab5c8ea698 | |||
68cfa9360b | |||
f627e3d994 | |||
7c870548d9 | |||
57ccc41547 | |||
988ba45197 | |||
df6606041b | |||
3ae27b466f | |||
69f5e21435 | |||
6da73c612a | |||
e1b1c1492f | |||
6ca13c4fce | |||
b474567d20 | |||
c07170902e | |||
0f201d2f4b | |||
b875d6f183 | |||
831b92239d | |||
66b91c22dd | |||
1242c0689f | |||
4386d02526 | |||
3ba521f8cc | |||
85bb818ae6 | |||
be7e2aa8fe | |||
7f71f6e3f1 | |||
a94d23e2ae | |||
133c255ce2 | |||
863e27ff9b | |||
5c63e6ae12 | |||
10dd36569d | |||
be5985fb6a | |||
0d7f169613 | |||
eaddcb83ab | |||
9a6885f124 | |||
7284ee818b | |||
20964454c4 | |||
d7670929d1 | |||
58f0761423 | |||
3f28bc09bc | |||
323895f0ab | |||
6efa734e81 | |||
47d64af737 | |||
4a2b91ce07 | |||
080a77cc73 | |||
9b874b0061 | |||
ff8a2ed538 | |||
251eafe103 | |||
64b604c9ac | |||
72fc5f9874 | |||
71dcdf0ca2 | |||
e23fc987a7 | |||
36dba1a36f | |||
1b1547d4b6 | |||
8008482592 | |||
6d1a7fe438 | |||
90c58b0498 | |||
c91bb71700 | |||
3d09c45205 | |||
f1e41d883c | |||
4f783ec8e4 | |||
3d35e84953 | |||
e80bc8b584 | |||
2848b39479 | |||
7ee9be200c | |||
94cdd740ad | |||
9130687164 | |||
2f52f47463 | |||
01866f4802 | |||
fa8ac0f2e4 | |||
e9a909ed20 | |||
8808447963 | |||
056b496189 | |||
11b374ea75 | |||
f8f9744786 | |||
6f6888d638 | |||
995430b76f | |||
d4a5ec4e14 | |||
c7dce059f8 | |||
2f4e3f2153 | |||
a37c5646b6 | |||
ddc9c8f62f | |||
1b06fc71cf | |||
e65a3bfeab | |||
b9ceabcc07 | |||
35be3bfb9b | |||
572c8efbc7 | |||
b1b3e2369b | |||
dc72bb629e | |||
a724706817 | |||
84989116ef | |||
6c4efe4a1c | |||
8596d70b79 | |||
db6c9b2700 | |||
a33602ccf6 | |||
988987ddbe | |||
309e66a6de | |||
7d8cfc0382 | |||
5cbae5d3f7 | |||
9b630c4ef7 | |||
befcbabe27 | |||
4cfb0ade88 | |||
a6f528537b | |||
dfc82a517d | |||
29f421686f | |||
c11299076f | |||
1cb2ef565e | |||
2de07d04a8 | |||
75e064dd1d | |||
5f0091ee25 | |||
d2c0e656d0 | |||
522b21862b | |||
ccf66dbd50 | |||
6e30ab0355 | |||
568c764e3c | |||
d508e8ae31 | |||
ded346e34a | |||
edb8eddce1 | |||
abd3641da4 | |||
7e1165d012 | |||
461754e591 | |||
e649330dbc | |||
baec324811 | |||
91c430d9e2 | |||
efd853d519 | |||
f717b0eae4 | |||
d76d21a1f2 | |||
712450d717 | |||
b9d93c9d33 | |||
c7ca51cd65 | |||
20b793620a | |||
9bed303d34 | |||
f4ed171f85 | |||
8a3ccdb196 | |||
41765d133f | |||
482ea1b186 | |||
3bba7f9d23 | |||
7e5e2baf92 | |||
53c70e6cd1 | |||
4bfb87ea74 | |||
86e12c7d40 | |||
eb5449adf8 | |||
19eeec9fc8 | |||
449f5f5be3 | |||
bc5a1b52b7 | |||
fc7f37767f | |||
38dbdd02ae | |||
7bb3fa74ce | |||
a33660d32c | |||
ef842d1f3f | |||
e5c2a0a87b | |||
817ffe8fd0 | |||
5b582d45ba | |||
6a303532f4 | |||
c75abb7cb9 | |||
8282d76b87 | |||
79f3866c4c | |||
6dcf3f25e9 | |||
e80acea63f | |||
640639264d | |||
3ccdd2585c | |||
2c4b55c692 | |||
70a3b25d54 | |||
d053baef03 | |||
629c586014 | |||
32a5cca878 | |||
911c705b59 | |||
594c8d72b8 | |||
7ea5232b22 | |||
be12d61795 | |||
925340eb3d | |||
e4b03b3f71 | |||
9ab6df99b1 | |||
51519a55ef | |||
059455929b | |||
8a1df4438e | |||
cbf6e46e35 | |||
727b1bd63b | |||
363b8d74ae | |||
b31ecd6583 | |||
563914a0ef | |||
1e8adbb240 | |||
4b1f89a561 | |||
1a4a0ea5b8 | |||
f781028b08 | |||
56e8ad4f17 | |||
62c34ae612 | |||
26123b0a93 | |||
4023464a13 | |||
0c92f354c5 | |||
676723c8bd | |||
2f4d5afaea | |||
d0abceb08d | |||
8b165e93e1 | |||
321969eb85 | |||
85ec90849e | |||
96451bc5b7 | |||
311cbf55ef | |||
0258b256f2 | |||
c615de97c4 | |||
e29a7bf146 | |||
b665c243f0 | |||
bea1c9ed61 | |||
0e6bdaa9c9 | |||
7925689618 | |||
0e818c8d73 | |||
791441ec86 | |||
401de9147c | |||
563e10fa92 | |||
a22c34d8c2 | |||
e549f8ae61 | |||
0ac23d0646 | |||
814d3892f2 | |||
07d1306a35 | |||
5950055cca | |||
d6dd468e84 | |||
9a221a01ab | |||
601a4038f4 | |||
2a78a29b08 | |||
e90d97b813 | |||
d020d59b11 | |||
5d6d52a465 | |||
ebb3f8137e | |||
af7d275c27 | |||
2b01a6006c | |||
9f3940746a | |||
9f729b3bb3 | |||
2376fb5834 | |||
0a1507599b | |||
42bb01c416 | |||
cfb0ae7428 | |||
6b30f44da0 | |||
a7f89ac58f | |||
38711f04bc | |||
78fd99c26e | |||
cae10d4611 | |||
40233dbf87 | |||
35865e46f0 | |||
ea565d8f71 | |||
859a3f4015 | |||
ebcb37cbed | |||
1bdf9a4987 | |||
d7a9cb2168 | |||
8890e13ccb | |||
87e1844f04 | |||
388030c6ec | |||
d5bd407802 | |||
ba4dc2ed54 | |||
c982e64996 | |||
0425939668 | |||
48b804b765 | |||
246ae6e6bc | |||
efa5b65e45 | |||
f4f6ee5055 | |||
1a630bcb4d | |||
600fef21f6 | |||
b779ee79a5 | |||
08537944ae | |||
004b3641eb | |||
b6be05a931 | |||
191cc071c2 | |||
9e52c46ad3 | |||
21f7662a77 | |||
d4d7f92df8 | |||
a3180fd70d | |||
3dc4f8e87a | |||
64393d92a5 | |||
1fbd405e41 | |||
f711aa1b58 | |||
e2e527ce44 | |||
bb7f48c021 | |||
ad9b64e7ae | |||
ef2ee6d00d | |||
2d259c4edc | |||
b286e3ae09 | |||
ec3e193672 | |||
40a2fcd81e | |||
7e876bad7e | |||
aefa3b102c | |||
4d1f295a26 | |||
56a31faf7e | |||
f3afef01b0 | |||
ea38655c48 | |||
972d06b492 | |||
8538489136 | |||
4f28464b99 | |||
049e111797 | |||
96199c4b12 | |||
cf23789edf | |||
48724e5b08 | |||
40c778d244 | |||
ff0c44ecfc | |||
828cc15ea3 | |||
bbbe55b706 | |||
cd98bdec9b | |||
59767bddfe | |||
035ae40b97 | |||
f7603bfdfc | |||
754201a9a2 | |||
d0af7e4781 | |||
ecf0bf8cdd | |||
85bafb3eef | |||
efe378e94f | |||
614cb74d47 | |||
df4190321e | |||
56c3574a2b | |||
51b11c7035 | |||
564693cf22 | |||
50a6bed92f | |||
ef54b3cf2e | |||
ebf06250b1 | |||
56f9c22ac6 | |||
384242974b | |||
7717d95cab | |||
5b69a32c11 | |||
24abf51c8c | |||
80c5092dc1 | |||
15ffa4d98b | |||
4935878f73 | |||
440782e9cf | |||
f304220463 | |||
02a5aaf5d8 | |||
e84641c13c | |||
278b6b6a20 | |||
d369c0a74c | |||
ab9f97598c | |||
2814841226 | |||
a7d55a52f3 | |||
d436b7b339 | |||
f183d38bb3 | |||
2353b36709 | |||
00db6e7dc1 | |||
eb479c4684 | |||
68413605e9 | |||
02bd5d71d0 | |||
97a851a848 | |||
f503794e09 | |||
d0ee5fa23a | |||
0ccf0f8d7a | |||
719f7c8f9e | |||
828e30a248 | |||
6beb7208af | |||
2d342a2415 | |||
a2017fc353 | |||
709c3d9b55 | |||
950867d032 | |||
65caa531c5 | |||
64addc85ee | |||
aa02261248 | |||
6d447033c9 | |||
c888f589d0 | |||
bb6eb87313 | |||
813143237b | |||
91c149caf8 | |||
3e619e47b2 | |||
e0576c889b | |||
3c03281b78 | |||
1d0c43e45d | |||
982d923553 | |||
4697d774f4 | |||
c19bc6b4b3 | |||
9c15cb55c8 | |||
73b974ddb2 | |||
c38e70e25d | |||
60096a94c9 | |||
c155f76550 | |||
9827ed30bb | |||
49054dae27 | |||
46f1f78529 | |||
5b7c62685d | |||
0acb9cf7a9 | |||
233a29bfef | |||
d6ec275778 | |||
291a650337 | |||
9d4476b04a | |||
871e0721b9 | |||
f1ab24c439 | |||
05c053a44d | |||
966a14b1b3 | |||
c00751d26a | |||
9fe329d542 | |||
96f2e8acb5 | |||
37dd51a119 | |||
e962f0ab83 | |||
a7f17f91d6 | |||
20cdd25e70 | |||
a79f839693 | |||
c7b68a40e4 | |||
f414b4ee9a | |||
ea908d57b5 | |||
bdbd15e7d9 | |||
00ae5a1a1f | |||
48f7e15be9 | |||
99d3a241a0 | |||
eea9643d7e | |||
d66f79e7b3 | |||
a5193b18d8 | |||
ec408c2dea | |||
cb79c616ee | |||
c7d9be597f | |||
c77542195e | |||
824f5d6396 | |||
0b2235793b | |||
559b92a8f9 | |||
8c7c373097 | |||
52f1392cc2 | |||
c21cc6c3e9 | |||
5cba27b482 | |||
4fe8a2aa9d | |||
27b3884e4d | |||
b54ff84adb | |||
8e8d09bbda | |||
0f78442cca | |||
9578c4ba33 | |||
9431f7b34e | |||
460d4888eb | |||
c8b183f057 | |||
27b0169e5f | |||
e47d8846a4 | |||
4f846f2a4a | |||
2246c625ce | |||
4e97012466 | |||
b7c0ad2d84 | |||
065977af37 | |||
4ff7f0a7bd | |||
2882c9aee2 | |||
96ad7c5886 | |||
c41b208ecb | |||
5f446a1f39 | |||
62223f3053 | |||
ce80a592de | |||
4e002ff342 | |||
9260fcb450 | |||
19b4f87ec1 | |||
2a9607b5b4 | |||
0bc3fe0617 | |||
375818b496 | |||
98d82248df | |||
d22263293f | |||
dbf7157ac6 | |||
dbd8d98223 | |||
aedaa98ecf | |||
252878dd74 | |||
2dc7fa7fda | |||
d50c00b8e4 | |||
aef9c9883d | |||
cf825676d3 | |||
af56f33b83 | |||
512cded8aa | |||
4af9e2545f | |||
7ea0917b90 | |||
6ed9059c34 | |||
33ec69bc17 | |||
f07ce0bbf4 | |||
d2f9816714 | |||
58305b5970 | |||
0b0a185fef | |||
d9743c2fa8 | |||
71b7c22aa8 | |||
2237b7d687 | |||
435fe309bd | |||
464002a03b | |||
fe7e7f4085 | |||
5a0c42a351 | |||
fe3a299b32 | |||
8712c0f2e0 | |||
c495035da0 | |||
0286749ffc | |||
54b43c76e1 | |||
0ffe150fdc | |||
e630c694b3 | |||
853219dca5 | |||
63a5e25e42 | |||
0fe51ffcb2 | |||
b8a750aa64 | |||
26dfed5853 | |||
259b428d2d | |||
29dd14933e | |||
98013466be | |||
27dd0a6ede | |||
e40deff1b5 | |||
6f4b70b7ed | |||
6bf962a670 | |||
896f6b5000 | |||
8011c54631 | |||
591e9b0be0 | |||
b6f6bb0894 | |||
d14f343481 | |||
afc50719ce | |||
257b3f075d | |||
1973597eb2 | |||
a87ecc2c99 | |||
a4eeb5782e | |||
36f537144a | |||
ad047110b4 | |||
32ac881d3d | |||
5fba4d8e76 | |||
d836231737 | |||
bfcacc16a2 | |||
862d04f4d5 | |||
d1699482bf | |||
622289ce2c | |||
0859026fcc | |||
c19c55d2c2 | |||
f21b1bc85b | |||
9ba31e8c3c | |||
fe71e59524 | |||
ddd85688ce | |||
6ca91e78db | |||
0008090360 | |||
8cf779d5b8 | |||
b81086ab7a | |||
6b2eab89d8 | |||
3cf4eb7b48 | |||
fd44b3b649 | |||
ce4eaec827 | |||
456e424d4d | |||
2f3b6a2753 | |||
c49a0225d7 | |||
c1e47885e0 | |||
b2a09b512f | |||
75bf33d64e | |||
33b44c1612 | |||
dc7f199345 | |||
bf77d76a75 | |||
26bdca5f30 | |||
491b774dd9 | |||
65e004f0c1 | |||
8348db2067 | |||
5dfe811a46 | |||
10f76962dd | |||
6377bb2d81 | |||
a012896665 | |||
8c5859aacd | |||
cf267cc84a | |||
578cc1530b | |||
516658ad56 | |||
d37e78057c | |||
2eabf1aba8 | |||
67b4e48c74 | |||
2c0921c8e6 | |||
2642571cf9 | |||
b14d657ad6 | |||
7d010f1186 | |||
dec9c3db49 | |||
326c4492d0 | |||
b1270309c0 | |||
607e01925e | |||
700474f80d | |||
37655b357f | |||
3ae5b5d8d5 | |||
f7bd5ae327 | |||
d307ecbde0 | |||
fa8d0bc9a6 | |||
b34b01e2da | |||
b32d6645aa | |||
594861024d | |||
22fd752afc | |||
5c57e61f84 | |||
d3479b4e45 | |||
5eaeed2679 | |||
bea22bef53 | |||
06d055c37d | |||
009faac447 | |||
4444063bcb | |||
826b9e9a99 | |||
9905654ef0 | |||
00549cc011 | |||
768f3c8f8f | |||
096a627944 | |||
63892f8ab4 | |||
3094d216a8 | |||
c1fd61850b | |||
5e95a6272d | |||
111c80d049 | |||
e6aad63047 | |||
e7fa73d145 | |||
bf685faf1d | |||
efcd318100 | |||
9cbb307fcc | |||
a868692b7a | |||
4900697d4a | |||
60bc688ce2 | |||
ab7d4f9f25 | |||
9a937891a8 | |||
3a27a33d8c | |||
e5005598e2 | |||
fbaea25fa3 | |||
9ce032decf | |||
01ab5e0c00 | |||
1412b40c4e | |||
e0ac5081ab | |||
dd4ee37179 | |||
344f7f036d | |||
2e02a3dfad | |||
3235f9bd7a | |||
e6cee96a9d | |||
11d902ff21 | |||
b8196aaa5a | |||
591fc0abad | |||
eb25eb43d7 | |||
df6b1c0815 | |||
82d9a71e67 | |||
d46c4e7387 | |||
abf2f531da | |||
f36b13f9ae | |||
4775093376 | |||
531e240a37 | |||
152b91685c | |||
2b0e8385f1 | |||
36b3242f4a | |||
8ca113c87b | |||
d3fd3938c7 | |||
8f0bbec5da | |||
6e95fd0fb9 | |||
dd842d54f0 | |||
efb48bf9ea | |||
d1d0310200 | |||
fdeb873536 | |||
8583aa0632 | |||
7682745402 | |||
2eb0b537f1 | |||
6d3ebf90c1 | |||
ed8b4180f8 | |||
4ad34920b7 | |||
ede6a32537 | |||
078d4908c2 | |||
c9135953f7 | |||
5259f30752 | |||
2223cfb6b2 | |||
345ce6db6d | |||
7accb91195 | |||
2bb9a78d2f | |||
f303306935 | |||
c82ad9711b | |||
41acda6a06 | |||
5d7ef7ab58 | |||
29f7f1a240 | |||
6b0d777bd7 | |||
455e66f74d | |||
36af1643a4 | |||
3a022c4d2a | |||
e50a6edbed | |||
31728ea253 | |||
5289ea8e1c | |||
d808b287a7 | |||
5ad7fd8a15 | |||
74fbc715e9 | |||
1385a5d702 | |||
e08ad990a8 | |||
35d987430a | |||
bb48068408 | |||
75d62723b6 | |||
02222c8681 | |||
c3800c4559 | |||
0e033131b2 | |||
0be6f31611 | |||
e8a8b73ad0 | |||
953c6806ce | |||
1cf68c696e | |||
6d354674b2 | |||
e598faad28 | |||
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 | |||
e65e7d6a32 | |||
fc87a73259 | |||
ec4c4fb5c4 | |||
870c222dd5 | |||
6b3d1d5579 | |||
5bca7d155f | |||
db7c4da609 | |||
9c11653313 | |||
2100b7b7d2 | |||
2cf1cce06d | |||
4ca44d335d | |||
358d578cd7 | |||
c61d24d8d4 |
71
.cspell.json
Normal file
71
.cspell.json
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
// cSpell Settings
|
||||||
|
{
|
||||||
|
// Version of the setting file. Always 0.2
|
||||||
|
"version": "0.2",
|
||||||
|
// language - current active spelling language
|
||||||
|
"language": "en_US",
|
||||||
|
"dictionaries": ["en_US", "typescript", "softwareTerms", "fonts", "npm"],
|
||||||
|
// words - list of words to be always considered correct
|
||||||
|
"words": [
|
||||||
|
"Abjad",
|
||||||
|
"aink",
|
||||||
|
"aiueo",
|
||||||
|
"ATLEAST",
|
||||||
|
"chosung",
|
||||||
|
"clippy",
|
||||||
|
"datas",
|
||||||
|
"dcmitype",
|
||||||
|
"dcterms",
|
||||||
|
"docsify",
|
||||||
|
"dolan",
|
||||||
|
"execa",
|
||||||
|
"falsey",
|
||||||
|
"horz",
|
||||||
|
"iife",
|
||||||
|
"Initializable",
|
||||||
|
"iroha",
|
||||||
|
"JOHAB",
|
||||||
|
"jsonify",
|
||||||
|
"jszip",
|
||||||
|
"NUMPAGES",
|
||||||
|
"odttf",
|
||||||
|
"ondata",
|
||||||
|
"onfile",
|
||||||
|
"ooxml",
|
||||||
|
"panose",
|
||||||
|
"rels",
|
||||||
|
"rsid",
|
||||||
|
"sdtdh",
|
||||||
|
"twip",
|
||||||
|
"twips",
|
||||||
|
"Xmlable",
|
||||||
|
"xmlified",
|
||||||
|
"xmlify",
|
||||||
|
"Xmlifyed"
|
||||||
|
],
|
||||||
|
"ignoreRegExpList": [
|
||||||
|
"/\"w:.+\"/",
|
||||||
|
"/\"s:.+\"/",
|
||||||
|
"/\"a:.+\"/",
|
||||||
|
"/\"pic:.+\"/",
|
||||||
|
"/\"xmlns:.+\"/",
|
||||||
|
"/\"vt:.+\"/",
|
||||||
|
"/[^\\s]{40,}/",
|
||||||
|
"/<xsd:.+/>/",
|
||||||
|
"/[A-Z_]+ = \".+\"/",
|
||||||
|
"/XmlAttributeComponent<{[^}]+}>/g",
|
||||||
|
"/xmlKeys = {[^}]+}/g",
|
||||||
|
"/\\.to\\.deep\\.equal\\({[^)]+}\\)/g",
|
||||||
|
"\\.to\\.include\\.members\\(\\[[^\\]]+]\\)",
|
||||||
|
"/new [a-zA-Z]+\\({[^£]+}\\)/g",
|
||||||
|
"/<element name=\"[a-z]+\"/gi",
|
||||||
|
"/<attribute name=\"[a-z]+\"/gi",
|
||||||
|
"/key: \".+\"/"
|
||||||
|
],
|
||||||
|
"ignorePaths": ["package.json", "docs/api", "*.docx", "build"],
|
||||||
|
"allowCompoundWords": true,
|
||||||
|
// flagWords - list of words to be always considered incorrect
|
||||||
|
// This is useful for offensive words and common spelling errors.
|
||||||
|
// For example "hte" should be "the"
|
||||||
|
"flagWords": ["hte"]
|
||||||
|
}
|
@ -7,6 +7,7 @@ indent_style = space
|
|||||||
indent_size = 4
|
indent_size = 4
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
max_line_length = off
|
max_line_length = off
|
||||||
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# https://prettier.io/docs/en/options.html#end-of-line
|
||||||
|
* text=auto eol=lf
|
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
|
12
.github/actions/install-and-build/action.yml
vendored
Normal file
12
.github/actions/install-and-build/action.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
name: Install dependencies and build ⚙️
|
||||||
|
description: Install dependencies and build
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Install Dependencies
|
||||||
|
shell: bash
|
||||||
|
run: npm ci --force
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: npm run build
|
14
.github/actions/validate-docx/action.yml
vendored
Normal file
14
.github/actions/validate-docx/action.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Extract and Validate Document ⚙️
|
||||||
|
description: Extract the document and validate the XML against the schema.
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Extract Word Document
|
||||||
|
shell: bash
|
||||||
|
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
|
7
.github/dependabot.yml
vendored
Normal file
7
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: npm
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
open-pull-requests-limit: 10
|
83
.github/workflows/default.yml
vendored
83
.github/workflows/default.yml
vendored
@ -13,13 +13,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- uses: "./.github/actions/install-and-build"
|
||||||
run: npm ci
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
- name: Archive Production Artifact
|
- name: Archive Production Artifact
|
||||||
uses: actions/upload-artifact@master
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build
|
name: build
|
||||||
path: build
|
path: build
|
||||||
@ -28,19 +25,26 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci --force
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm run test.coverage
|
run: npm run test:ci
|
||||||
|
- name: Codecov
|
||||||
|
uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
lint:
|
lint:
|
||||||
name: Lint
|
name: Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci --force
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
prettier:
|
prettier:
|
||||||
@ -48,57 +52,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci --force
|
||||||
- name: Prettier
|
- name: Prettier
|
||||||
run: npm run style
|
run: npm run prettier
|
||||||
demos:
|
cspell:
|
||||||
name: Run Demos
|
name: CSpell
|
||||||
needs: [build]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v4
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci --force
|
||||||
- name: Download Artifact
|
- name: CSpell
|
||||||
uses: actions/download-artifact@master
|
run: npm run cspell
|
||||||
with:
|
|
||||||
name: build
|
|
||||||
path: build
|
|
||||||
- name: Run demos
|
|
||||||
run: |
|
|
||||||
npm run ts-node -- ./demo/1-basic.ts
|
|
||||||
npm run ts-node -- ./demo/2-declaritive-styles.ts
|
|
||||||
npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
|
|
||||||
npm run ts-node -- ./demo/4-basic-table.ts
|
|
||||||
npm run ts-node -- ./demo/5-images.ts
|
|
||||||
npm run ts-node -- ./demo/6-page-borders.ts
|
|
||||||
npm run ts-node -- ./demo/7-landscape.ts
|
|
||||||
npm run ts-node -- ./demo/8-header-footer.ts
|
|
||||||
npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
|
|
||||||
npm run ts-node -- ./demo/10-my-cv.ts
|
|
||||||
npm run ts-node -- ./demo/11-declaritive-styles-2.ts
|
|
||||||
npm run ts-node -- ./demo/12-scaling-images.ts
|
|
||||||
npm run ts-node -- ./demo/13-xml-styles.ts
|
|
||||||
npm run ts-node -- ./demo/14-page-numbers.ts
|
|
||||||
npm run ts-node -- ./demo/15-page-break-before.ts
|
|
||||||
npm run ts-node -- ./demo/16-multiple-sections.ts
|
|
||||||
npm run ts-node -- ./demo/17-footnotes.ts
|
|
||||||
npm run ts-node -- ./demo/18-image-from-buffer.ts
|
|
||||||
npm run ts-node -- ./demo/19-export-to-base64.ts
|
|
||||||
npm run ts-node -- ./demo/20-table-cell-borders.ts
|
|
||||||
npm run ts-node -- ./demo/21-bookmarks.ts
|
|
||||||
npm run ts-node -- ./demo/22-right-to-left-text.ts
|
|
||||||
npm run ts-node -- ./demo/23-base64-images.ts
|
|
||||||
npm run ts-node -- ./demo/24-images-to-table-cell.ts
|
|
||||||
npm run ts-node -- ./demo/26-paragraph-borders.ts
|
|
||||||
npm run ts-node -- ./demo/27-declaritive-styles-3.ts
|
|
||||||
npm run ts-node -- ./demo/28-table-of-contents.ts
|
|
||||||
npm run ts-node -- ./demo/29-numbered-lists.ts
|
|
||||||
npm run ts-node -- ./demo/30-template-document.ts
|
|
||||||
npm run ts-node -- ./demo/31-tables.ts
|
|
||||||
npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
|
|
||||||
npm run ts-node -- ./demo/33-sequential-captions.ts
|
|
||||||
npm run ts-node -- ./demo/34-floating-tables.ts
|
|
||||||
|
196
.github/workflows/demos.yml
vendored
Normal file
196
.github/workflows/demos.yml
vendored
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
name: Demos
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
demos:
|
||||||
|
name: Demos
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: "./.github/actions/install-and-build"
|
||||||
|
- name: Run Demos
|
||||||
|
run: npm run run-ts -- ./demo/1-basic.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/2-declaritive-styles.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/3-numbering-and-bullet-points.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/4-basic-table.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/5-images.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/6-page-borders.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/7-landscape.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/8-header-footer.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/9-images-in-header-and-footer.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/10-my-cv.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/11-declaritive-styles-2.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/12-scaling-images.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/13-xml-styles.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/14-page-numbers.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/15-page-break-before.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/16-multiple-sections.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/17-footnotes.ts
|
||||||
|
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/18-image-from-buffer.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/19-export-to-base64.ts
|
||||||
|
# Base 64 No longer works, abruptly. Node issue?
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/20-table-cell-borders.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/21-bookmarks.ts
|
||||||
|
# Bad ID - need numeric ID
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/22-right-to-left-text.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/23-base64-images.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/24-images-to-table-cell.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/25-table-xml-styles.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/26-paragraph-borders.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/27-declaritive-styles-3.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/28-table-of-contents.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/29-numbered-lists.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/31-tables.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/32-merge-and-shade-table-cells.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/33-sequential-captions.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/34-floating-tables.ts
|
||||||
|
# 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.
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/35-hyperlinks.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/36-image-to-table-cell.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/37-images-to-header-and-footer.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/38-text-wrapping.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/39-page-numbers.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/40-line-numbers.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/41-merge-table-cells-2.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/42-restart-page-numbers.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/43-images-to-table-cell-2.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/44-multiple-columns.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/45-highlighting-text.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/46-shading-text.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/47-number-of-total-pages-section.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/48-vertical-align.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/49-table-borders.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/50-readme-demo.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/51-character-styles.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/52-japanese.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/53-chinese.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/54-custom-properties.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/55-math.ts
|
||||||
|
#: 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 ).
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/56-background-color.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/57-add-parent-numbered-lists.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/58-section-types.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/59-header-footer-margins.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/60-track-revisions.ts
|
||||||
|
# element r: Schemas validity error : Element '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r': This element is not expected.
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/61-text-frame.ts
|
||||||
|
# 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 ).
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/62-paragraph-spacing.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/63-odd-even-header-footer.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/64-complex-numbering-text.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/65-page-sizes.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/66-fields.ts
|
||||||
|
# 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'.
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/67-column-break.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/68-numbering-instances-and-starting-number.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/69-different-width-columns.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/70-line-numbers-suppression.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/71-page-borders-2.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/72-word-wrap.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/73-comments.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/74-nodejs-stream.ts
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
# run: npm run run-ts -- ./demo/75-tab-stops.ts
|
||||||
|
# - uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/76-compatibility.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/77-side-by-side-tables.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/78-thai-distributed.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/79-table-from-data-source.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/80-thai-distributed.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/81-continuous-header.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/82-new-headers-new-section.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/83-setting-languages.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
||||||
|
- run: npm run run-ts -- ./demo/84-positional-tabs.ts
|
||||||
|
- uses: "./.github/actions/validate-docx"
|
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@v4
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci --force
|
||||||
|
- 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@v4
|
||||||
|
with:
|
||||||
|
name: docs
|
||||||
|
path: docs
|
||||||
|
deploy:
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repo 🛎️
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm ci --force
|
||||||
|
- name: Download Artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: docs
|
||||||
|
path: docs
|
||||||
|
- name: Deploy 🚀
|
||||||
|
uses: JamesIves/github-pages-deploy-action@4.1.5
|
||||||
|
with:
|
||||||
|
branch: gh-pages
|
||||||
|
folder: docs
|
46
.github/workflows/npm-publish.yml
vendored
Normal file
46
.github/workflows/npm-publish.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
||||||
|
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
||||||
|
|
||||||
|
name: Node.js Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm run cspell
|
||||||
|
- run: npm run prettier
|
||||||
|
- run: npm run lint
|
||||||
|
- run: npm run test:ci
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm run build
|
||||||
|
|
||||||
|
publish-npm:
|
||||||
|
needs: [test, build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
- run: npm ci --force
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
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
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -33,8 +33,7 @@ node_modules
|
|||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
# build
|
# build
|
||||||
build
|
dist
|
||||||
build-tests
|
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
docs/api/
|
docs/api/
|
||||||
@ -60,5 +59,5 @@ My Document.docx
|
|||||||
# Temporary folder
|
# Temporary folder
|
||||||
tmp
|
tmp
|
||||||
|
|
||||||
# nyc
|
# Exclude Mac .DS_Store files
|
||||||
.nyc_output
|
.DS_Store
|
||||||
|
@ -40,4 +40,7 @@ build-tests
|
|||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
docs
|
docs
|
||||||
|
|
||||||
|
# src
|
||||||
|
src
|
||||||
|
26
.nycrc
26
.nycrc
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"check-coverage": true,
|
|
||||||
"lines": 96.81,
|
|
||||||
"functions": 93.80,
|
|
||||||
"branches": 92.63,
|
|
||||||
"statements": 96.80,
|
|
||||||
"include": [
|
|
||||||
"src/**/*.ts"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"src/**/*.spec.ts",
|
|
||||||
"src/import-dotx/import-dotx.ts"
|
|
||||||
],
|
|
||||||
"reporter": [
|
|
||||||
"lcov",
|
|
||||||
"text",
|
|
||||||
"json"
|
|
||||||
],
|
|
||||||
"extension": [
|
|
||||||
".ts"
|
|
||||||
],
|
|
||||||
"cache": true,
|
|
||||||
"all": true,
|
|
||||||
"instrument": false,
|
|
||||||
"sourceMap": true
|
|
||||||
}
|
|
63
.travis.yml
63
.travis.yml
@ -1,63 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- 10
|
|
||||||
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/1-basic.ts
|
|
||||||
# - npm run e2e "My Document.docx"
|
|
||||||
- npm run ts-node -- ./demo/2-declaritive-styles.ts
|
|
||||||
- npm run ts-node -- ./demo/3-numbering-and-bullet-points.ts
|
|
||||||
- npm run ts-node -- ./demo/4-basic-table.ts
|
|
||||||
- npm run ts-node -- ./demo/5-images.ts
|
|
||||||
- npm run ts-node -- ./demo/6-page-borders.ts
|
|
||||||
- npm run ts-node -- ./demo/7-landscape.ts
|
|
||||||
- npm run ts-node -- ./demo/8-header-footer.ts
|
|
||||||
- npm run ts-node -- ./demo/9-images-in-header-and-footer.ts
|
|
||||||
- npm run ts-node -- ./demo/10-my-cv.ts
|
|
||||||
# - npm run e2e "My Document.docx"
|
|
||||||
- npm run ts-node -- ./demo/11-declaritive-styles-2.ts
|
|
||||||
- npm run ts-node -- ./demo/12-scaling-images.ts
|
|
||||||
- npm run ts-node -- ./demo/13-xml-styles.ts
|
|
||||||
- npm run ts-node -- ./demo/14-page-numbers.ts
|
|
||||||
- npm run ts-node -- ./demo/15-page-break-before.ts
|
|
||||||
- npm run ts-node -- ./demo/16-multiple-sections.ts
|
|
||||||
- npm run ts-node -- ./demo/17-footnotes.ts
|
|
||||||
- npm run ts-node -- ./demo/18-image-from-buffer.ts
|
|
||||||
- npm run ts-node -- ./demo/19-export-to-base64.ts
|
|
||||||
- npm run ts-node -- ./demo/20-table-cell-borders.ts
|
|
||||||
- npm run ts-node -- ./demo/21-bookmarks.ts
|
|
||||||
- npm run ts-node -- ./demo/22-right-to-left-text.ts
|
|
||||||
- npm run ts-node -- ./demo/23-base64-images.ts
|
|
||||||
- npm run ts-node -- ./demo/24-images-to-table-cell.ts
|
|
||||||
# - npm run ts-node -- ./demo/demo25.ts
|
|
||||||
- npm run ts-node -- ./demo/26-paragraph-borders.ts
|
|
||||||
- npm run ts-node -- ./demo/27-declaritive-styles-3.ts
|
|
||||||
- npm run ts-node -- ./demo/28-table-of-contents.ts
|
|
||||||
- npm run ts-node -- ./demo/29-numbered-lists.ts
|
|
||||||
- npm run ts-node -- ./demo/30-template-document.ts
|
|
||||||
- npm run ts-node -- ./demo/31-tables.ts
|
|
||||||
- npm run ts-node -- ./demo/32-merge-and-shade-table-cells.ts
|
|
||||||
# - npm run e2e "My Document.docx" // Need to fix
|
|
||||||
- npm run ts-node -- ./demo/33-sequential-captions.ts
|
|
||||||
- npm run ts-node -- ./demo/34-floating-tables.ts
|
|
||||||
after_failure:
|
|
||||||
- "cat /home/travis/builds/dolanmiu/docx/npm-debug.log"
|
|
||||||
after_success:
|
|
||||||
- npm run typedoc
|
|
||||||
- echo "docx.js.org" > docs/.nojekyll
|
|
||||||
- echo "docx.js.org" > docs/CNAME
|
|
||||||
- codecov
|
|
||||||
deploy:
|
|
||||||
provider: pages
|
|
||||||
skip-cleanup: true
|
|
||||||
github-token: $GITHUB_TOKEN
|
|
||||||
keep-history: true
|
|
||||||
local-dir: docs
|
|
||||||
on:
|
|
||||||
branch: master
|
|
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["streetsidesoftware.code-spell-checker", "dbaeumer.vscode-eslint"]
|
||||||
|
}
|
4
.vscode/launch.json
vendored
Normal file
4
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": []
|
||||||
|
}
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -5,5 +5,6 @@
|
|||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"prettier.tabWidth": 4,
|
"prettier.tabWidth": 4,
|
||||||
"prettier.arrowParens": "always",
|
"prettier.arrowParens": "always",
|
||||||
"prettier.bracketSpacing": true
|
"prettier.bracketSpacing": true,
|
||||||
|
"eslint.useFlatConfig": true
|
||||||
}
|
}
|
||||||
|
20
.vscode/tasks.json
vendored
20
.vscode/tasks.json
vendored
@ -2,23 +2,5 @@
|
|||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
// for the documentation about the tasks.json format
|
// for the documentation about the tasks.json format
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": []
|
||||||
{
|
|
||||||
"type": "typescript",
|
|
||||||
"tsconfig": "tsconfig.json",
|
|
||||||
"option": "watch",
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc-watch"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "npm",
|
|
||||||
"script": "ts-node",
|
|
||||||
"problemMatcher": [],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
57
README.md
57
README.md
@ -1,25 +1,22 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="clippy the assistant" src="https://i.imgur.com/37uBGhO.gif">
|
<img src="./logo/logo-animate.svg" width="100%" height="300" alt="clippy the assistant">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
Easily generate .docx files with JS/TS. Works for Node and on the Browser.
|
Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[![NPM version][npm-image]][npm-url]
|
[![NPM version][npm-image]][npm-url]
|
||||||
[![Downloads per month][downloads-image]][downloads-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]
|
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
|
||||||
[![Dependency Status][daviddm-image]][daviddm-url]
|
|
||||||
[![Known Vulnerabilities][snky-image]][snky-url]
|
[![Known Vulnerabilities][snky-image]][snky-url]
|
||||||
[![Chat on Gitter][gitter-image]][gitter-url]
|
|
||||||
[![PRs Welcome][pr-image]][pr-url]
|
[![PRs Welcome][pr-image]][pr-url]
|
||||||
[![codecov][codecov-image]][codecov-url]
|
[![codecov][codecov-image]][codecov-url]
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://i.imgur.com/TCH0YzD.png" alt="drawing" width="800"/>
|
<img src="https://i.imgur.com/QeL1HuU.png" alt="drawing"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# Demo
|
# Demo
|
||||||
@ -28,21 +25,22 @@
|
|||||||
|
|
||||||
Here are examples of `docx` being used with basic `HTML/JS` in a browser environment:
|
Here are examples of `docx` being used with basic `HTML/JS` in a browser environment:
|
||||||
|
|
||||||
* https://codepen.io/dolanmiu/pen/RwNeObg
|
- https://codepen.io/dolanmiu/pen/RwNeObg
|
||||||
* https://jsfiddle.net/dolanmiu/kqxrj35u/1/
|
- https://jsfiddle.net/dolanmiu/onadx1gu/
|
||||||
|
|
||||||
Here is an example of `docx` working in `Angular`:
|
Here are examples of `docx` working in `Angular`:
|
||||||
|
|
||||||
* https://stackblitz.com/edit/angular-afvxtz
|
- https://stackblitz.com/edit/angular-docx
|
||||||
|
- https://stackblitz.com/edit/angular-wmd6k3
|
||||||
|
|
||||||
Here is an example of `docx` working in `React`:
|
Here are examples of `docx` working in `React`:
|
||||||
|
|
||||||
* https://stackblitz.com/edit/react-ts-qq25sp
|
- https://stackblitz.com/edit/react-docx
|
||||||
* https://stackblitz.com/edit/react-ts-qdqu7z (adding images to Word Document)
|
- https://stackblitz.com/edit/react-docx-images (adding images to Word Document)
|
||||||
|
|
||||||
Here is an example of `docx` working in `Vue.js`:
|
Here is an example of `docx` working in `Vue.js`:
|
||||||
|
|
||||||
* https://stackblitz.com/edit/vuejs-docx
|
- https://stackblitz.com/edit/vuejs-docx
|
||||||
|
|
||||||
## Node
|
## Node
|
||||||
|
|
||||||
@ -50,15 +48,15 @@ Press `endpoint` on the `RunKit` website:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
* https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
|
- https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
|
||||||
* https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
|
- https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
|
||||||
* https://runkit.com/dolanmiu/docx-demo3 - Bullet points
|
- https://runkit.com/dolanmiu/docx-demo3 - Bullet points
|
||||||
* https://runkit.com/dolanmiu/docx-demo4 - Simple table
|
- https://runkit.com/dolanmiu/docx-demo4 - Simple table
|
||||||
* https://runkit.com/dolanmiu/docx-demo5 - Images
|
- https://runkit.com/dolanmiu/docx-demo5 - Images
|
||||||
* https://runkit.com/dolanmiu/docx-demo6 - Margins
|
- https://runkit.com/dolanmiu/docx-demo6 - Margins
|
||||||
* https://runkit.com/dolanmiu/docx-demo7 - Landscape
|
- https://runkit.com/dolanmiu/docx-demo7 - Landscape
|
||||||
* https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
|
- https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
|
||||||
* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
|
- https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
|
||||||
|
|
||||||
More [here](https://github.com/dolanmiu/docx/tree/master/demo)
|
More [here](https://github.com/dolanmiu/docx/tree/master/demo)
|
||||||
|
|
||||||
@ -84,10 +82,13 @@ Read the contribution guidelines [here](https://docx.js.org/#/contribution-guide
|
|||||||
[<img src="https://i.imgur.com/1LjuK2M.png" alt="drawing" height="50"/>](https://turbopatent.com/)
|
[<img src="https://i.imgur.com/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/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/QEZXU5b.png" alt="drawing" height="50"/>](https://www.beekast.com/)
|
||||||
[<img src="https://imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
|
[<img src="https://i.imgur.com/XVU6aoi.png" alt="drawing" height="50"/>](https://herraizsoto.com/)
|
||||||
[<img src="https://i.imgur.com/fn1xccG.png" alt="drawing" height="50"/>](http://www.ativer.com.br/)
|
[<img src="https://i.imgur.com/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/cmykN7c.png" alt="drawing"/>](https://www.arity.co/)
|
||||||
|
[<img src="https://i.imgur.com/PXo25um.png" alt="drawing" height="50"/>](https://www.circadianrisk.com/)
|
||||||
|
[<img src="https://i.imgur.com/AKGhtlh.png" alt="drawing"/>](https://lexense.com/)
|
||||||
|
[<img src="https://i.imgur.com/9tqJaHw.png" alt="drawing" height="50"/>](https://novelpad.co/)
|
||||||
|
[<img src="https://i.imgur.com/5bLKFeP.png" alt="drawing" height="50"/>](https://proton.me/)
|
||||||
|
|
||||||
...and many more!
|
...and many more!
|
||||||
|
|
||||||
@ -102,16 +103,10 @@ Made with 💖
|
|||||||
[npm-url]: https://npmjs.org/package/docx
|
[npm-url]: https://npmjs.org/package/docx
|
||||||
[downloads-image]: https://img.shields.io/npm/dm/docx.svg
|
[downloads-image]: https://img.shields.io/npm/dm/docx.svg
|
||||||
[downloads-url]: https://npmjs.org/package/docx
|
[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-image]: https://github.com/dolanmiu/docx/workflows/Default/badge.svg
|
||||||
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
|
[github-actions-workflow-url]: https://github.com/dolanmiu/docx/actions
|
||||||
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
|
|
||||||
[daviddm-url]: https://david-dm.org/dolanmiu/docx
|
|
||||||
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
|
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
|
||||||
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
|
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
|
||||||
[gitter-image]: https://badges.gitter.im/dolanmiu/docx.svg
|
|
||||||
[gitter-url]: https://gitter.im/docx-lib/Lobby
|
|
||||||
[pr-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
[pr-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
||||||
[pr-url]: http://makeapullrequest.com
|
[pr-url]: http://makeapullrequest.com
|
||||||
[codecov-image]: https://codecov.io/gh/dolanmiu/docx/branch/master/graph/badge.svg
|
[codecov-image]: https://codecov.io/gh/dolanmiu/docx/branch/master/graph/badge.svg
|
||||||
|
24
SECURITY.md
Normal file
24
SECURITY.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Use this section to tell people about which versions of your project are
|
||||||
|
currently being supported with security updates.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 9.0.x | :white_check_mark: |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
We encourage responsible disclosure of security vulnerabilities. If you believe you have found a security vulnerability in this project, please report it via the [Security Tab](https://github.com/dolanmiu/docx/security/advisories)
|
||||||
|
|
||||||
|
Please include the following information in your report:
|
||||||
|
|
||||||
|
* A description of the vulnerability
|
||||||
|
* Steps to reproduce the vulnerability
|
||||||
|
* Impact of the vulnerability
|
||||||
|
|
||||||
|
We will investigate all reported vulnerabilities and take appropriate action.
|
||||||
|
|
||||||
|
We appreciate your help in keeping this project secure.
|
@ -1,26 +1,29 @@
|
|||||||
// Simple example to add text to a document
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
properties: {},
|
properties: {},
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World"),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "Foo Bar",
|
new TextRun("Hello World"),
|
||||||
bold: true,
|
new TextRun({
|
||||||
}),
|
text: "Foo Bar",
|
||||||
new TextRun({
|
bold: true,
|
||||||
text: "\tGithub is the best",
|
size: 40,
|
||||||
bold: true,
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
194
demo/10-my-cv.ts
194
demo/10-my-cv.ts
@ -1,7 +1,7 @@
|
|||||||
// Generate a CV
|
// Generate a CV
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "../build";
|
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, Tab, TabStopPosition, TabStopType, TextRun } from "docx";
|
||||||
|
|
||||||
// tslint:disable:no-shadowed-variable
|
// tslint:disable:no-shadowed-variable
|
||||||
|
|
||||||
@ -9,7 +9,46 @@ const PHONE_NUMBER = "07534563401";
|
|||||||
const PROFILE_URL = "https://www.linkedin.com/in/dolan1";
|
const PROFILE_URL = "https://www.linkedin.com/in/dolan1";
|
||||||
const EMAIL = "docx@com";
|
const EMAIL = "docx@com";
|
||||||
|
|
||||||
const experiences = [
|
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 Achievement {
|
||||||
|
readonly issuer: string;
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const experiences: Experience[] = [
|
||||||
{
|
{
|
||||||
isCurrent: true,
|
isCurrent: true,
|
||||||
summary: "Full-stack developer working with Angular and Java. Working for the iShares platform",
|
summary: "Full-stack developer working with Angular and Java. Working for the iShares platform",
|
||||||
@ -25,7 +64,7 @@ const experiences = [
|
|||||||
{
|
{
|
||||||
isCurrent: false,
|
isCurrent: false,
|
||||||
summary:
|
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.",
|
"Full-stack developer working with Angular, Node and TypeScript. Working for the iShares platform. Emphasis on Dev-ops and developing the continuous integration pipeline.",
|
||||||
title: "Software Developer",
|
title: "Software Developer",
|
||||||
endDate: {
|
endDate: {
|
||||||
month: 11,
|
month: 11,
|
||||||
@ -59,6 +98,7 @@ const experiences = [
|
|||||||
{
|
{
|
||||||
isCurrent: false,
|
isCurrent: false,
|
||||||
summary:
|
summary:
|
||||||
|
// cspell:disable-next-line
|
||||||
"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.",
|
"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",
|
title: "Java Developer",
|
||||||
endDate: {
|
endDate: {
|
||||||
@ -75,12 +115,11 @@ const experiences = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const education = [
|
const education: Education[] = [
|
||||||
{
|
{
|
||||||
degree: "Master of Science (MSc)",
|
degree: "Master of Science (MSc)",
|
||||||
fieldOfStudy: "Computer Science",
|
fieldOfStudy: "Computer Science",
|
||||||
notes:
|
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, Algorithms, 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.",
|
||||||
"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",
|
schoolName: "University College London",
|
||||||
startDate: {
|
startDate: {
|
||||||
year: 2012,
|
year: 2012,
|
||||||
@ -92,8 +131,7 @@ const education = [
|
|||||||
{
|
{
|
||||||
degree: "Bachelor of Engineering (BEng)",
|
degree: "Bachelor of Engineering (BEng)",
|
||||||
fieldOfStudy: "Material Science and Engineering",
|
fieldOfStudy: "Material Science and Engineering",
|
||||||
notes:
|
notes: "Exam Results: 2:1, Dissertation: 1st Class with Distinction\n\nRelevant courses: C Programming, Mathematics and Business for Engineers.",
|
||||||
"Exam Results: 2:1, Dissertation: 1st Class with Distinction\n\nRelevant courses: C Programming, Mathematics and Business for Engineers.",
|
|
||||||
schoolName: "Imperial College London",
|
schoolName: "Imperial College London",
|
||||||
startDate: {
|
startDate: {
|
||||||
year: 2009,
|
year: 2009,
|
||||||
@ -104,7 +142,7 @@ const education = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const skills = [
|
const skills: Skill[] = [
|
||||||
{
|
{
|
||||||
name: "Angular",
|
name: "Angular",
|
||||||
},
|
},
|
||||||
@ -119,7 +157,7 @@ const skills = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const achievements = [
|
const achievements: Achievement[] = [
|
||||||
{
|
{
|
||||||
issuer: "Oracle",
|
issuer: "Oracle",
|
||||||
name: "Oracle Certified Expert",
|
name: "Oracle Certified Expert",
|
||||||
@ -128,71 +166,76 @@ const achievements = [
|
|||||||
|
|
||||||
class DocumentCreator {
|
class DocumentCreator {
|
||||||
// tslint:disable-next-line: typedef
|
// tslint:disable-next-line: typedef
|
||||||
public create([experiences, educations, skills, achivements]): Document {
|
public create([experiences, educations, skills, achievements]: [Experience[], Education[], Skill[], Achievement[]]): Document {
|
||||||
const document = new Document();
|
const document = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Dolan Miu",
|
||||||
|
heading: HeadingLevel.TITLE,
|
||||||
|
}),
|
||||||
|
this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL),
|
||||||
|
this.createHeading("Education"),
|
||||||
|
...educations
|
||||||
|
.map((education) => {
|
||||||
|
const arr: Paragraph[] = [];
|
||||||
|
arr.push(
|
||||||
|
this.createInstitutionHeader(
|
||||||
|
education.schoolName,
|
||||||
|
`${education.startDate.year} - ${education.endDate.year}`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
arr.push(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
|
||||||
|
|
||||||
document.addSection({
|
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
|
||||||
children: [
|
bulletPoints.forEach((bulletPoint) => {
|
||||||
new Paragraph({
|
arr.push(this.createBullet(bulletPoint));
|
||||||
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);
|
return arr;
|
||||||
bulletPoints.forEach((bulletPoint) => {
|
})
|
||||||
arr.push(this.createBullet(bulletPoint));
|
.reduce((prev, curr) => prev.concat(curr), []),
|
||||||
});
|
this.createHeading("Experience"),
|
||||||
|
...experiences
|
||||||
|
.map((position) => {
|
||||||
|
const arr: Paragraph[] = [];
|
||||||
|
|
||||||
return arr;
|
arr.push(
|
||||||
})
|
this.createInstitutionHeader(
|
||||||
.reduce((prev, curr) => prev.concat(curr), []),
|
position.company.name,
|
||||||
this.createHeading("Experience"),
|
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
|
||||||
...experiences
|
),
|
||||||
.map((position) => {
|
);
|
||||||
const arr: Paragraph[] = [];
|
arr.push(this.createRoleText(position.title));
|
||||||
|
|
||||||
arr.push(
|
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
|
||||||
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));
|
||||||
|
});
|
||||||
|
|
||||||
bulletPoints.forEach((bulletPoint) => {
|
return arr;
|
||||||
arr.push(this.createBullet(bulletPoint));
|
})
|
||||||
});
|
.reduce((prev, curr) => prev.concat(curr), []),
|
||||||
|
this.createHeading("Skills, Achievements and Interests"),
|
||||||
return arr;
|
this.createSubHeading("Skills"),
|
||||||
})
|
this.createSkillList(skills),
|
||||||
.reduce((prev, curr) => prev.concat(curr), []),
|
this.createSubHeading("Achievements"),
|
||||||
this.createHeading("Skills, Achievements and Interests"),
|
...this.createAchievementsList(achievements),
|
||||||
this.createSubHeading("Skills"),
|
this.createSubHeading("Interests"),
|
||||||
this.createSkillList(skills),
|
this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."),
|
||||||
this.createSubHeading("Achievements"),
|
this.createHeading("References"),
|
||||||
...this.createAchivementsList(achivements),
|
new Paragraph(
|
||||||
this.createSubHeading("Interests"),
|
"Dr. Dean Mohamedally Director of Postgraduate Studies Department of Computer Science, University College London Malet Place, Bloomsbury, London WC1E d.mohamedally@ucl.ac.uk",
|
||||||
this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."),
|
),
|
||||||
this.createHeading("References"),
|
new Paragraph("More references upon request"),
|
||||||
new Paragraph(
|
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",
|
text: "This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
|
||||||
),
|
alignment: AlignmentType.CENTER,
|
||||||
new Paragraph("More references upon request"),
|
}),
|
||||||
new Paragraph({
|
],
|
||||||
text: "This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
|
},
|
||||||
alignment: AlignmentType.CENTER,
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -204,7 +247,10 @@ class DocumentCreator {
|
|||||||
alignment: AlignmentType.CENTER,
|
alignment: AlignmentType.CENTER,
|
||||||
children: [
|
children: [
|
||||||
new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`),
|
new TextRun(`Mobile: ${phoneNumber} | LinkedIn: ${profileUrl} | Email: ${email}`),
|
||||||
new TextRun("Address: 58 Elm Avenue, Kent ME4 6ER, UK").break(),
|
new TextRun({
|
||||||
|
text: "Address: 58 Elm Avenue, Kent ME4 6ER, UK",
|
||||||
|
break: 1,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -238,7 +284,7 @@ class DocumentCreator {
|
|||||||
bold: true,
|
bold: true,
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: `\t${dateText}`,
|
children: [new Tab(), dateText],
|
||||||
bold: true,
|
bold: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -273,8 +319,8 @@ class DocumentCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
public createAchivementsList(achivements: any[]): Paragraph[] {
|
public createAchievementsList(achievements: any[]): Paragraph[] {
|
||||||
return achivements.map(
|
return achievements.map(
|
||||||
(achievement) =>
|
(achievement) =>
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: achievement.name,
|
text: achievement.name,
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
// Setting styles with JavaScript configuration
|
// Setting styles with JavaScript configuration
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
AlignmentType,
|
AlignmentType,
|
||||||
|
convertInchesToTwip,
|
||||||
Document,
|
Document,
|
||||||
Footer,
|
Footer,
|
||||||
HeadingLevel,
|
HeadingLevel,
|
||||||
Media,
|
ImageRun,
|
||||||
Packer,
|
Packer,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
Table,
|
Table,
|
||||||
@ -14,9 +15,58 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
TabStopPosition,
|
TabStopPosition,
|
||||||
UnderlineType,
|
UnderlineType,
|
||||||
} from "../build";
|
LevelFormat,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
|
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({
|
const doc = new Document({
|
||||||
|
numbering: {
|
||||||
|
config: [
|
||||||
|
{
|
||||||
|
reference: "ref1",
|
||||||
|
levels: [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: LevelFormat.DECIMAL,
|
||||||
|
text: "%1)",
|
||||||
|
start: 50,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
styles: {
|
styles: {
|
||||||
default: {
|
default: {
|
||||||
heading1: {
|
heading1: {
|
||||||
@ -110,7 +160,7 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
paragraph: {
|
paragraph: {
|
||||||
spacing: { line: 276 },
|
spacing: { line: 276 },
|
||||||
indent: { left: 720 },
|
indent: { left: convertInchesToTwip(0.5) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -121,116 +171,143 @@ const doc = new Document({
|
|||||||
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
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: [
|
||||||
|
{
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
properties: {
|
||||||
|
page: {
|
||||||
const table = new Table({
|
margin: {
|
||||||
rows: [
|
top: 700,
|
||||||
new TableRow({
|
right: 700,
|
||||||
children: [
|
bottom: 700,
|
||||||
new TableCell({
|
left: 700,
|
||||||
children: [new Paragraph("Test cell 1.")],
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
footers: {
|
||||||
|
default: new Footer({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "1",
|
||||||
|
style: "normalPara",
|
||||||
|
alignment: AlignmentType.RIGHT,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
},
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph("Test cell 2.")],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph("Test cell 3.")],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph("Test cell 4.")],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
properties: {
|
|
||||||
top: 700,
|
|
||||||
right: 700,
|
|
||||||
bottom: 700,
|
|
||||||
left: 700,
|
|
||||||
},
|
|
||||||
footers: {
|
|
||||||
default: new Footer({
|
|
||||||
children: [
|
children: [
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "1",
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "HEADING",
|
||||||
|
heading: HeadingLevel.HEADING_1,
|
||||||
|
alignment: AlignmentType.CENTER,
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Ref. :",
|
||||||
style: "normalPara",
|
style: "normalPara",
|
||||||
alignment: AlignmentType.RIGHT,
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Date :",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "To,",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "The Superindenting Engineer,(O &M)",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Sub : ",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Ref. : ",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Sir,",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "BRIEF DESCRIPTION",
|
||||||
|
style: "normalPara",
|
||||||
|
}),
|
||||||
|
table,
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Test",
|
||||||
|
style: "normalPara2",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "Test 2",
|
||||||
|
style: "normalPara2",
|
||||||
|
}),
|
||||||
|
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",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph(image),
|
|
||||||
new Paragraph({
|
|
||||||
text: "HEADING",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
alignment: AlignmentType.CENTER,
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Ref. :",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Date :",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "To,",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "The Superindenting Engineer,(O &M)",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Sub : ",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Ref. : ",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Sir,",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "BRIEF DESCRIPTION",
|
|
||||||
style: "normalPara",
|
|
||||||
}),
|
|
||||||
table,
|
|
||||||
new Paragraph(image1),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Test",
|
|
||||||
style: "normalPara2",
|
|
||||||
}),
|
|
||||||
new Paragraph(image2),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Test 2",
|
|
||||||
style: "normalPara2",
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,17 +1,60 @@
|
|||||||
// Scaling images
|
// Scaling images
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Media, Packer, Paragraph } from "../build";
|
import { Document, ImageRun, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 50, 50);
|
{
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 100, 100);
|
children: [
|
||||||
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 250, 250);
|
new Paragraph("Hello World"),
|
||||||
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 400, 400);
|
new Paragraph({
|
||||||
|
children: [
|
||||||
doc.addSection({
|
new ImageRun({
|
||||||
children: [new Paragraph("Hello World"), new Paragraph(image), new Paragraph(image2), new Paragraph(image3), new Paragraph(image4)],
|
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) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,29 +1,30 @@
|
|||||||
// This example shows 3 styles using XML styles
|
// 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 * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
const styles = fs.readFileSync("./demo/assets/custom-styles.xml", "utf-8");
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
title: "Title",
|
title: "Title",
|
||||||
externalStyles: styles,
|
externalStyles: styles,
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
children: [
|
||||||
children: [
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Cool Heading Text",
|
||||||
text: "Cool Heading Text",
|
heading: HeadingLevel.HEADING_1,
|
||||||
heading: HeadingLevel.HEADING_1,
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: 'This is a custom named style from the template "MyFancyStyle"',
|
||||||
text: 'This is a custom named style from the template "MyFancyStyle"',
|
style: "MyFancyStyle",
|
||||||
style: "MyFancyStyle",
|
}),
|
||||||
}),
|
new Paragraph("Some normal text"),
|
||||||
new Paragraph("Some normal text"),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "MyFancyStyle again",
|
||||||
text: "MyFancyStyle again",
|
style: "MyFancyStyle",
|
||||||
style: "MyFancyStyle",
|
}),
|
||||||
}),
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,44 +1,77 @@
|
|||||||
// Page numbers
|
// Page numbers
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "../build";
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
headers: {
|
properties: {
|
||||||
default: new Header({
|
titlePage: true,
|
||||||
children: [
|
},
|
||||||
new Paragraph({
|
headers: {
|
||||||
alignment: AlignmentType.RIGHT,
|
default: new Header({
|
||||||
children: [
|
children: [
|
||||||
new TextRun("My Title "),
|
new Paragraph({
|
||||||
new TextRun({
|
alignment: AlignmentType.RIGHT,
|
||||||
children: ["Page ", PageNumber.CURRENT],
|
children: [
|
||||||
|
new TextRun("My Title "),
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
first: new Header({
|
||||||
}),
|
|
||||||
first: new Header({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
alignment: AlignmentType.RIGHT,
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("First Page Header "),
|
new Paragraph({
|
||||||
new TextRun({
|
alignment: AlignmentType.RIGHT,
|
||||||
children: ["Page ", PageNumber.CURRENT],
|
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, " of ", PageNumber.TOTAL_PAGES],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
first: new Footer({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
alignment: AlignmentType.RIGHT,
|
||||||
|
children: [
|
||||||
|
new TextRun("First Page Footer "),
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("First Page"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
new Paragraph("Second Page"),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("First Page"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph("Second Page"),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
// Page break before example
|
// Page break before example
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "../build";
|
import { Document, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
children: [
|
||||||
new Paragraph("Hello World"),
|
new Paragraph("Hello World"),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Hello World on another page",
|
text: "Hello World on another page",
|
||||||
pageBreakBefore: true,
|
pageBreakBefore: true,
|
||||||
}),
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,121 +1,144 @@
|
|||||||
// Multiple sections and headers
|
// Multiple sections and headers
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Footer, Header, Packer, PageNumber, PageNumberFormat, PageOrientation, Paragraph, TextRun } from "../build";
|
import { Document, Footer, Header, Packer, PageNumber, NumberFormat, PageOrientation, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
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")],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
|
||||||
doc.addSection({
|
children: [new Paragraph("hello")],
|
||||||
children: [new Paragraph("Hello World")],
|
},
|
||||||
});
|
{
|
||||||
|
properties: {
|
||||||
doc.addSection({
|
page: {
|
||||||
headers: {
|
size: {
|
||||||
default: new Header({
|
orientation: PageOrientation.LANDSCAPE,
|
||||||
children: [new Paragraph("First Default Header on another page")],
|
},
|
||||||
}),
|
pageNumbers: {
|
||||||
},
|
start: 1,
|
||||||
footers: {
|
formatType: NumberFormat.DECIMAL,
|
||||||
default: new Footer({
|
},
|
||||||
children: [new Paragraph("Footer on another page")],
|
},
|
||||||
}),
|
},
|
||||||
},
|
headers: {
|
||||||
properties: {
|
default: new Header({
|
||||||
pageNumberStart: 1,
|
children: [new Paragraph("Second Default Header on another page")],
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
}),
|
||||||
},
|
},
|
||||||
children: [new Paragraph("hello")],
|
footers: {
|
||||||
});
|
default: new Footer({
|
||||||
|
children: [new Paragraph("Footer on another page")],
|
||||||
doc.addSection({
|
}),
|
||||||
headers: {
|
},
|
||||||
default: new Header({
|
children: [new Paragraph("hello in landscape")],
|
||||||
children: [new Paragraph("Second Default Header on another page")],
|
},
|
||||||
}),
|
{
|
||||||
},
|
properties: {
|
||||||
footers: {
|
page: {
|
||||||
default: new Footer({
|
size: {
|
||||||
children: [new Paragraph("Footer on another page")],
|
orientation: PageOrientation.PORTRAIT,
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
size: {
|
},
|
||||||
orientation: PageOrientation.LANDSCAPE,
|
headers: {
|
||||||
},
|
default: new Header({
|
||||||
properties: {
|
|
||||||
pageNumberStart: 1,
|
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
|
||||||
},
|
|
||||||
children: [new Paragraph("hello in landscape")],
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
headers: {
|
|
||||||
default: new Header({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: ["Page number: ", PageNumber.CURRENT],
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page number: ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
},
|
||||||
}),
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
orientation: PageOrientation.PORTRAIT,
|
|
||||||
},
|
|
||||||
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
children: [new Paragraph("Page number in the header must be 2, because it continues from the previous section.")],
|
||||||
headers: {
|
},
|
||||||
default: new Header({
|
{
|
||||||
children: [
|
properties: {
|
||||||
new Paragraph({
|
page: {
|
||||||
|
size: {
|
||||||
|
orientation: PageOrientation.PORTRAIT,
|
||||||
|
},
|
||||||
|
pageNumbers: {
|
||||||
|
formatType: NumberFormat.UPPER_ROMAN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
default: new Header({
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: ["Page number: ", PageNumber.CURRENT],
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page number: ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
},
|
||||||
}),
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
pageNumberFormatType: PageNumberFormat.UPPER_ROMAN,
|
|
||||||
orientation: PageOrientation.PORTRAIT,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph(
|
|
||||||
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
headers: {
|
|
||||||
default: new Header({
|
|
||||||
children: [
|
children: [
|
||||||
new Paragraph({
|
new Paragraph(
|
||||||
|
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
page: {
|
||||||
|
size: {
|
||||||
|
orientation: PageOrientation.PORTRAIT,
|
||||||
|
},
|
||||||
|
pageNumbers: {
|
||||||
|
start: 25,
|
||||||
|
formatType: NumberFormat.DECIMAL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
default: new Header({
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: ["Page number: ", PageNumber.CURRENT],
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page number: ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph(
|
||||||
|
"Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section.",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
},
|
|
||||||
size: {
|
|
||||||
orientation: PageOrientation.PORTRAIT,
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
|
||||||
pageNumberStart: 25,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,52 +1,59 @@
|
|||||||
// Footnotes
|
// Footnotes
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "../build";
|
import { Document, FootnoteReferenceRun, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
footnotes: [
|
footnotes: {
|
||||||
new Paragraph("Foo"),
|
1: { children: [new Paragraph("Foo"), new Paragraph("Bar")] },
|
||||||
new Paragraph("Test"),
|
2: { children: [new Paragraph("Test")] },
|
||||||
new Paragraph("My amazing reference"),
|
3: { children: [new Paragraph("My amazing reference")] },
|
||||||
new Paragraph("Foo1"),
|
4: { children: [new Paragraph("Foo1")] },
|
||||||
new Paragraph("Test1"),
|
5: { children: [new Paragraph("Test1")] },
|
||||||
new Paragraph("My amazing reference1"),
|
6: { children: [new Paragraph("My amazing reference1")] },
|
||||||
],
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: ["Hello", new FootnoteReferenceRun(1)],
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Hello"],
|
||||||
|
}),
|
||||||
|
new FootnoteReferenceRun(1),
|
||||||
|
new TextRun({
|
||||||
|
children: [" World!"],
|
||||||
|
}),
|
||||||
|
new FootnoteReferenceRun(2),
|
||||||
|
new TextRun({
|
||||||
|
children: [" GitHub!"],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: [" World!", new FootnoteReferenceRun(2)],
|
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
{
|
||||||
children: [new TextRun("Hello World"), new FootnoteReferenceRun(3)],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: ["Hello", new FootnoteReferenceRun(4)],
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
children: ["Hello"],
|
||||||
|
}),
|
||||||
|
new FootnoteReferenceRun(4),
|
||||||
|
new TextRun({
|
||||||
|
children: [" World!"],
|
||||||
|
}),
|
||||||
|
new FootnoteReferenceRun(5),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
children: [" World!", new FootnoteReferenceRun(5)],
|
children: [new TextRun("Hello World Again"), new FootnoteReferenceRun(6)],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World"), new FootnoteReferenceRun(6)],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
// Insert image from a buffer
|
// Insert image from a buffer
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Media, Packer, Paragraph } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import { Document, ImageRun, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const imageBase64Data = `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`;
|
const imageBase64Data = `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`;
|
||||||
|
|
||||||
const image = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100, 100);
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
children: [
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
children: [image],
|
children: [
|
||||||
}),
|
new ImageRun({
|
||||||
|
data: Buffer.from(imageBase64Data, "base64"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
// Export to base64 string - Useful in a browser environment.
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World"),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "Foo",
|
new TextRun("Hello World"),
|
||||||
bold: true,
|
new TextRun({
|
||||||
}),
|
text: "Foo",
|
||||||
new TextRun({
|
bold: true,
|
||||||
text: "\tBar",
|
}),
|
||||||
bold: true,
|
new TextRun({
|
||||||
|
children: [new Tab(), "Bar"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Example on how to customise the look at feel using Styles
|
// Example on how to customize the look at feel using Styles
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, HeadingLevel, Packer, Paragraph, TextRun, UnderlineType } from "../build";
|
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph, TextRun, UnderlineType } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
creator: "Clippy",
|
creator: "Clippy",
|
||||||
@ -14,7 +14,7 @@ const doc = new Document({
|
|||||||
size: 28,
|
size: 28,
|
||||||
bold: true,
|
bold: true,
|
||||||
italics: true,
|
italics: true,
|
||||||
color: "red",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
paragraph: {
|
paragraph: {
|
||||||
spacing: {
|
spacing: {
|
||||||
@ -40,9 +40,18 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
listParagraph: {
|
listParagraph: {
|
||||||
run: {
|
run: {
|
||||||
color: '#FF0000'
|
color: "#FF0000",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
document: {
|
||||||
|
run: {
|
||||||
|
size: "11pt",
|
||||||
|
font: "Calibri",
|
||||||
|
},
|
||||||
|
paragraph: {
|
||||||
|
alignment: AlignmentType.RIGHT,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
paragraphStyles: [
|
paragraphStyles: [
|
||||||
{
|
{
|
||||||
@ -56,7 +65,7 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: {
|
indent: {
|
||||||
left: 720,
|
left: convertInchesToTwip(0.5),
|
||||||
},
|
},
|
||||||
spacing: {
|
spacing: {
|
||||||
line: 276,
|
line: 276,
|
||||||
@ -72,6 +81,32 @@ const doc = new Document({
|
|||||||
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
spacing: { line: 276, before: 20 * 72 * 0.1, after: 20 * 72 * 0.05 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "strikeUnderline",
|
||||||
|
name: "Strike Underline",
|
||||||
|
basedOn: "Normal",
|
||||||
|
quickFormat: true,
|
||||||
|
run: {
|
||||||
|
strike: true,
|
||||||
|
underline: {
|
||||||
|
type: UnderlineType.SINGLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
characterStyles: [
|
||||||
|
{
|
||||||
|
id: "strikeUnderlineCharacter",
|
||||||
|
name: "Strike Underline",
|
||||||
|
basedOn: "Normal",
|
||||||
|
quickFormat: true,
|
||||||
|
run: {
|
||||||
|
strike: true,
|
||||||
|
underline: {
|
||||||
|
type: UnderlineType.SINGLE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
numbering: {
|
numbering: {
|
||||||
@ -81,7 +116,7 @@ const doc = new Document({
|
|||||||
levels: [
|
levels: [
|
||||||
{
|
{
|
||||||
level: 0,
|
level: 0,
|
||||||
format: "lowerLetter",
|
format: LevelFormat.LOWER_LETTER,
|
||||||
text: "%1)",
|
text: "%1)",
|
||||||
alignment: AlignmentType.LEFT,
|
alignment: AlignmentType.LEFT,
|
||||||
},
|
},
|
||||||
@ -89,78 +124,142 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Test heading1, bold and italicized",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
}),
|
|
||||||
new Paragraph("Some simple content"),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Test heading2 with double red underline",
|
|
||||||
heading: HeadingLevel.HEADING_2,
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Option1",
|
|
||||||
numbering: {
|
|
||||||
reference: "my-crazy-numbering",
|
|
||||||
level: 0,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Option5 -- override 2 to 5",
|
|
||||||
numbering: {
|
|
||||||
reference: "my-crazy-numbering",
|
|
||||||
level: 0,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "Option3",
|
|
||||||
numbering: {
|
|
||||||
reference: "my-crazy-numbering",
|
|
||||||
level: 0,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "Some monospaced content",
|
text: "Test heading1, bold and italicized",
|
||||||
font: {
|
heading: HeadingLevel.HEADING_1,
|
||||||
name: "Monospace",
|
}),
|
||||||
|
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",
|
||||||
new Paragraph({
|
numbering: {
|
||||||
text: "An aside, in light gray italics and indented",
|
reference: "my-crazy-numbering",
|
||||||
style: "aside",
|
level: 0,
|
||||||
}),
|
},
|
||||||
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 Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "and then underlined ",
|
new TextRun({
|
||||||
underline: {},
|
text: "Some monospaced content",
|
||||||
|
font: {
|
||||||
|
name: "Monospace",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "and then emphasis-mark ",
|
text: "An aside, in light gray italics and indented",
|
||||||
emphasisMark: {},
|
style: "aside",
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "and back to normal.",
|
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 TextRun({
|
||||||
|
text: "This text will be invisible!",
|
||||||
|
vanish: true,
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "This text will be VERY invisible! Word processors cannot override this!",
|
||||||
|
specVanish: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
style: "Strong",
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Strong Style",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: " - Very strong.",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
style: "strikeUnderline",
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Underline and Strike",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: " Override Underline ",
|
||||||
|
underline: {
|
||||||
|
type: UnderlineType.NONE,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "Strike and Underline",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Hello World ",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
style: "strikeUnderlineCharacter",
|
||||||
|
text: "Underline and Strike",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: " Another Hello World",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
scale: 50,
|
||||||
|
text: " Scaled text",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
scale: 200,
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Scaled paragraph",
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,103 +1,107 @@
|
|||||||
// Add custom borders to table cell
|
// Add custom borders to table cell
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const table = new Table({
|
{
|
||||||
rows: [
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
children: [
|
||||||
new TableCell({
|
new Table({
|
||||||
children: [],
|
rows: [
|
||||||
}),
|
new TableRow({
|
||||||
new TableCell({
|
children: [
|
||||||
children: [],
|
new TableCell({
|
||||||
}),
|
children: [],
|
||||||
new TableCell({
|
}),
|
||||||
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: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph("Hello")],
|
|
||||||
borders: {
|
|
||||||
top: {
|
|
||||||
style: BorderStyle.DASH_DOT_STROKED,
|
|
||||||
size: 3,
|
|
||||||
color: "red",
|
|
||||||
},
|
|
||||||
bottom: {
|
|
||||||
style: BorderStyle.DOUBLE,
|
|
||||||
size: 3,
|
|
||||||
color: "blue",
|
|
||||||
},
|
|
||||||
left: {
|
|
||||||
style: BorderStyle.DASH_DOT_STROKED,
|
|
||||||
size: 3,
|
|
||||||
color: "green",
|
|
||||||
},
|
|
||||||
right: {
|
|
||||||
style: BorderStyle.DASH_DOT_STROKED,
|
|
||||||
size: 3,
|
|
||||||
color: "#ff8000",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({ children: [table] });
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
});
|
});
|
||||||
|
@ -1,37 +1,75 @@
|
|||||||
// This demo shows how to create bookmarks then link to them with internal hyperlinks
|
// 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 * as fs from "fs";
|
||||||
import { Bookmark, Document, HeadingLevel, HyperlinkRef, HyperlinkType, Packer, PageBreak, Paragraph } from "../build";
|
import { Bookmark, Document, Footer, HeadingLevel, InternalHyperlink, Packer, PageBreak, Paragraph, TextRun, PageReference } from "docx";
|
||||||
|
|
||||||
const LOREM_IPSUM =
|
const LOREM_IPSUM =
|
||||||
|
/* cspell:disable-next-line */
|
||||||
"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.";
|
"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({
|
const doc = new Document({
|
||||||
creator: "Clippy",
|
creator: "Clippy",
|
||||||
title: "Sample Document",
|
title: "Sample Document",
|
||||||
description: "A brief example of using docx with bookmarks and internal hyperlinks",
|
description: "A brief example of using docx with bookmarks and internal hyperlinks",
|
||||||
hyperlinks: {
|
sections: [
|
||||||
myAnchorId: {
|
{
|
||||||
text: "Hyperlink",
|
footers: {
|
||||||
type: HyperlinkType.INTERNAL,
|
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")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
children: [new Bookmark("myAnchorId", "Lorem Ipsum")],
|
|
||||||
}),
|
|
||||||
new Paragraph("\n"),
|
|
||||||
new Paragraph(LOREM_IPSUM),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new HyperlinkRef("myAnchorId")],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,41 +1,68 @@
|
|||||||
// This demo shows right to left for special languages
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
bidirectional: true,
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "שלום עולם",
|
bidirectional: true,
|
||||||
rightToLeft: true,
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "שלום עולם",
|
||||||
|
rightToLeft: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
bidirectional: true,
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "שלום עולם",
|
||||||
|
bold: true,
|
||||||
|
rightToLeft: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
bidirectional: true,
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "שלום עולם",
|
||||||
|
italics: true,
|
||||||
|
rightToLeft: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Table({
|
||||||
|
visuallyRightToLeft: true,
|
||||||
|
rows: [
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph("שלום עולם")],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph("שלום עולם")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
|
||||||
bidirectional: true,
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "שלום עולם",
|
|
||||||
bold: true,
|
|
||||||
rightToLeft: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
bidirectional: true,
|
|
||||||
children: [
|
|
||||||
new TextRun({
|
|
||||||
text: "שלום עולם",
|
|
||||||
italics: true,
|
|
||||||
rightToLeft: true,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,29 +1,83 @@
|
|||||||
// This demo adds an image to the Media cache, and then insert to the document afterwards
|
// 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 * as fs from "fs";
|
||||||
import { Document, Media, Packer, Paragraph, TextRun } from "../build";
|
import { Document, ImageRun, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
|
||||||
|
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png"));
|
|
||||||
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"));
|
|
||||||
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/parrots.bmp"));
|
|
||||||
const image5 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
|
||||||
|
|
||||||
const imageBase64Data = `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`;
|
const imageBase64Data = `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`;
|
||||||
const image6 = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100, 100);
|
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [
|
sections: [
|
||||||
new Paragraph({
|
{
|
||||||
children: [new TextRun("Hello World"), image5],
|
children: [
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph(image),
|
children: [
|
||||||
new Paragraph(image2),
|
new TextRun("Hello World"),
|
||||||
new Paragraph(image3),
|
new ImageRun({
|
||||||
new Paragraph(image4),
|
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||||
new Paragraph(image6),
|
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,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,85 +1,97 @@
|
|||||||
// Add image to table cell
|
// Add image to table cell
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Media, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
{
|
||||||
|
|
||||||
const table = new Table({
|
|
||||||
rows: [
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
children: [
|
||||||
new TableCell({
|
new Table({
|
||||||
children: [],
|
rows: [
|
||||||
}),
|
new TableRow({
|
||||||
new TableCell({
|
children: [
|
||||||
children: [],
|
new TableCell({
|
||||||
}),
|
children: [],
|
||||||
new TableCell({
|
}),
|
||||||
children: [],
|
new TableCell({
|
||||||
}),
|
children: [],
|
||||||
new TableCell({
|
}),
|
||||||
children: [],
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph("Hello")],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph(image)],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [new Paragraph("Hello")],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [table],
|
|
||||||
});
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
fs.writeFileSync("My Document.docx", 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 * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,30 +1,62 @@
|
|||||||
// Creates two paragraphs, one with a border and one without
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "../build";
|
import { BorderStyle, Document, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
children: [
|
||||||
new Paragraph("No border!"),
|
new Paragraph("No border!"),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "I have borders on my top and bottom sides!",
|
text: "I have borders on my top and bottom sides!",
|
||||||
border: {
|
border: {
|
||||||
top: {
|
top: {
|
||||||
color: "auto",
|
color: "auto",
|
||||||
space: 1,
|
space: 1,
|
||||||
value: "single",
|
style: BorderStyle.SINGLE,
|
||||||
size: 6,
|
size: 6,
|
||||||
},
|
},
|
||||||
bottom: {
|
bottom: {
|
||||||
color: "auto",
|
color: "auto",
|
||||||
space: 1,
|
space: 1,
|
||||||
value: "single",
|
style: BorderStyle.SINGLE,
|
||||||
size: 6,
|
size: 6,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "",
|
||||||
|
border: {
|
||||||
|
top: {
|
||||||
|
color: "auto",
|
||||||
|
space: 1,
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
size: 6,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "This will ",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "have a border.",
|
||||||
|
border: {
|
||||||
|
color: "auto",
|
||||||
|
space: 1,
|
||||||
|
style: BorderStyle.SINGLE,
|
||||||
|
size: 6,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: " This will not.",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Custom styles using JavaScript configuration
|
// Custom styles using JavaScript configuration
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, UnderlineType } from "../build";
|
import { Document, convertInchesToTwip, HeadingLevel, Packer, Paragraph, UnderlineType } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
@ -17,7 +17,7 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: {
|
indent: {
|
||||||
left: 720,
|
left: convertInchesToTwip(0.5),
|
||||||
},
|
},
|
||||||
spacing: {
|
spacing: {
|
||||||
line: 276,
|
line: 276,
|
||||||
@ -47,18 +47,19 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
children: [
|
||||||
children: [
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Hello",
|
||||||
text: "Hello",
|
style: "myWonkyStyle",
|
||||||
style: "myWonkyStyle",
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "World",
|
||||||
text: "World",
|
heading: HeadingLevel.HEADING_2,
|
||||||
heading: HeadingLevel.HEADING_2,
|
}),
|
||||||
}),
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
// Table of contents
|
// 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";
|
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { File, HeadingLevel, Packer, Paragraph, StyleLevel, TableOfContents } from "docx";
|
||||||
|
|
||||||
|
// 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({
|
const doc = new File({
|
||||||
|
features: {
|
||||||
|
updateFields: true,
|
||||||
|
},
|
||||||
styles: {
|
styles: {
|
||||||
paragraphStyles: [
|
paragraphStyles: [
|
||||||
{
|
{
|
||||||
@ -19,43 +27,38 @@ const doc = new File({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
// WordprocessingML docs for TableOfContents can be found here:
|
children: [
|
||||||
// http://officeopenxml.com/WPtableOfContents.php
|
new TableOfContents("Summary", {
|
||||||
|
hyperlink: true,
|
||||||
// Let's define the properties for generate a TOC for heading 1-5 and MySpectacularStyle,
|
headingStyleRange: "1-5",
|
||||||
// making the entries be hyperlinks for the paragraph
|
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
|
||||||
|
}),
|
||||||
doc.addSection({
|
new Paragraph({
|
||||||
children: [
|
text: "Header #1",
|
||||||
new TableOfContents("Summary", {
|
heading: HeadingLevel.HEADING_1,
|
||||||
hyperlink: true,
|
pageBreakBefore: true,
|
||||||
headingStyleRange: "1-5",
|
}),
|
||||||
stylesWithLevels: [new StyleLevel("MySpectacularStyle", 1)],
|
new Paragraph("I'm a little text very nicely written.'"),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Header #2",
|
||||||
text: "Header #1",
|
heading: HeadingLevel.HEADING_1,
|
||||||
heading: HeadingLevel.HEADING_1,
|
pageBreakBefore: true,
|
||||||
pageBreakBefore: true,
|
}),
|
||||||
}),
|
new Paragraph("I'm a other text very nicely written.'"),
|
||||||
new Paragraph("I'm a little text very nicely written.'"),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Header #2.1",
|
||||||
text: "Header #2",
|
heading: HeadingLevel.HEADING_2,
|
||||||
heading: HeadingLevel.HEADING_1,
|
}),
|
||||||
pageBreakBefore: true,
|
new Paragraph("I'm a another text very nicely written.'"),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph("I'm a other text very nicely written.'"),
|
text: "My Spectacular Style #1",
|
||||||
new Paragraph({
|
style: "MySpectacularStyle",
|
||||||
text: "Header #2.1",
|
pageBreakBefore: true,
|
||||||
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,
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Numbered lists
|
// Numbered lists
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
// The lists can also be restarted by specifying the instance number
|
||||||
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Packer, Paragraph } from "../build";
|
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
@ -10,12 +11,12 @@ const doc = new Document({
|
|||||||
levels: [
|
levels: [
|
||||||
{
|
{
|
||||||
level: 0,
|
level: 0,
|
||||||
format: "upperRoman",
|
format: LevelFormat.UPPER_ROMAN,
|
||||||
text: "%1",
|
text: "%1",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 720, hanging: 260 },
|
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -26,89 +27,256 @@ const doc = new Document({
|
|||||||
levels: [
|
levels: [
|
||||||
{
|
{
|
||||||
level: 0,
|
level: 0,
|
||||||
format: "decimal",
|
format: LevelFormat.DECIMAL,
|
||||||
text: "%1",
|
text: "%1",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 720, hanging: 260 },
|
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
reference: "my-number-numbering-reference",
|
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: [
|
||||||
|
{
|
||||||
doc.addSection({
|
children: [
|
||||||
children: [
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "line with contextual spacing",
|
||||||
text: "line with contextual spacing",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-crazy-reference",
|
||||||
reference: "my-crazy-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
contextualSpacing: true,
|
||||||
contextualSpacing: true,
|
spacing: {
|
||||||
spacing: {
|
before: 200,
|
||||||
before: 200,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "line with contextual spacing",
|
||||||
text: "line with contextual spacing",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-crazy-reference",
|
||||||
reference: "my-crazy-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
contextualSpacing: true,
|
||||||
contextualSpacing: true,
|
spacing: {
|
||||||
spacing: {
|
before: 200,
|
||||||
before: 200,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "line without contextual spacing",
|
||||||
text: "line without contextual spacing",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-crazy-reference",
|
||||||
reference: "my-crazy-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
contextualSpacing: false,
|
||||||
contextualSpacing: false,
|
spacing: {
|
||||||
spacing: {
|
before: 200,
|
||||||
before: 200,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "line without contextual spacing",
|
||||||
text: "line without contextual spacing",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-crazy-reference",
|
||||||
reference: "my-crazy-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
contextualSpacing: false,
|
||||||
contextualSpacing: false,
|
spacing: {
|
||||||
spacing: {
|
before: 200,
|
||||||
before: 200,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Step 1 - Add sugar",
|
||||||
text: "Step 1 - Add sugar",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-number-numbering-reference",
|
||||||
reference: "my-number-numbering-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Step 2 - Add wheat",
|
||||||
text: "Step 2 - Add wheat",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-number-numbering-reference",
|
||||||
reference: "my-number-numbering-reference",
|
level: 0,
|
||||||
level: 0,
|
},
|
||||||
},
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "Step 3 - Put in oven",
|
||||||
text: "Step 3 - Put in oven",
|
numbering: {
|
||||||
numbering: {
|
reference: "my-number-numbering-reference",
|
||||||
reference: "my-number-numbering-reference",
|
level: 0,
|
||||||
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,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Numbering and bullet points example
|
// Numbering and bullet points example
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Packer, Paragraph } from "../build";
|
import { AlignmentType, convertInchesToTwip, Document, Footer, Header, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
numbering: {
|
numbering: {
|
||||||
@ -11,40 +11,40 @@ const doc = new Document({
|
|||||||
levels: [
|
levels: [
|
||||||
{
|
{
|
||||||
level: 0,
|
level: 0,
|
||||||
format: "upperRoman",
|
format: LevelFormat.UPPER_ROMAN,
|
||||||
text: "%1",
|
text: "%1",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 720, hanging: 260 },
|
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.18) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
level: 1,
|
level: 1,
|
||||||
format: "decimal",
|
format: LevelFormat.DECIMAL,
|
||||||
text: "%2.",
|
text: "%2.",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 1440, hanging: 980 },
|
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.68) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
level: 2,
|
level: 2,
|
||||||
format: "lowerLetter",
|
format: LevelFormat.LOWER_LETTER,
|
||||||
text: "%3)",
|
text: "%3)",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
paragraph: {
|
paragraph: {
|
||||||
indent: { left: 2160, hanging: 1700 },
|
indent: { left: convertInchesToTwip(1.5), hanging: convertInchesToTwip(1.18) },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
level: 3,
|
level: 3,
|
||||||
format: "upperLetter",
|
format: LevelFormat.UPPER_LETTER,
|
||||||
text: "%4)",
|
text: "%4)",
|
||||||
alignment: AlignmentType.START,
|
alignment: AlignmentType.START,
|
||||||
style: {
|
style: {
|
||||||
@ -55,85 +55,239 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
reference: "my-unique-bullet-points",
|
||||||
|
levels: [
|
||||||
|
{
|
||||||
|
level: 0,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u1F60",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level: 1,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u00A5",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level: 2,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u273F",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: 2160, hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level: 3,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u267A",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: 2880, hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level: 4,
|
||||||
|
format: LevelFormat.BULLET,
|
||||||
|
text: "\u2603",
|
||||||
|
alignment: AlignmentType.LEFT,
|
||||||
|
style: {
|
||||||
|
paragraph: {
|
||||||
|
indent: { left: 3600, hanging: convertInchesToTwip(0.25) },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
headers: {
|
||||||
children: [
|
default: new Header({
|
||||||
new Paragraph({
|
children: [
|
||||||
text: "Hey you",
|
new Paragraph({
|
||||||
numbering: {
|
text: "Hey you",
|
||||||
reference: "my-crazy-numbering",
|
numbering: {
|
||||||
level: 0,
|
reference: "my-crazy-numbering",
|
||||||
|
level: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "What's up fam",
|
||||||
|
numbering: {
|
||||||
|
reference: "my-crazy-numbering",
|
||||||
|
level: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}),
|
footers: {
|
||||||
new Paragraph({
|
default: new Footer({
|
||||||
text: "What's up fam",
|
children: [
|
||||||
numbering: {
|
new Paragraph({
|
||||||
reference: "my-crazy-numbering",
|
text: "Hey you",
|
||||||
level: 1,
|
numbering: {
|
||||||
|
reference: "my-crazy-numbering",
|
||||||
|
level: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
text: "What's up fam",
|
||||||
|
numbering: {
|
||||||
|
reference: "my-crazy-numbering",
|
||||||
|
level: 1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}),
|
children: [
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Hello World 2",
|
text: "Hey you",
|
||||||
numbering: {
|
numbering: {
|
||||||
reference: "my-crazy-numbering",
|
reference: "my-crazy-numbering",
|
||||||
level: 1,
|
level: 0,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Yeah boi",
|
text: "What's up fam",
|
||||||
numbering: {
|
numbering: {
|
||||||
reference: "my-crazy-numbering",
|
reference: "my-crazy-numbering",
|
||||||
level: 2,
|
level: 1,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "Hey you",
|
text: "Hello World 2",
|
||||||
bullet: {
|
numbering: {
|
||||||
level: 0,
|
reference: "my-crazy-numbering",
|
||||||
},
|
level: 1,
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
}),
|
||||||
text: "What's up fam",
|
new Paragraph({
|
||||||
bullet: {
|
text: "Yeah boi",
|
||||||
level: 1,
|
numbering: {
|
||||||
},
|
reference: "my-crazy-numbering",
|
||||||
}),
|
level: 2,
|
||||||
new Paragraph({
|
},
|
||||||
text: "Hello World 2",
|
}),
|
||||||
bullet: {
|
new Paragraph({
|
||||||
level: 2,
|
text: "Hey you",
|
||||||
},
|
bullet: {
|
||||||
}),
|
level: 0,
|
||||||
new Paragraph({
|
},
|
||||||
text: "Yeah boi",
|
}),
|
||||||
bullet: {
|
new Paragraph({
|
||||||
level: 3,
|
text: "What's up fam",
|
||||||
},
|
bullet: {
|
||||||
}),
|
level: 1,
|
||||||
new Paragraph({
|
},
|
||||||
text: "101 MSXFM",
|
}),
|
||||||
numbering: {
|
new Paragraph({
|
||||||
reference: "my-crazy-numbering",
|
text: "Hello World 2",
|
||||||
level: 3,
|
bullet: {
|
||||||
},
|
level: 2,
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
}),
|
||||||
text: "back to level 1",
|
new Paragraph({
|
||||||
numbering: {
|
text: "Yeah boi",
|
||||||
reference: "my-crazy-numbering",
|
bullet: {
|
||||||
level: 1,
|
level: 3,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
text: "back to level 0",
|
text: "101 MSXFM",
|
||||||
numbering: {
|
numbering: {
|
||||||
reference: "my-crazy-numbering",
|
reference: "my-crazy-numbering",
|
||||||
level: 0,
|
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,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
// Example on how to use a template document
|
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, ImportDotx, Packer, Paragraph } from "../build";
|
|
||||||
|
|
||||||
const importDotx = new ImportDotx();
|
|
||||||
const filePath = "./demo/dotx/template.dotx";
|
|
||||||
|
|
||||||
fs.readFile(filePath, (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
throw new Error(`Failed to read file ${filePath}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
importDotx.extract(data).then((templateDocument) => {
|
|
||||||
const doc = new Document(undefined, {
|
|
||||||
template: templateDocument,
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
properties: {
|
|
||||||
titlePage: templateDocument.titlePageIsDefined,
|
|
||||||
},
|
|
||||||
children: [new Paragraph("Hello World")],
|
|
||||||
});
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,76 +1,77 @@
|
|||||||
// Example of how you would create a table and add data to it
|
// 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 * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign, TextDirection } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const table = new Table({
|
{
|
||||||
rows: [
|
|
||||||
new TableRow({
|
|
||||||
children: [
|
children: [
|
||||||
new TableCell({
|
new Table({
|
||||||
children: [new Paragraph({}), new Paragraph({})],
|
rows: [
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
new TableRow({
|
||||||
}),
|
children: [
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph({}), new Paragraph({})],
|
children: [new Paragraph({}), new Paragraph({})],
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
|
children: [new Paragraph({}), new Paragraph({})],
|
||||||
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
|
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
|
||||||
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
|
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
|
||||||
|
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
|
||||||
|
heading: HeadingLevel.HEADING_1,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "This text should be in the middle of the cell",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Text above should be vertical from bottom to top",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Text above should be vertical from top to bottom",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new TableRow({
|
|
||||||
children: [
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text:
|
|
||||||
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "This text should be in the middle of the cell",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Text above should be vertical from bottom to top",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
new TableCell({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "Text above should be vertical from top to bottom",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [table],
|
|
||||||
});
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
// Example of how you would merge cells together (Rows and Columns) and apply shading
|
// Example of how you would merge cells together (Rows and Columns) and apply shading
|
||||||
// Also includes an example on how to center tables
|
// Also includes an example on how to center tables
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { AlignmentType, BorderStyle, Document, HeadingLevel, Packer, Paragraph, ShadingType, Table, TableCell, TableRow, WidthType } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
AlignmentType,
|
||||||
|
BorderStyle,
|
||||||
|
convertInchesToTwip,
|
||||||
|
Document,
|
||||||
|
HeadingLevel,
|
||||||
|
Packer,
|
||||||
|
Paragraph,
|
||||||
|
ShadingType,
|
||||||
|
Table,
|
||||||
|
TableCell,
|
||||||
|
TableRow,
|
||||||
|
WidthType,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
@ -37,10 +48,10 @@ const table2 = new Table({
|
|||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph("World")],
|
children: [new Paragraph("World")],
|
||||||
margins: {
|
margins: {
|
||||||
top: 1000,
|
top: convertInchesToTwip(0.69),
|
||||||
bottom: 1000,
|
bottom: convertInchesToTwip(0.69),
|
||||||
left: 1000,
|
left: convertInchesToTwip(0.69),
|
||||||
right: 1000,
|
right: convertInchesToTwip(0.69),
|
||||||
},
|
},
|
||||||
columnSpan: 3,
|
columnSpan: 3,
|
||||||
}),
|
}),
|
||||||
@ -64,7 +75,7 @@ const table2 = new Table({
|
|||||||
size: 100,
|
size: 100,
|
||||||
type: WidthType.AUTO,
|
type: WidthType.AUTO,
|
||||||
},
|
},
|
||||||
columnWidths: [1000, 1000, 1000],
|
columnWidths: [convertInchesToTwip(0.69), convertInchesToTwip(0.69), convertInchesToTwip(0.69)],
|
||||||
});
|
});
|
||||||
|
|
||||||
const table3 = new Table({
|
const table3 = new Table({
|
||||||
@ -87,7 +98,7 @@ const table3 = new Table({
|
|||||||
children: [new Paragraph("Bar1")],
|
children: [new Paragraph("Bar1")],
|
||||||
shading: {
|
shading: {
|
||||||
fill: "b79c2f",
|
fill: "b79c2f",
|
||||||
val: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
color: "auto",
|
color: "auto",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -95,7 +106,7 @@ const table3 = new Table({
|
|||||||
children: [new Paragraph("Bar2")],
|
children: [new Paragraph("Bar2")],
|
||||||
shading: {
|
shading: {
|
||||||
fill: "42c5f4",
|
fill: "42c5f4",
|
||||||
val: ShadingType.PERCENT_95,
|
type: ShadingType.PERCENT_95,
|
||||||
color: "auto",
|
color: "auto",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -103,7 +114,7 @@ const table3 = new Table({
|
|||||||
children: [new Paragraph("Bar3")],
|
children: [new Paragraph("Bar3")],
|
||||||
shading: {
|
shading: {
|
||||||
fill: "880aa8",
|
fill: "880aa8",
|
||||||
val: ShadingType.PERCENT_10,
|
type: ShadingType.PERCENT_10,
|
||||||
color: "e2df0b",
|
color: "e2df0b",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -111,7 +122,7 @@ const table3 = new Table({
|
|||||||
children: [new Paragraph("Bar4")],
|
children: [new Paragraph("Bar4")],
|
||||||
shading: {
|
shading: {
|
||||||
fill: "FF0000",
|
fill: "FF0000",
|
||||||
val: ShadingType.CLEAR,
|
type: ShadingType.CLEAR,
|
||||||
color: "auto",
|
color: "auto",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@ -119,14 +130,14 @@ const table3 = new Table({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
width: {
|
width: {
|
||||||
size: 7000,
|
size: convertInchesToTwip(4.86),
|
||||||
type: WidthType.DXA,
|
type: WidthType.DXA,
|
||||||
},
|
},
|
||||||
margins: {
|
margins: {
|
||||||
top: 400,
|
top: convertInchesToTwip(0.27),
|
||||||
bottom: 400,
|
bottom: convertInchesToTwip(0.27),
|
||||||
right: 400,
|
right: convertInchesToTwip(0.27),
|
||||||
left: 400,
|
left: convertInchesToTwip(0.27),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -213,22 +224,22 @@ const borders = {
|
|||||||
top: {
|
top: {
|
||||||
style: BorderStyle.DASH_SMALL_GAP,
|
style: BorderStyle.DASH_SMALL_GAP,
|
||||||
size: 1,
|
size: 1,
|
||||||
color: "red",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
bottom: {
|
bottom: {
|
||||||
style: BorderStyle.DASH_SMALL_GAP,
|
style: BorderStyle.DASH_SMALL_GAP,
|
||||||
size: 1,
|
size: 1,
|
||||||
color: "red",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
left: {
|
left: {
|
||||||
style: BorderStyle.DASH_SMALL_GAP,
|
style: BorderStyle.DASH_SMALL_GAP,
|
||||||
size: 1,
|
size: 1,
|
||||||
color: "red",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
right: {
|
right: {
|
||||||
style: BorderStyle.DASH_SMALL_GAP,
|
style: BorderStyle.DASH_SMALL_GAP,
|
||||||
size: 1,
|
size: 1,
|
||||||
color: "red",
|
color: "FF0000",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -355,9 +366,7 @@ const table8 = new Table({
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new TableRow({
|
new TableRow({
|
||||||
children: [
|
children: [new TableCell({ children: [new Paragraph("4,1")] })],
|
||||||
new TableCell({ children: [new Paragraph("4,1")] }),
|
|
||||||
],
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
width: {
|
width: {
|
||||||
@ -365,30 +374,33 @@ const table8 = new Table({
|
|||||||
type: WidthType.PERCENTAGE,
|
type: WidthType.PERCENTAGE,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const doc = new Document({
|
||||||
doc.addSection({
|
sections: [
|
||||||
children: [
|
{
|
||||||
table,
|
children: [
|
||||||
new Paragraph({
|
table,
|
||||||
text: "Another table",
|
new Paragraph({
|
||||||
heading: HeadingLevel.HEADING_2,
|
text: "Another table",
|
||||||
}),
|
heading: HeadingLevel.HEADING_2,
|
||||||
table2,
|
}),
|
||||||
new Paragraph({
|
table2,
|
||||||
text: "Another table",
|
new Paragraph({
|
||||||
heading: HeadingLevel.HEADING_2,
|
text: "Another table",
|
||||||
}),
|
heading: HeadingLevel.HEADING_2,
|
||||||
table3,
|
}),
|
||||||
new Paragraph("Merging columns 1"),
|
table3,
|
||||||
table4,
|
new Paragraph("Merging columns 1"),
|
||||||
new Paragraph("Merging columns 2"),
|
table4,
|
||||||
table5,
|
new Paragraph("Merging columns 2"),
|
||||||
new Paragraph("Merging columns 3"),
|
table5,
|
||||||
table6,
|
new Paragraph("Merging columns 3"),
|
||||||
new Paragraph("Merging columns 4"),
|
table6,
|
||||||
table7,
|
new Paragraph("Merging columns 4"),
|
||||||
new Paragraph("Merging columns 5"),
|
table7,
|
||||||
table8,
|
new Paragraph("Merging columns 5"),
|
||||||
|
table8,
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,44 +1,46 @@
|
|||||||
// Sequential Captions
|
// Sequential Captions
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "../build";
|
import { Document, Packer, Paragraph, SequentialIdentifier, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World 1->"),
|
new Paragraph({
|
||||||
new SequentialIdentifier("Caption"),
|
children: [
|
||||||
new TextRun(" text after sequencial caption 2->"),
|
new TextRun("Hello World 1->"),
|
||||||
new SequentialIdentifier("Caption"),
|
new SequentialIdentifier("Caption"),
|
||||||
|
new TextRun(" text after sequencial caption 2->"),
|
||||||
|
new SequentialIdentifier("Caption"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World 1->"),
|
||||||
|
new SequentialIdentifier("Label"),
|
||||||
|
new TextRun(" text after sequencial caption 2->"),
|
||||||
|
new SequentialIdentifier("Label"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World 1->"),
|
||||||
|
new SequentialIdentifier("Another"),
|
||||||
|
new TextRun(" text after sequencial caption 3->"),
|
||||||
|
new SequentialIdentifier("Label"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World 2->"),
|
||||||
|
new SequentialIdentifier("Another"),
|
||||||
|
new TextRun(" text after sequencial caption 4->"),
|
||||||
|
new SequentialIdentifier("Label"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("Hello World 1->"),
|
|
||||||
new SequentialIdentifier("Label"),
|
|
||||||
new TextRun(" text after sequencial caption 2->"),
|
|
||||||
new SequentialIdentifier("Label"),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("Hello World 1->"),
|
|
||||||
new SequentialIdentifier("Another"),
|
|
||||||
new TextRun(" text after sequencial caption 3->"),
|
|
||||||
new SequentialIdentifier("Label"),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("Hello World 2->"),
|
|
||||||
new SequentialIdentifier("Another"),
|
|
||||||
new TextRun(" text after sequencial caption 4->"),
|
|
||||||
new SequentialIdentifier("Label"),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Example of how you would create a table with float positions
|
// 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 * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -14,9 +14,7 @@ import {
|
|||||||
TableLayoutType,
|
TableLayoutType,
|
||||||
TableRow,
|
TableRow,
|
||||||
WidthType,
|
WidthType,
|
||||||
} from "../build";
|
} from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
@ -45,6 +43,10 @@ const table = new Table({
|
|||||||
relativeHorizontalPosition: RelativeHorizontalPosition.RIGHT,
|
relativeHorizontalPosition: RelativeHorizontalPosition.RIGHT,
|
||||||
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
|
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
|
||||||
overlap: OverlapType.NEVER,
|
overlap: OverlapType.NEVER,
|
||||||
|
leftFromText: 1000,
|
||||||
|
rightFromText: 2000,
|
||||||
|
topFromText: 1500,
|
||||||
|
bottomFromText: 30,
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
size: 4535,
|
size: 4535,
|
||||||
@ -53,8 +55,12 @@ const table = new Table({
|
|||||||
layout: TableLayoutType.FIXED,
|
layout: TableLayoutType.FIXED,
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [table],
|
sections: [
|
||||||
|
{
|
||||||
|
children: [table],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,33 +1,160 @@
|
|||||||
// Example on how to add hyperlinks to websites
|
// 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 * as fs from "fs";
|
||||||
import { Document, HyperlinkRef, HyperlinkType, Packer, Paragraph, Media } from "../build";
|
import { Document, ExternalHyperlink, Footer, FootnoteReferenceRun, ImageRun, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
hyperlinks: {
|
styles: {
|
||||||
myCoolLink: {
|
default: {
|
||||||
link: "http://www.example.com",
|
hyperlink: {
|
||||||
text: "Hyperlink",
|
run: {
|
||||||
type: HyperlinkType.EXTERNAL,
|
color: "FF0000",
|
||||||
},
|
underline: {
|
||||||
myOtherLink: {
|
color: "0000FF",
|
||||||
link: "http://www.google.com",
|
},
|
||||||
text: "Google Link",
|
},
|
||||||
type: HyperlinkType.EXTERNAL,
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
footnotes: {
|
||||||
|
1: {
|
||||||
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
children: [
|
||||||
|
new Paragraph({
|
||||||
doc.addSection({
|
children: [
|
||||||
children: [
|
new TextRun("Click here for the "),
|
||||||
new Paragraph({
|
new ExternalHyperlink({
|
||||||
children: [new HyperlinkRef("myCoolLink")],
|
children: [
|
||||||
}),
|
new TextRun({
|
||||||
new Paragraph({
|
text: "Footnotes external hyperlink",
|
||||||
children: [image1, new HyperlinkRef("myOtherLink")],
|
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",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
// Add image to table cell in a header and body
|
// Add image to table cell in a header and body
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Header, Media, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
import { Document, Header, ImageRun, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
@ -30,7 +27,19 @@ const table = new Table({
|
|||||||
children: [],
|
children: [],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph(image)],
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -58,13 +67,17 @@ const table = new Table({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Adding same table in the body and in the header
|
// Adding same table in the body and in the header
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
headers: {
|
sections: [
|
||||||
default: new Header({
|
{
|
||||||
|
headers: {
|
||||||
|
default: new Header({
|
||||||
|
children: [table],
|
||||||
|
}),
|
||||||
|
},
|
||||||
children: [table],
|
children: [table],
|
||||||
}),
|
},
|
||||||
},
|
],
|
||||||
children: [table],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,20 +1,53 @@
|
|||||||
// Add images to header and footer
|
// Add images to header and footer
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Header, Media, Packer, Paragraph } from "../build";
|
import { Document, Header, ImageRun, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
sections: [
|
||||||
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
{
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
headers: {
|
||||||
|
default: new Header({
|
||||||
doc.addSection({
|
children: [
|
||||||
headers: {
|
new Paragraph({
|
||||||
default: new Header({
|
children: [
|
||||||
children: [new Paragraph(image), new Paragraph(image1), new Paragraph(image2)],
|
new ImageRun({
|
||||||
}),
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
},
|
transformation: {
|
||||||
children: [new Paragraph("Hello World")],
|
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) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,42 +1,51 @@
|
|||||||
// Example of how to "wrap" text around an image
|
// 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 * as fs from "fs";
|
||||||
// import { Document, Packer, Paragraph } from "../build";
|
// import { Document, Packer, Paragraph } from "docx";
|
||||||
import { Document, Media, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "../build";
|
import { Document, ImageRun, Packer, Paragraph, TextWrappingSide, TextWrappingType } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const image = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
|
{
|
||||||
floating: {
|
children: [
|
||||||
horizontalPosition: {
|
new Paragraph(
|
||||||
offset: 2014400,
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
|
||||||
|
),
|
||||||
|
new Paragraph(
|
||||||
|
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
|
||||||
|
),
|
||||||
|
new Paragraph(
|
||||||
|
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
|
||||||
|
),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
},
|
||||||
|
floating: {
|
||||||
|
horizontalPosition: {
|
||||||
|
offset: 2014400,
|
||||||
|
},
|
||||||
|
verticalPosition: {
|
||||||
|
offset: 2014400,
|
||||||
|
},
|
||||||
|
wrap: {
|
||||||
|
type: TextWrappingType.SQUARE,
|
||||||
|
side: TextWrappingSide.BOTH_SIDES,
|
||||||
|
},
|
||||||
|
margins: {
|
||||||
|
top: 201440,
|
||||||
|
bottom: 201440,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
verticalPosition: {
|
|
||||||
offset: 2014400,
|
|
||||||
},
|
|
||||||
wrap: {
|
|
||||||
type: TextWrappingType.SQUARE,
|
|
||||||
side: TextWrappingSide.BOTH_SIDES,
|
|
||||||
},
|
|
||||||
margins: {
|
|
||||||
top: 201440,
|
|
||||||
bottom: 201440,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph(
|
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
|
|
||||||
),
|
|
||||||
new Paragraph(
|
|
||||||
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
|
|
||||||
),
|
|
||||||
new Paragraph(
|
|
||||||
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
|
|
||||||
),
|
|
||||||
new Paragraph(image),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,66 +1,72 @@
|
|||||||
// Example how to display page numbers
|
// Example how to display page numbers
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, PageNumberFormat, Paragraph, TextRun } from "../build";
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({});
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
headers: {
|
properties: {
|
||||||
default: new Header({
|
page: {
|
||||||
children: [
|
pageNumbers: {
|
||||||
new Paragraph({
|
start: 1,
|
||||||
|
formatType: NumberFormat.DECIMAL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
default: new Header({
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Foo Bar corp. "),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
children: ["Page Number ", PageNumber.CURRENT],
|
new TextRun("Foo Bar corp. "),
|
||||||
}),
|
new TextRun({
|
||||||
new TextRun({
|
children: ["Page Number ", PageNumber.CURRENT],
|
||||||
children: [" to ", PageNumber.TOTAL_PAGES],
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [" to ", PageNumber.TOTAL_PAGES],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
},
|
||||||
}),
|
footers: {
|
||||||
},
|
default: new Footer({
|
||||||
footers: {
|
|
||||||
default: new Footer({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
alignment: AlignmentType.CENTER,
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Foo Bar corp. "),
|
new Paragraph({
|
||||||
new TextRun({
|
alignment: AlignmentType.CENTER,
|
||||||
children: ["Page Number: ", PageNumber.CURRENT],
|
children: [
|
||||||
}),
|
new TextRun("Foo Bar corp. "),
|
||||||
new TextRun({
|
new TextRun({
|
||||||
children: [" to ", PageNumber.TOTAL_PAGES],
|
children: ["Page Number: ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [" to ", PageNumber.TOTAL_PAGES],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World 1"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World 2"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World 3"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World 4"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World 5"), new PageBreak()],
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
pageNumberStart: 1,
|
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World 1"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World 2"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World 3"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World 4"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [new TextRun("Hello World 5"), new PageBreak()],
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,11 +1,93 @@
|
|||||||
// Example of how you would create a table and add data to it
|
// Example of how you would create a table and add data to it
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
||||||
|
|
||||||
const table = new Table({
|
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: [
|
rows: [
|
||||||
new TableRow({
|
new TableRow({
|
||||||
children: [
|
children: [
|
||||||
@ -30,8 +112,19 @@ const table = new Table({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [table],
|
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) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
// Example demonstrating line numbers.
|
// Example demonstrating line numbers.
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "../build";
|
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
properties: {
|
properties: {
|
||||||
lineNumberCountBy: 1,
|
lineNumbers: {
|
||||||
lineNumberRestart: LineNumberRestartFormat.CONTINUOUS,
|
countBy: 1,
|
||||||
},
|
restart: LineNumberRestartFormat.CONTINUOUS,
|
||||||
children: [
|
},
|
||||||
new Paragraph({
|
},
|
||||||
text: "Hello",
|
children: [
|
||||||
heading: HeadingLevel.HEADING_1,
|
new Paragraph({
|
||||||
}),
|
text: "Hello",
|
||||||
new Paragraph(
|
heading: HeadingLevel.HEADING_1,
|
||||||
"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(
|
||||||
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.",
|
||||||
"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.",
|
),
|
||||||
),
|
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.",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// Multiple cells merging in the same table - Rows and Columns
|
// Multiple cells merging in the same table - Rows and Columns
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "docx";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
@ -252,8 +250,12 @@ const table2 = new Table({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [table, new Paragraph(""), table2],
|
sections: [
|
||||||
|
{
|
||||||
|
children: [table, new Paragraph(""), table2],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((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 * as fs from "fs";
|
||||||
|
import { AlignmentType, Document, Header, Packer, PageBreak, PageNumber, PageNumberSeparator, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,11 +1,15 @@
|
|||||||
// Add image to table cell
|
// Add image to table cell
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import { Document, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, WidthType } from "docx";
|
||||||
|
|
||||||
|
const imageBase64Data = `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`;
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
|
width: {
|
||||||
|
size: 8640,
|
||||||
|
type: WidthType.DXA,
|
||||||
|
},
|
||||||
rows: [
|
rows: [
|
||||||
new TableRow({
|
new TableRow({
|
||||||
children: [
|
children: [
|
||||||
@ -19,7 +23,19 @@ const table = new Table({
|
|||||||
children: [],
|
children: [],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [],
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: Buffer.from(imageBase64Data, "base64"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@ -29,7 +45,19 @@ const table = new Table({
|
|||||||
children: [],
|
children: [],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [],
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [],
|
children: [],
|
||||||
@ -75,8 +103,12 @@ const table = new Table({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [table],
|
sections: [
|
||||||
|
{
|
||||||
|
children: [table],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,37 +1,53 @@
|
|||||||
// Sections with multiple columns
|
// Sections with multiple columns
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph } from "../build";
|
import { Document, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
properties: {
|
properties: {
|
||||||
column: {
|
column: {
|
||||||
space: 708,
|
space: 708,
|
||||||
count: 2,
|
count: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph("This text will be split into 2 columns on a page."),
|
||||||
|
new Paragraph(
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||||
|
),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
children: [
|
properties: {
|
||||||
new Paragraph("This text will be split into 2 columns on a page."),
|
column: {
|
||||||
new Paragraph(
|
space: 708,
|
||||||
"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.",
|
count: 3,
|
||||||
),
|
},
|
||||||
],
|
},
|
||||||
});
|
children: [
|
||||||
|
new Paragraph("This text will be split into 3 columns on a page."),
|
||||||
doc.addSection({
|
new Paragraph(
|
||||||
properties: {
|
"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.",
|
||||||
column: {
|
),
|
||||||
space: 708,
|
],
|
||||||
count: 3,
|
},
|
||||||
|
{
|
||||||
|
properties: {
|
||||||
|
column: {
|
||||||
|
space: 708,
|
||||||
|
count: 2,
|
||||||
|
separate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph("This text will be split into 2 columns on a page."),
|
||||||
|
new Paragraph(
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||||
|
),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
|
||||||
children: [
|
|
||||||
new Paragraph("This text will be split into 3 columns on a page."),
|
|
||||||
new Paragraph(
|
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,33 +1,35 @@
|
|||||||
// Highlighting text
|
// Highlighting text
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "../build";
|
import { AlignmentType, Document, Header, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
headers: {
|
headers: {
|
||||||
default: new Header({
|
default: new Header({
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
alignment: AlignmentType.RIGHT,
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "Hello World",
|
alignment: AlignmentType.RIGHT,
|
||||||
color: "red",
|
children: [
|
||||||
bold: true,
|
new TextRun({
|
||||||
size: 24,
|
text: "Hello World",
|
||||||
font: {
|
color: "FF0000",
|
||||||
name: "Garamond",
|
bold: true,
|
||||||
},
|
size: 24,
|
||||||
highlight: "yellow",
|
font: {
|
||||||
|
name: "Garamond",
|
||||||
|
},
|
||||||
|
highlight: "yellow",
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
},
|
||||||
}),
|
children: [],
|
||||||
},
|
},
|
||||||
children: [],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,49 +1,64 @@
|
|||||||
// Shading text
|
// Shading text
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "../build";
|
import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
headers: {
|
headers: {
|
||||||
default: new Header({
|
default: new Header({
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
alignment: AlignmentType.RIGHT,
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "Hello World",
|
alignment: AlignmentType.RIGHT,
|
||||||
color: "red",
|
children: [
|
||||||
bold: true,
|
new TextRun({
|
||||||
size: 24,
|
text: "Hello World",
|
||||||
font: {
|
color: "FF0000",
|
||||||
name: "Garamond",
|
bold: true,
|
||||||
},
|
size: 24,
|
||||||
|
font: {
|
||||||
|
name: "Garamond",
|
||||||
|
},
|
||||||
|
shading: {
|
||||||
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
|
color: "00FFFF",
|
||||||
|
fill: "FF0000",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
shading: {
|
shading: {
|
||||||
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
type: ShadingType.DIAGONAL_CROSS,
|
||||||
color: "00FFFF",
|
color: "00FFFF",
|
||||||
fill: "FF0000",
|
fill: "FF0000",
|
||||||
},
|
},
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Hello World for entire paragraph",
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
},
|
||||||
|
children: [
|
||||||
new Paragraph({
|
new Paragraph({
|
||||||
shading: {
|
|
||||||
type: ShadingType.DIAGONAL_CROSS,
|
|
||||||
color: "00FFFF",
|
|
||||||
fill: "FF0000",
|
|
||||||
},
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new TextRun({
|
||||||
text: "Hello World for entire paragraph",
|
emboss: true,
|
||||||
|
text: "Embossed text - hello world",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
imprint: true,
|
||||||
|
text: "Imprinted text - hello world",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
},
|
],
|
||||||
children: [],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// Multiple sections with total number of pages in each section
|
// Multiple sections with total number of pages in each section
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, PageNumberFormat, Paragraph, TextRun } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import { AlignmentType, Document, Footer, Header, Packer, PageBreak, PageNumber, NumberFormat, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const header = new Header({
|
const header = new Header({
|
||||||
children: [
|
children: [
|
||||||
@ -26,39 +24,50 @@ const footer = new Footer({
|
|||||||
children: [new Paragraph("Foo Bar corp. ")],
|
children: [new Paragraph("Foo Bar corp. ")],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
headers: {
|
sections: [
|
||||||
default: header,
|
{
|
||||||
},
|
properties: {
|
||||||
footers: {
|
page: {
|
||||||
default: footer,
|
pageNumbers: {
|
||||||
},
|
start: 1,
|
||||||
properties: {
|
formatType: NumberFormat.DECIMAL,
|
||||||
pageNumberStart: 1,
|
},
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
},
|
||||||
},
|
},
|
||||||
children: [
|
headers: {
|
||||||
new Paragraph({
|
default: header,
|
||||||
children: [new TextRun("Section 1"), new PageBreak(), new TextRun("Section 1"), new PageBreak()],
|
},
|
||||||
}),
|
footers: {
|
||||||
],
|
default: footer,
|
||||||
});
|
},
|
||||||
|
children: [
|
||||||
doc.addSection({
|
new Paragraph({
|
||||||
headers: {
|
children: [new TextRun("Section 1"), new PageBreak(), new TextRun("Section 1"), new PageBreak()],
|
||||||
default: header,
|
}),
|
||||||
},
|
],
|
||||||
footers: {
|
},
|
||||||
default: footer,
|
{
|
||||||
},
|
properties: {
|
||||||
properties: {
|
page: {
|
||||||
pageNumberStart: 1,
|
pageNumbers: {
|
||||||
pageNumberFormatType: PageNumberFormat.DECIMAL,
|
start: 1,
|
||||||
},
|
formatType: NumberFormat.DECIMAL,
|
||||||
children: [
|
},
|
||||||
new Paragraph({
|
},
|
||||||
children: [new TextRun("Section 2"), new PageBreak(), new TextRun("Section 2"), new PageBreak()],
|
},
|
||||||
}),
|
headers: {
|
||||||
|
default: header,
|
||||||
|
},
|
||||||
|
footers: {
|
||||||
|
default: footer,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Section 2"), new PageBreak(), new TextRun("Section 2"), new PageBreak()],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
// Example of making content of section vertically aligned
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, SectionVerticalAlignValue, TextRun } from "../build";
|
import { Document, Packer, Paragraph, VerticalAlign, TextRun, Tab } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
properties: {
|
properties: {
|
||||||
verticalAlign: SectionVerticalAlignValue.CENTER,
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
},
|
},
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World"),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "Foo Bar",
|
new TextRun("Hello World"),
|
||||||
bold: true,
|
new TextRun({
|
||||||
}),
|
text: "Foo Bar",
|
||||||
new TextRun({
|
bold: true,
|
||||||
text: "\tGithub is the best",
|
}),
|
||||||
bold: true,
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,15 +1,47 @@
|
|||||||
// Add custom borders to the table itself
|
// Add custom borders and no-borders to the table itself
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { BorderStyle, Document, Packer, Paragraph, Table, TableCell, TableRow } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
BorderStyle,
|
||||||
|
Document,
|
||||||
|
HeadingLevel,
|
||||||
|
Packer,
|
||||||
|
Paragraph,
|
||||||
|
Table,
|
||||||
|
TableBorders,
|
||||||
|
TableCell,
|
||||||
|
TableRow,
|
||||||
|
TextDirection,
|
||||||
|
VerticalAlign,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
new TableRow({
|
new TableRow({
|
||||||
children: [
|
children: [
|
||||||
new TableCell({
|
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")],
|
children: [new Paragraph("Hello")],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
@ -30,7 +62,104 @@ const table = new Table({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({ children: [table] });
|
// Using the no-border convenience object. It is the same as writing this manually:
|
||||||
|
// const borders = {
|
||||||
|
// top: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// bottom: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// left: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// right: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// insideHorizontal: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// insideVertical: {
|
||||||
|
// style: BorderStyle.NONE,
|
||||||
|
// size: 0,
|
||||||
|
// color: "auto",
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
const noBorderTable = new Table({
|
||||||
|
borders: TableBorders.NONE,
|
||||||
|
rows: [
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph({}), new Paragraph({})],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph({}), new Paragraph({})],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph({ text: "bottom to top" }), new Paragraph({})],
|
||||||
|
textDirection: TextDirection.BOTTOM_TO_TOP_LEFT_TO_RIGHT,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [new Paragraph({ text: "top to bottom" }), new Paragraph({})],
|
||||||
|
textDirection: TextDirection.TOP_TO_BOTTOM_RIGHT_TO_LEFT,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",
|
||||||
|
heading: HeadingLevel.HEADING_1,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "This text should be in the middle of the cell",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Text above should be vertical from bottom to top",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
text: "Text above should be vertical from top to bottom",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [{ children: [table, new Paragraph("Hello"), noBorderTable] }],
|
||||||
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
202
demo/5-images.ts
202
demo/5-images.ts
@ -1,59 +1,173 @@
|
|||||||
// Example of how to add images to the document - You can use Buffers, UInt8Arrays or Base64 strings
|
// 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 * as fs from "fs";
|
||||||
// import { Document, Packer, Paragraph } from "../build";
|
|
||||||
import {
|
import {
|
||||||
|
convertMillimetersToTwip,
|
||||||
Document,
|
Document,
|
||||||
HorizontalPositionAlign,
|
HorizontalPositionAlign,
|
||||||
HorizontalPositionRelativeFrom,
|
HorizontalPositionRelativeFrom,
|
||||||
Media,
|
ImageRun,
|
||||||
Packer,
|
Packer,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
VerticalPositionAlign,
|
VerticalPositionAlign,
|
||||||
VerticalPositionRelativeFrom,
|
VerticalPositionRelativeFrom,
|
||||||
} from "../build";
|
} from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
{
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png").toString("base64"));
|
children: [
|
||||||
const image3 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"));
|
new Paragraph("Hello World"),
|
||||||
const image4 = Media.addImage(doc, fs.readFileSync("./demo/images/parrots.bmp"));
|
new Paragraph({
|
||||||
const image5 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
children: [
|
||||||
const image6 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"), 200, 200, {
|
new ImageRun({
|
||||||
floating: {
|
type: "jpg",
|
||||||
horizontalPosition: {
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
offset: 1014400,
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
altText: {
|
||||||
|
title: "This is an ultimate title",
|
||||||
|
description: "This is an ultimate image",
|
||||||
|
name: "My Ultimate Image",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "png",
|
||||||
|
data: fs.readFileSync("./demo/images/dog.png").toString("base64"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
outline: {
|
||||||
|
type: "solidFill",
|
||||||
|
solidFillType: "rgb",
|
||||||
|
value: "FF0000",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "jpg",
|
||||||
|
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
flip: {
|
||||||
|
vertical: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
outline: {
|
||||||
|
type: "solidFill",
|
||||||
|
solidFillType: "rgb",
|
||||||
|
value: "0000FF",
|
||||||
|
width: convertMillimetersToTwip(600),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "bmp",
|
||||||
|
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||||
|
transformation: {
|
||||||
|
width: 150,
|
||||||
|
height: 150,
|
||||||
|
flip: {
|
||||||
|
horizontal: true,
|
||||||
|
},
|
||||||
|
rotation: 225,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "gif",
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
flip: {
|
||||||
|
horizontal: true,
|
||||||
|
vertical: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "gif",
|
||||||
|
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({
|
||||||
|
type: "jpg",
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
type: "svg",
|
||||||
|
data: fs.readFileSync("./demo/images/linux-svg.svg"),
|
||||||
|
transformation: {
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
},
|
||||||
|
fallback: {
|
||||||
|
type: "png",
|
||||||
|
data: fs.readFileSync("./demo/images/linux-png.png"),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
verticalPosition: {
|
|
||||||
offset: 1014400,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const image7 = Media.addImage(doc, fs.readFileSync("./demo/images/cat.jpg"), 200, 200, {
|
|
||||||
floating: {
|
|
||||||
horizontalPosition: {
|
|
||||||
relative: HorizontalPositionRelativeFrom.PAGE,
|
|
||||||
align: HorizontalPositionAlign.RIGHT,
|
|
||||||
},
|
|
||||||
verticalPosition: {
|
|
||||||
relative: VerticalPositionRelativeFrom.PAGE,
|
|
||||||
align: VerticalPositionAlign.BOTTOM,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph("Hello World"),
|
|
||||||
new Paragraph(image1),
|
|
||||||
new Paragraph(image2),
|
|
||||||
new Paragraph(image3),
|
|
||||||
new Paragraph(image4),
|
|
||||||
new Paragraph(image5),
|
|
||||||
new Paragraph(image6),
|
|
||||||
new Paragraph(image7),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
// Simple example to add text to a document
|
// The demo on the README.md
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Media, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "../build";
|
import { Document, HeadingLevel, ImageRun, Packer, Paragraph, Table, TableCell, TableRow, VerticalAlign } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
|
||||||
|
|
||||||
const image1 = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
|
|
||||||
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/pizza.gif"));
|
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
rows: [
|
rows: [
|
||||||
new TableRow({
|
new TableRow({
|
||||||
children: [
|
children: [
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph(image1)],
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
verticalAlign: VerticalAlign.CENTER,
|
verticalAlign: VerticalAlign.CENTER,
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
@ -38,21 +45,47 @@ const table = new Table({
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [new Paragraph(image1)],
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.addSection({
|
const doc = new Document({
|
||||||
children: [
|
sections: [
|
||||||
new Paragraph({
|
{
|
||||||
text: "Hello World",
|
children: [
|
||||||
heading: HeadingLevel.HEADING_1,
|
new Paragraph({
|
||||||
}),
|
text: "Hello World",
|
||||||
table,
|
heading: HeadingLevel.HEADING_1,
|
||||||
new Paragraph(image2),
|
}),
|
||||||
|
table,
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new ImageRun({
|
||||||
|
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||||
|
transformation: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Custom character styles using JavaScript configuration
|
// Custom character styles using JavaScript configuration
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
@ -15,20 +15,40 @@ const doc = new Document({
|
|||||||
italics: true,
|
italics: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "strong",
|
||||||
|
name: "Strong",
|
||||||
|
basedOn: "Normal",
|
||||||
|
run: {
|
||||||
|
bold: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "Foo bar",
|
children: [
|
||||||
style: "myRedStyle",
|
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.",
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Japanese text - Need to use a Japanese font
|
// 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 * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
@ -18,17 +18,18 @@ const doc = new Document({
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
children: [
|
||||||
children: [
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "KFCを食べるのが好き",
|
||||||
text: "KFCを食べるのが好き",
|
heading: HeadingLevel.HEADING_1,
|
||||||
heading: HeadingLevel.HEADING_1,
|
}),
|
||||||
}),
|
new Paragraph({
|
||||||
new Paragraph({
|
text: "こんにちは",
|
||||||
text: "こんにちは",
|
}),
|
||||||
}),
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,12 +5,23 @@
|
|||||||
|
|
||||||
// Note that if the OS have not install `KaiTi` font, this demo doesn't work.
|
// 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 * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
styles: {
|
styles: {
|
||||||
|
default: {
|
||||||
|
document: {
|
||||||
|
run: {
|
||||||
|
font: {
|
||||||
|
ascii: "minorHAnsi",
|
||||||
|
eastAsia: "minorEastAsia",
|
||||||
|
cs: "minorBidi",
|
||||||
|
hAnsi: "minorHAnsi",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
paragraphStyles: [
|
paragraphStyles: [
|
||||||
{
|
{
|
||||||
id: "Normal",
|
id: "Normal",
|
||||||
@ -20,33 +31,57 @@ const doc = new Document({
|
|||||||
quickFormat: true,
|
quickFormat: true,
|
||||||
run: {
|
run: {
|
||||||
font: {
|
font: {
|
||||||
ascii: "Times",
|
ascii: "minorHAnsi", // Can also use minorHAnsi
|
||||||
eastAsia: "KaiTi",
|
eastAsia: "minorEastAsia", // Can also use minorEastAsia
|
||||||
|
cs: "minorBidi",
|
||||||
|
hAnsi: "minorHAnsi",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
text: "中文和英文 Chinese and English",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
text: "中文和英文 Chinese and English",
|
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "中文和英文 Chinese and English",
|
text: "中文和英文 Chinese and English",
|
||||||
font: { eastAsia: "SimSun" }, // set eastAsia to "SimSun".
|
heading: HeadingLevel.HEADING_1,
|
||||||
// The ascii characters will use the default font ("Times") specified in paragraphStyles
|
}),
|
||||||
|
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: `店様付旅母正役基社発破班。発治治京岡局本因追意金紀統責郵滴尽。立功日庁重天富評界明済不着法返祉経正引行。載区列防新目治日群付無人道言越名。界安無死専体風木人教録覧訃。女問堂容県作先芸便効証帯債土全極的日。能山中岡仕関攻井季接店線幌温後率事阜止。成間路行究今式歌像祉帯式媛読徹。安行息古入出文侵監株登部席内文第珍鶴問用。
|
||||||
|
|
||||||
|
編竹入俳多応日氏陸福芸北供動。情績拠僧肺軍油能認郷翌南対韓短東食束兵晶。政予任習口佐所当止市告号。悩申無式立医毎部観潟訴菱権。発臼背郎上予配光記芸注然出。梨場株以政囲下球品材県動政押婚面見。米共試使落帳遅毅間三子開。問与大八地芸第線体架辺今死。押構草齢戦重最変社豪記目盗連報準周込。系貸劇様重鷲始能質村異社学動導勤。
|
||||||
|
|
||||||
|
残様的荻仲刺局標績供質球就雄。考和母問者役尊紙推新経革個事編安観。益学北日著楽車山勢流泉四犯投台戒設対臨百。危謄初治穴委済本索労刊回。月写政覧女事棋違年終索情響白子泉転企堀社。江遊著西高開面毎分芸責成創査全判調目止懇。原育会夏作売望人転乱融抜心。制川供健水示囲阜厚高右断季人役。持面必日暮気管像冬間影図健行格阪。
|
||||||
|
|
||||||
|
来入工速会健評下町慮大貸社一見園外申憶。服豊舞入面沢交使奥見記写意岩。北観提女刊液城共五擦相売田合是由読。回歳売苦定記点郎意増賛治北渡本応。受送文携村陸情静了申注際。順負子研済老上変女産第内無費携投展達。東初乗回動合語学待聴暮沢流全場導敷記賞次。更物中備著後渡売第部時禁新田木下昨。備護起織服久権意全海馬適応。
|
||||||
|
|
||||||
|
幸速団供地信討川安矛場消学年。去茂玉東今要出約元教負限載始今簡。編掲証的情仕渡室手映法部始。紙反語清阪曜税受知選謝個印観聞。教人超死準無者参生撤技真価椿景破市見国。左需臓道力趣暮際丁高会近部敗岡力当社。壊態毒期波超長写島断兆国世行共絞私報。反野番点図択女撃脱案情王援。減属考論月院催者門料約覧市戦。
|
||||||
|
|
||||||
|
山部午金査投立集争教殺巣作世動北部応。通負考隙問粛中帯閉要程規化小。橋棋互界時引就現省竹去子無系容米。竹転起日本新田強済購書区庁集作容同会窓教。文公神転待究挙登投川選囲針能楽路断出歌。祥新現寄公史真玉属元始員金抜関前百衝能。国眺暮囲世嘘面外営国内報夜九掲事春葉。来月刊台先良理著自供法投。通渡請当月学安首一押実展介況。
|
||||||
|
|
||||||
|
法優分独込右得里記域目順供進乗。憂婚転峰大写医投社曲題任能務熱県展覧港専。栄余歯真著改追事作果石芸。青感将南便再転領鈴投提鉄索競虎師体物想。牲打迎達携度開技書催掲安去変念座。革混疑生採就枢当住回県組北意寛。爆新和級掲交象温十賛展木開有結日。新海辺小除京物興量写界裁上。文師建関面取質也底沼画者図空医心無季。
|
||||||
|
|
||||||
|
高館湯転名気業以際置講詰方活礎組調軽際。発変東作訪乃小化理利提目気。極季本問号面帯勤戦行新禁情堀郎携。座所転再祥業必変昌今歩佐王立抗後養崩。支物猪躍芸整縦焦供防続相護治時語朝分刊定。綿田幸崎責本欲間載神調崎答志政報与速美載。飯治止稿原先明画森群進見情幕。女民館終調質並伝車慌供科。支田国傷自動献疑討医足公成公主断的望。
|
||||||
|
|
||||||
|
責開児食福実帰治師今策今。水重寺圧医観送連東者秒途。選央力律式開作掲写様階組戦写型紙。式国販時天遣国出難共前次領体康稲住転。査見保重議原速群者内月正連。爾天膨装芸別巨平運数準三浜念載創県奈飛提。素京発揮田談気党示見象定電類代級。善返跡国有話権入猛府週亡辞馬脳。関残主祐雪塚去集村完海関文受載表川護照立。
|
||||||
|
|
||||||
|
発闘美慎健育旅布容広互無秋認天歌媛芸。転器合読県増認会賞倒点系。食気母服絵知去祝芸車報熱勝。能貿月更障文的欠賞現覇声敏施会。懲病写昼法族業律記聡生開緊楽暮護。東地二員者説盟治害討面提。第北乗査庭年近的禁疑報方店記必迷都流通。聞有力前愛院梨野関業前訳本清滋補。蒲読火死勝広保会婚際気二由保国。用君込村需起相点選紙拡氏訃不。`,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
26
demo/54-custom-properties.ts
Normal file
26
demo/54-custom-properties.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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 * as fs from "fs";
|
||||||
|
import { Document, Packer } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,145 +0,0 @@
|
|||||||
// Track Revisions aka. "Track Changes"
|
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import {
|
|
||||||
AlignmentType,
|
|
||||||
DeletedTextRun,
|
|
||||||
Document,
|
|
||||||
Footer,
|
|
||||||
FootnoteReferenceRun,
|
|
||||||
InsertedTextRun,
|
|
||||||
Packer,
|
|
||||||
PageNumber,
|
|
||||||
Paragraph,
|
|
||||||
ShadingType,
|
|
||||||
TextRun,
|
|
||||||
} from "../build";
|
|
||||||
|
|
||||||
/*
|
|
||||||
For reference, see
|
|
||||||
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.insertedrun
|
|
||||||
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.deletedrun
|
|
||||||
|
|
||||||
The method `addTrackRevisions()` adds an element `<w:trackRevisions />` to the `settings.xml` file. This specifies that the application shall track *new* revisions made to the existing document.
|
|
||||||
See also https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.trackrevisions
|
|
||||||
|
|
||||||
Note that this setting enables to track *new changes* after teh file is generated, so this example will still show inserted and deleted text runs when you remove it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const doc = new Document({
|
|
||||||
footnotes: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("This is a footnote"),
|
|
||||||
new DeletedTextRun({
|
|
||||||
text: " with some extra text which was deleted",
|
|
||||||
id: 0,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:05:00Z",
|
|
||||||
}),
|
|
||||||
new InsertedTextRun({
|
|
||||||
text: " and new content",
|
|
||||||
id: 1,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:05:00Z",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
features: {
|
|
||||||
trackRevisions: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const paragraph = new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("This is a simple demo "),
|
|
||||||
new TextRun({
|
|
||||||
text: "on how to ",
|
|
||||||
}),
|
|
||||||
new InsertedTextRun({
|
|
||||||
text: "mark a text as an insertion ",
|
|
||||||
id: 0,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:00:00Z",
|
|
||||||
}),
|
|
||||||
new DeletedTextRun({
|
|
||||||
text: "or a deletion.",
|
|
||||||
id: 1,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:00:00Z",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
properties: {},
|
|
||||||
children: [
|
|
||||||
paragraph,
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new TextRun("This is a demo "),
|
|
||||||
new DeletedTextRun({
|
|
||||||
text: "in order",
|
|
||||||
color: "red",
|
|
||||||
bold: true,
|
|
||||||
size: 24,
|
|
||||||
font: {
|
|
||||||
name: "Garamond",
|
|
||||||
},
|
|
||||||
shading: {
|
|
||||||
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
|
||||||
color: "00FFFF",
|
|
||||||
fill: "FF0000",
|
|
||||||
},
|
|
||||||
id: 2,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:00:00Z",
|
|
||||||
}).break(),
|
|
||||||
new InsertedTextRun({
|
|
||||||
text: "to show how to ",
|
|
||||||
bold: false,
|
|
||||||
id: 3,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:05:00Z",
|
|
||||||
}),
|
|
||||||
new TextRun({
|
|
||||||
bold: true,
|
|
||||||
children: ["\tuse Inserted and Deleted TextRuns.", new FootnoteReferenceRun(1)],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
footers: {
|
|
||||||
default: new Footer({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
alignment: AlignmentType.CENTER,
|
|
||||||
children: [
|
|
||||||
new TextRun("Awesome LLC"),
|
|
||||||
new TextRun({
|
|
||||||
children: ["Page Number: ", PageNumber.CURRENT],
|
|
||||||
}),
|
|
||||||
new DeletedTextRun({
|
|
||||||
children: [" to ", PageNumber.TOTAL_PAGES],
|
|
||||||
id: 4,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:05:00Z",
|
|
||||||
}),
|
|
||||||
new InsertedTextRun({
|
|
||||||
children: [" from ", PageNumber.TOTAL_PAGES],
|
|
||||||
bold: true,
|
|
||||||
id: 5,
|
|
||||||
author: "Firstname Lastname",
|
|
||||||
date: "2020-10-06T09:05:00Z",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
|
||||||
fs.writeFileSync("My Document.docx", buffer);
|
|
||||||
});
|
|
519
demo/55-math.ts
519
demo/55-math.ts
@ -1,5 +1,5 @@
|
|||||||
// Simple example to add text to a document
|
// 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 * as fs from "fs";
|
||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
@ -16,276 +16,327 @@ import {
|
|||||||
MathSubScript,
|
MathSubScript,
|
||||||
MathSubSuperScript,
|
MathSubSuperScript,
|
||||||
MathSum,
|
MathSum,
|
||||||
|
MathIntegral,
|
||||||
MathSuperScript,
|
MathSuperScript,
|
||||||
Packer,
|
Packer,
|
||||||
Paragraph,
|
Paragraph,
|
||||||
TextRun,
|
TextRun,
|
||||||
} from "../build";
|
MathLimitLower,
|
||||||
|
MathLimitUpper,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
properties: {},
|
properties: {},
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new Math({
|
new Paragraph({
|
||||||
children: [
|
children: [
|
||||||
new MathRun("2+2"),
|
new Math({
|
||||||
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: [
|
children: [
|
||||||
|
new MathRun("2+2"),
|
||||||
new MathFraction({
|
new MathFraction({
|
||||||
numerator: [new MathRun("1")],
|
numerator: [new MathRun("hi")],
|
||||||
denominator: [new MathRun("2")],
|
denominator: [new MathRun("2")],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
subScript: [new MathRun("4")],
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
new Paragraph({
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new Math({
|
|
||||||
children: [
|
children: [
|
||||||
new MathSubScript({
|
new Math({
|
||||||
children: [
|
children: [
|
||||||
new MathRadical({
|
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 MathIntegral({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
}),
|
||||||
|
new MathIntegral({
|
||||||
|
children: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("e")],
|
||||||
|
superScript: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
subScript: [new MathRun("i")],
|
||||||
|
}),
|
||||||
|
new MathIntegral({
|
||||||
|
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: [
|
children: [
|
||||||
new MathFraction({
|
new MathFraction({
|
||||||
numerator: [new MathRun("1")],
|
numerator: [new MathRun("1")],
|
||||||
denominator: [new MathRun("2")],
|
denominator: [new MathRun("2")],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
degree: [new MathRun("4")],
|
subScript: [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({
|
||||||
}),
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
|
||||||
new Math({
|
|
||||||
children: [
|
children: [
|
||||||
new MathFraction({
|
new Math({
|
||||||
numerator: [
|
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({
|
new MathRadical({
|
||||||
children: [new MathRun("4")],
|
children: [new MathRun("4")],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
denominator: [new MathRun("2a")],
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
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")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathLimitUpper({
|
||||||
|
children: [new MathRun("x")],
|
||||||
|
limit: [new MathRun("-")],
|
||||||
|
}),
|
||||||
|
new MathRun("="),
|
||||||
|
new MathLimitLower({
|
||||||
|
children: [new MathRun("lim")],
|
||||||
|
limit: [new MathRun("x→0")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
// Change background colour of whole document
|
// Change background colour of whole document
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document({
|
const doc = new Document({
|
||||||
background: {
|
background: {
|
||||||
color: "C45911",
|
color: "C45911",
|
||||||
},
|
},
|
||||||
});
|
sections: [
|
||||||
|
{
|
||||||
doc.addSection({
|
properties: {},
|
||||||
properties: {},
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World"),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "Foo Bar",
|
new TextRun("Hello World"),
|
||||||
bold: true,
|
new TextRun({
|
||||||
}),
|
text: "Foo Bar",
|
||||||
new TextRun({
|
bold: true,
|
||||||
text: "\tGithub is the best",
|
}),
|
||||||
bold: true,
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,31 +0,0 @@
|
|||||||
// Add Run styles across the whole Paragraph
|
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
|
||||||
import { Document, Packer, Paragraph, TextRun } from "../build";
|
|
||||||
|
|
||||||
const doc = new Document();
|
|
||||||
|
|
||||||
doc.addSection({
|
|
||||||
children: [
|
|
||||||
new Paragraph({
|
|
||||||
runStyle: {
|
|
||||||
size: 100,
|
|
||||||
},
|
|
||||||
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);
|
|
||||||
});
|
|
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 * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, TextRun, SectionType } from "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Document, Footer, Header, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,37 +1,43 @@
|
|||||||
// Example of how to change page borders
|
// Example of how to change page borders
|
||||||
// Import from 'docx' rather than '../build' if you install from npm
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "../build";
|
import { Document, HeadingLevel, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
margins: {
|
properties: {
|
||||||
top: 0,
|
page: {
|
||||||
right: 0,
|
margin: {
|
||||||
bottom: 0,
|
top: 0,
|
||||||
left: 0,
|
right: 0,
|
||||||
},
|
bottom: 0,
|
||||||
children: [
|
left: 0,
|
||||||
new Paragraph({
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
children: [
|
children: [
|
||||||
new TextRun("Hello World"),
|
new Paragraph({
|
||||||
new TextRun({
|
children: [
|
||||||
text: "Foo bar",
|
new TextRun("Hello World"),
|
||||||
bold: true,
|
new TextRun({
|
||||||
|
text: "Foo bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
new TextRun({
|
new Paragraph({
|
||||||
text: "\tGithub is the best",
|
text: "Hello World",
|
||||||
bold: true,
|
heading: HeadingLevel.HEADING_1,
|
||||||
}),
|
}),
|
||||||
|
new Paragraph("Foo bar"),
|
||||||
|
new Paragraph("Github is the best"),
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
new Paragraph({
|
|
||||||
text: "Hello World",
|
|
||||||
heading: HeadingLevel.HEADING_1,
|
|
||||||
}),
|
|
||||||
new Paragraph("Foo bar"),
|
|
||||||
new Paragraph("Github is the best"),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
164
demo/60-track-revisions.ts
Normal file
164
demo/60-track-revisions.ts
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// Track Revisions aka. "Track Changes"
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
AlignmentType,
|
||||||
|
DeletedTextRun,
|
||||||
|
Document,
|
||||||
|
Footer,
|
||||||
|
FootnoteReferenceRun,
|
||||||
|
InsertedTextRun,
|
||||||
|
Packer,
|
||||||
|
PageNumber,
|
||||||
|
Paragraph,
|
||||||
|
ShadingType,
|
||||||
|
Tab,
|
||||||
|
TextRun,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
|
/*
|
||||||
|
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: [new Tab(), "use Inserted and Deleted TextRuns.", new FootnoteReferenceRun(1)],
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
bold: true,
|
||||||
|
text: "And some style changes",
|
||||||
|
revision: {
|
||||||
|
id: 4,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
bold: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
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);
|
||||||
|
});
|
186
demo/61-text-frame.ts
Normal file
186
demo/61-text-frame.ts
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
// Text Frame (Text Box) example
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
AlignmentType,
|
||||||
|
BorderStyle,
|
||||||
|
Document,
|
||||||
|
FrameAnchorType,
|
||||||
|
HorizontalPositionAlign,
|
||||||
|
Packer,
|
||||||
|
Paragraph,
|
||||||
|
Tab,
|
||||||
|
TextRun,
|
||||||
|
VerticalPositionAlign,
|
||||||
|
} from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
frame: {
|
||||||
|
type: "absolute",
|
||||||
|
position: {
|
||||||
|
x: 1000,
|
||||||
|
y: 3000,
|
||||||
|
},
|
||||||
|
width: 4000,
|
||||||
|
height: 1000,
|
||||||
|
anchor: {
|
||||||
|
horizontal: FrameAnchorType.MARGIN,
|
||||||
|
vertical: FrameAnchorType.MARGIN,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
frame: {
|
||||||
|
type: "alignment",
|
||||||
|
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({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
frame: {
|
||||||
|
type: "alignment",
|
||||||
|
width: 4000,
|
||||||
|
height: 1000,
|
||||||
|
anchor: {
|
||||||
|
horizontal: FrameAnchorType.MARGIN,
|
||||||
|
vertical: FrameAnchorType.MARGIN,
|
||||||
|
},
|
||||||
|
alignment: {
|
||||||
|
x: HorizontalPositionAlign.CENTER,
|
||||||
|
y: VerticalPositionAlign.BOTTOM,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
alignment: AlignmentType.RIGHT,
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World"),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github 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 * as fs from "fs";
|
||||||
|
import { Document, LineRuleType, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Document, Footer, Header, Packer, PageBreak, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, LevelFormat } from "docx";
|
||||||
|
|
||||||
|
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("My Document.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 * as fs from "fs";
|
||||||
|
import { convertMillimetersToTwip, Document, Packer, PageOrientation, Paragraph } from "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Bookmark, Document, Packer, Paragraph, SimpleField, TextRun } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
30
demo/67-column-break.ts
Normal file
30
demo/67-column-break.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Section with 2 columns including a column break
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, ColumnBreak, TextRun } from "docx";
|
||||||
|
|
||||||
|
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 "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Column, Document, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
@ -1,15 +1,21 @@
|
|||||||
// Example of how to set the document to landscape
|
// 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 * as fs from "fs";
|
||||||
import { Document, Packer, PageOrientation, Paragraph } from "../build";
|
import { Document, Packer, PageOrientation, Paragraph } from "docx";
|
||||||
|
|
||||||
const doc = new Document();
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
doc.addSection({
|
{
|
||||||
size: {
|
properties: {
|
||||||
orientation: PageOrientation.LANDSCAPE,
|
page: {
|
||||||
},
|
size: {
|
||||||
children: [new Paragraph("Hello World")],
|
orientation: PageOrientation.LANDSCAPE,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
children: [new Paragraph("Hello World")],
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
Packer.toBuffer(doc).then((buffer) => {
|
Packer.toBuffer(doc).then((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 * as fs from "fs";
|
||||||
|
import { Document, HeadingLevel, LineNumberRestartFormat, Packer, Paragraph } from "docx";
|
||||||
|
|
||||||
|
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 * as fs from "fs";
|
||||||
|
import { Document, Packer, TextRun, Paragraph, BorderStyle, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder } from "docx";
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
55
demo/72-word-wrap.ts
Normal file
55
demo/72-word-wrap.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Example on how to preserve word wrap text. Works with all languages.
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
wordWrap: true,
|
||||||
|
children: [
|
||||||
|
new TextRun("我今天遛狗去公园"),
|
||||||
|
new TextRun({
|
||||||
|
text: "456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
wordWrap: true,
|
||||||
|
children: [
|
||||||
|
new TextRun(
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
|
||||||
|
),
|
||||||
|
new TextRun({
|
||||||
|
text: "456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("我今天遛狗去公园"),
|
||||||
|
new TextRun({
|
||||||
|
text: "456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun(
|
||||||
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua",
|
||||||
|
),
|
||||||
|
new TextRun({
|
||||||
|
text: "456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345456435234523456435564745673456345",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
138
demo/73-comments.ts
Normal file
138
demo/73-comments.ts
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
// Simple example to add comments to a document
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, TextRun, CommentRangeStart, CommentRangeEnd, CommentReference } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
comments: {
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: 0,
|
||||||
|
author: "Ray Chen",
|
||||||
|
date: new Date(),
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "some initial text content",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "comment text content",
|
||||||
|
}),
|
||||||
|
new TextRun({ text: "", break: 1 }),
|
||||||
|
new TextRun({
|
||||||
|
text: "More text here",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
author: "Bob Ross",
|
||||||
|
date: new Date(),
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Some initial text content",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "comment text content",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
author: "John Doe",
|
||||||
|
date: new Date(),
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Hello World",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
author: "Beatriz",
|
||||||
|
date: new Date(),
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Another reply",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World"),
|
||||||
|
new CommentRangeStart(0),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new CommentRangeEnd(0),
|
||||||
|
new TextRun({
|
||||||
|
children: [new CommentReference(0)],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new CommentRangeStart(1),
|
||||||
|
new CommentRangeStart(2),
|
||||||
|
new CommentRangeStart(3),
|
||||||
|
new TextRun({
|
||||||
|
text: "Some text which need commenting",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new CommentRangeEnd(1),
|
||||||
|
new TextRun({
|
||||||
|
children: [new CommentReference(1)],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new CommentRangeEnd(2),
|
||||||
|
new TextRun({
|
||||||
|
children: [new CommentReference(2)],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new CommentRangeEnd(3),
|
||||||
|
new TextRun({
|
||||||
|
children: [new CommentReference(3)],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
30
demo/74-nodejs-stream.ts
Normal file
30
demo/74-nodejs-stream.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Exporting the document as a stream
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, Tab, TextRun } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World"),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
children: [new Tab(), "Github is the best"],
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const stream = Packer.toStream(doc);
|
||||||
|
stream.pipe(fs.createWriteStream("My Document.docx"));
|
81
demo/75-tab-stops.ts
Normal file
81
demo/75-tab-stops.ts
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Example of using tab stops
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, HeadingLevel, Packer, Paragraph, TabStopPosition, TabStopType, TextRun } from "docx";
|
||||||
|
|
||||||
|
const columnWidth = TabStopPosition.MAX / 4;
|
||||||
|
const receiptTabStops = [
|
||||||
|
// no need to define first left tab column
|
||||||
|
// the right aligned tab column position should point to the end of column
|
||||||
|
// i.e. in this case
|
||||||
|
// (end position of 1st) + (end position of current)
|
||||||
|
// columnWidth + columnWidth = columnWidth * 2
|
||||||
|
|
||||||
|
{ type: TabStopType.RIGHT, position: columnWidth * 2 },
|
||||||
|
{ type: TabStopType.RIGHT, position: columnWidth * 3 },
|
||||||
|
{ type: TabStopType.RIGHT, position: TabStopPosition.MAX },
|
||||||
|
];
|
||||||
|
const twoTabStops = [{ type: TabStopType.RIGHT, position: TabStopPosition.MAX }];
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
defaultTabStop: 0,
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
heading: HeadingLevel.HEADING_1,
|
||||||
|
children: [new TextRun("Receipt 001")],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: twoTabStops,
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "To Bob.\tBy Alice.",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: twoTabStops,
|
||||||
|
children: [new TextRun("Foo Inc\tBar Inc")],
|
||||||
|
}),
|
||||||
|
new Paragraph({ text: "" }),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: receiptTabStops,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Item\tPrice\tQuantity\tSub-total",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: receiptTabStops,
|
||||||
|
text: "Item 3\t10\t5\t50",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: receiptTabStops,
|
||||||
|
text: "Item 3\t10\t5\t50",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: receiptTabStops,
|
||||||
|
text: "Item 3\t10\t5\t50",
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
tabStops: receiptTabStops,
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "\t\t\tTotal: 200",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const stream = Packer.toStream(doc);
|
||||||
|
stream.pipe(fs.createWriteStream("My Document.docx"));
|
87
demo/76-compatibility.ts
Normal file
87
demo/76-compatibility.ts
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// Add compatibility options
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, TextRun } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
compatibility: {
|
||||||
|
useSingleBorderforContiguousCells: true,
|
||||||
|
wordPerfectJustification: true,
|
||||||
|
noTabStopForHangingIndent: true,
|
||||||
|
noLeading: true,
|
||||||
|
spaceForUnderline: true,
|
||||||
|
noColumnBalance: true,
|
||||||
|
balanceSingleByteDoubleByteWidth: true,
|
||||||
|
noExtraLineSpacing: true,
|
||||||
|
doNotLeaveBackslashAlone: true,
|
||||||
|
underlineTrailingSpaces: true,
|
||||||
|
doNotExpandShiftReturn: true,
|
||||||
|
spacingInWholePoints: true,
|
||||||
|
lineWrapLikeWord6: true,
|
||||||
|
printBodyTextBeforeHeader: true,
|
||||||
|
printColorsBlack: true,
|
||||||
|
spaceWidth: true,
|
||||||
|
showBreaksInFrames: true,
|
||||||
|
subFontBySize: true,
|
||||||
|
suppressBottomSpacing: true,
|
||||||
|
suppressTopSpacing: true,
|
||||||
|
suppressSpacingAtTopOfPage: true,
|
||||||
|
suppressTopSpacingWP: true,
|
||||||
|
suppressSpBfAfterPgBrk: true,
|
||||||
|
swapBordersFacingPages: true,
|
||||||
|
convertMailMergeEsc: true,
|
||||||
|
truncateFontHeightsLikeWP6: true,
|
||||||
|
macWordSmallCaps: true,
|
||||||
|
usePrinterMetrics: true,
|
||||||
|
doNotSuppressParagraphBorders: true,
|
||||||
|
wrapTrailSpaces: true,
|
||||||
|
footnoteLayoutLikeWW8: true,
|
||||||
|
shapeLayoutLikeWW8: true,
|
||||||
|
alignTablesRowByRow: true,
|
||||||
|
forgetLastTabAlignment: true,
|
||||||
|
adjustLineHeightInTable: true,
|
||||||
|
autoSpaceLikeWord95: true,
|
||||||
|
noSpaceRaiseLower: true,
|
||||||
|
doNotUseHTMLParagraphAutoSpacing: true,
|
||||||
|
layoutRawTableWidth: true,
|
||||||
|
layoutTableRowsApart: true,
|
||||||
|
useWord97LineBreakRules: true,
|
||||||
|
doNotBreakWrappedTables: true,
|
||||||
|
doNotSnapToGridInCell: true,
|
||||||
|
selectFieldWithFirstOrLastCharacter: true,
|
||||||
|
applyBreakingRules: true,
|
||||||
|
doNotWrapTextWithPunctuation: true,
|
||||||
|
doNotUseEastAsianBreakRules: true,
|
||||||
|
useWord2002TableStyleRules: true,
|
||||||
|
growAutofit: true,
|
||||||
|
useFELayout: true,
|
||||||
|
useNormalStyleForList: true,
|
||||||
|
doNotUseIndentAsNumberingTabStop: true,
|
||||||
|
useAlternateEastAsianLineBreakRules: true,
|
||||||
|
allowSpaceOfSameStyleInTable: true,
|
||||||
|
doNotSuppressIndentation: true,
|
||||||
|
doNotAutofitConstrainedTables: true,
|
||||||
|
autofitToFirstFixedWidthCell: true,
|
||||||
|
underlineTabInNumberingList: true,
|
||||||
|
displayHangulFixedWidth: true,
|
||||||
|
splitPgBreakAndParaMark: true,
|
||||||
|
doNotVerticallyAlignCellWithSp: true,
|
||||||
|
doNotBreakConstrainedForcedTable: true,
|
||||||
|
ignoreVerticalAlignmentInTextboxes: true,
|
||||||
|
useAnsiKerningPairs: true,
|
||||||
|
cachedColumnBalance: true,
|
||||||
|
},
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [new TextRun("Hello World")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
116
demo/77-side-by-side-tables.ts
Normal file
116
demo/77-side-by-side-tables.ts
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// Exporting the document as a stream
|
||||||
|
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, Table, TableBorders, TableCell, TableRow, WidthType } from "docx";
|
||||||
|
|
||||||
|
const table1 = 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: [3505, 5505],
|
||||||
|
rows: [
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
width: {
|
||||||
|
size: 3505,
|
||||||
|
type: WidthType.DXA,
|
||||||
|
},
|
||||||
|
children: [new Paragraph("Foo")],
|
||||||
|
}),
|
||||||
|
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("Bar")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const noBorderTable = new Table({
|
||||||
|
borders: TableBorders.NONE,
|
||||||
|
rows: [
|
||||||
|
new TableRow({
|
||||||
|
children: [
|
||||||
|
new TableCell({
|
||||||
|
children: [table1],
|
||||||
|
}),
|
||||||
|
new TableCell({
|
||||||
|
children: [table2],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
properties: {},
|
||||||
|
children: [noBorderTable],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const stream = Packer.toStream(doc);
|
||||||
|
stream.pipe(fs.createWriteStream("My Document.docx"));
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user