-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
103 lines (84 loc) · 3.32 KB
/
index.html
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
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<meta name="description" content="">
</head>
<body>
<p>PDF MAKE - CUSTOM FONTS</p>
<button onclick="print()">Print PDF</button>
<script src="./pdfmake.min.js"></script>
<script src="./vfs_fonts.js"></script>
<script>
function print() {
pdfMake.fonts = {
Roboto: {
normal: 'Roboto-Regular.ttf',
bold: 'Roboto-Medium.ttf',
italics: 'Roboto-Italic.ttf',
bolditalics: 'Roboto-MediumItalic.ttf'
},
OpenSans: {
normal: 'OpenSans-Regular.ttf',
bold: 'OpenSans-Bold.ttf',
italics: 'OpenSans-Italic.ttf',
bolditalics: 'OpenSans-BoldItalic.ttf'
},
FontawesomeRegular: {
normal: 'fa-regular-400.ttf',
bold: 'fa-regular-400.ttf',
italics: 'fa-regular-400.ttf',
bolditalics: 'fa-regular-400.ttf'
},
FontawesomeSolid: {
normal: 'fa-solid-900.ttf',
bold: 'fa-solid-900.ttf',
italics: 'fa-solid-900.ttf',
bolditalics: 'fa-solid-900.ttf'
},
FontawesomeBrands: {
normal: 'fa-brands-400.ttf',
bold: 'fa-brands-400.ttf',
italics: 'fa-brands-400.ttf',
bolditalics: 'fa-brands-400.ttf'
}
}
var docDefinition = {
content: [
{ text: 'Roboto font', font: 'Roboto' },
{ text: 'Roboto font (bold)', font: 'Roboto', bold: true },
{ text: 'OpenSans font ', font: 'OpenSans' },
{ text: 'OpenSans font (bold)', font: 'OpenSans', bold: true },
{ text: '', font: 'FontawesomeRegular' },
{ text: '', font: 'FontawesomeRegular', fontSize: 32 },
{ text: '', font: 'FontawesomeSolid' },
{ text: '', font: 'FontawesomeSolid', color: 'red' },
{
text: [
{ text: 'This is an icon in the text ', font: 'OpenSans' },
{ text: '', font: 'FontawesomeSolid' },
{ text: ' blablabla', font: 'OpenSans' },
]
},
// using styles
{ text: 'Paragraph using styles formating', style: 'body' },
{ text: '', style: 'symbol' },
],
styles: {
symbol: {
font: 'FontawesomeRegular',
fontSize: 12
},
body: {
font: 'OpenSans',
fontSize: 12
}
}
}
pdfMake.createPdf(docDefinition).download('test.pdf');
}
</script>
</body>
</html>