deno.land / x / docx@8.5.0 / demo / 73-comments.ts

73-comments.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// 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);});
docx

Version Info

Tagged at
4 months ago