deno.land / x / docx@8.5.0 / demo / 46-shading-text.ts

46-shading-text.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
// Shading text
import * as fs from "fs";import { AlignmentType, Document, Header, Packer, Paragraph, ShadingType, TextRun } from "docx";
const doc = new Document({ sections: [ { headers: { default: new Header({ children: [ new Paragraph({ alignment: AlignmentType.RIGHT, children: [ new TextRun({ text: "Hello World", color: "FF0000", bold: true, size: 24, font: { name: "Garamond", }, shading: { type: ShadingType.REVERSE_DIAGONAL_STRIPE, color: "00FFFF", fill: "FF0000", }, }), ], }), new Paragraph({ shading: { type: ShadingType.DIAGONAL_CROSS, color: "00FFFF", fill: "FF0000", }, children: [ new TextRun({ text: "Hello World for entire paragraph", }), ], }), ], }), }, children: [ new Paragraph({ children: [ new TextRun({ emboss: true, text: "Embossed text - hello world", }), new TextRun({ imprint: true, text: "Imprinted text - hello world", }), ], }), ], }, ],});
Packer.toBuffer(doc).then((buffer) => { fs.writeFileSync("My Document.docx", buffer);});
docx

Version Info

Tagged at
4 months ago