forked from bpampuch/pdfmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtextDecorations.js
50 lines (41 loc) · 1.38 KB
/
textDecorations.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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);
var ct = [];
ct.push({ text: 'Higlighted text', fontSize: 18, background: 'yellow' });
ct.push(' ');
ct.push({
columns: [
{ text: 'Underline decoration', decoration: 'underline' },
{ text: 'Line Through decoration', decoration: 'lineThrough' },
{ text: 'Overline decoration', decoration: 'overline' }
]
});
ct.push(' ');
ct.push({
columns: [
{ text: 'Dashed style', decoration: 'underline', decorationStyle: 'dashed' },
{ text: 'Dotted style', decoration: 'underline', decorationStyle: 'dotted' },
{ text: 'Double style', decoration: 'underline', decorationStyle: 'double' },
{ text: 'Wavy style', decoration: 'underline', decorationStyle: 'wavy' }
]
});
ct.push(' ');
ct.push({
columns: [
{ text: 'Using colors', decoration: 'underline', decorationColor: 'blue' },
{ text: 'Using colors', decoration: 'lineThrough', decorationColor: 'red' },
{ text: 'Using colors', decoration: 'underline', decorationStyle: 'wavy', decorationColor: 'green' }
]
});
var docDefinition = {
content: ct
};
var now = new Date();
var pdf = pdfmake.createPdf(docDefinition);
pdf.write('pdfs/textDecorations.pdf').then(() => {
console.log(new Date() - now);
}, err => {
console.error(err);
});