-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.ts
39 lines (37 loc) · 1007 Bytes
/
example.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
/* istanbul ignore file */
import { DocxGenerator } from '../src';
import * as fs from 'fs';
import { AlignmentType, NumberFormat } from 'docx';
import { PageFormat } from '../src/options';
const main = async () => {
console.time('Loading');
const docxGenerator = new DocxGenerator({
page: {
size: PageFormat.A5,
numbering: { type: NumberFormat.DECIMAL, align: AlignmentType.END },
margins: {
top: 20,
left: 15,
right: 15,
bottom: 15,
},
},
font: {
baseFontFamily: 'Times New Roman',
headersFontFamily: 'Times New Roman',
baseSize: 12,
headersSizes: {
h1: 16,
h2: 14,
h3: 12,
},
},
ignoreIndentation: true,
verticalSpaces: 1.15,
});
const exampleText = fs.readFileSync('./example/exampleText.html', 'utf8');
const buffer = await docxGenerator.generateDocx(exampleText);
console.timeEnd('Loading');
fs.writeFileSync('test-lib.docx', buffer);
};
void main();