-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-font-example.js
More file actions
62 lines (59 loc) · 2.02 KB
/
Copy pathcustom-font-example.js
File metadata and controls
62 lines (59 loc) · 2.02 KB
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
const fs = require('fs');
const { Page, StackVertical, Text } = require('../src/components/index.js');
const { PageSize, FontWeight } = require('../src/components/enums/index.js');
const { Offset } = require('../src/components/models/index.js');
const ReplyPDF = require('../src/reply-pdf.js');
module.exports = {
generate: () => {
const template = new Page({
size: PageSize.A4,
margin: new Offset(50),
children: [
new StackVertical({
children: [
new Text({
margin: new Offset(10),
fontFamily: 'Robinette',
fontSize: 30,
text: 'This is robinette font',
}),
new Text({
margin: new Offset(10),
fontFamily: 'GrandAutoDemo',
text: 'This is grand auto demo font',
}),
new Text({
margin: new Offset(10),
fontFamily: 'GrandAutoDemo',
text: 'This is grand auto demo font in italic',
italic: true,
}),
new Text({
margin: new Offset(10),
fontFamily: 'PlayfairDisplay',
text: 'This is playfair dispay font',
}),
new Text({
margin: new Offset(10),
fontFamily: 'PlayfairDisplay',
fontWeight: FontWeight.bold,
text: 'This is playfair dispay font in bold',
}),
],
})
],
});
let doc = ReplyPDF.generateDocument({
fonts: {
'Robinette': fs.readFileSync('examples/fonts/Robinette.ttf'),
'GrandAutoDemo': fs.readFileSync('examples/fonts/GrandAutoDemoRegular.ttf'),
'PlayfairDisplay': fs.readFileSync('examples/fonts/PlayfairDisplay-Regular.ttf'),
'PlayfairDisplay-Bold': fs.readFileSync('examples/fonts/PlayfairDisplay-Bold.ttf'),
},
template: template,
debug: false,
});
doc.pipe(fs.createWriteStream('examples/outputs/output-custom-font-example.pdf'));
doc.end();
}
}