deno.land / x / docx@8.5.0 / demo / 90-check-boxes.ts

90-check-boxes.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
// Simple example to add check boxes to a documentimport * as fs from "fs";import { Document, Packer, Paragraph, TextRun, CheckBox } from "docx";
const doc = new Document({ sections: [ { properties: {}, children: [ new Paragraph({ children: [ new TextRun("Hello World"), new TextRun({ break: 1 }), new CheckBox(), new TextRun({ break: 1 }), new CheckBox({ checked: true }), new TextRun({ break: 1 }), new CheckBox({ checked: true, checkedState: { value: "2611" } }), new TextRun({ break: 1 }), new CheckBox({ checked: true, checkedState: { value: "2611", font: "MS Gothic" } }), new TextRun({ break: 1 }), new CheckBox({ checked: true, checkedState: { value: "2611", font: "MS Gothic" }, uncheckedState: { value: "2610", font: "MS Gothic" }, }), new TextRun({ break: 1 }), new CheckBox({ checked: true, checkedState: { value: "2611", font: "MS Gothic" }, uncheckedState: { value: "2610", font: "MS Gothic" }, }), new TextRun({ text: "Are you ok?", break: 1 }), new CheckBox({ checked: true, alias: "Are you ok?" }), ], }), ], }, ],});
Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("My Document.docx", buffer);});
docx

Version Info

Tagged at
4 months ago