-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathbasics.js
33 lines (28 loc) · 843 Bytes
/
basics.js
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
var pdfmake = require('../js/index'); // only during development, otherwise use the following line
//var pdfmake = require('pdfmake');
var Roboto = require('../fonts/Roboto');
pdfmake.addFonts(Roboto);
// or you can define the font manually:
/*
pdfmake.addFonts({
Roboto: {
normal: '../fonts/Roboto/Roboto-Regular.ttf',
bold: '../fonts/Roboto/Roboto-Medium.ttf',
italics: '../fonts/Roboto/Roboto-Italic.ttf',
bolditalics: '../fonts/Roboto/Roboto-MediumItalic.ttf'
}
});
*/
var docDefinition = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
]
};
var now = new Date();
var pdf = pdfmake.createPdf(docDefinition);
pdf.write('pdfs/basics.pdf').then(() => {
console.log(new Date() - now);
}, err => {
console.error(err);
});