-
Notifications
You must be signed in to change notification settings - Fork 44
/
test.js
65 lines (60 loc) · 1.01 KB
/
test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var pdf = require('./index');
let htm_template = `<!DOCTYPE html>
<html>
<head>
<mate charest="utf-8" />
<title>Hello world!</title>
</head>
<body>
<h1>User List</h1>
<ul>
{{#each users}}
<li>Name: {{this.name}}</li>
<li>Age: {{this.age}}</li>
<br />
{{/each}}
</ul>
</body>
</html>`;
var options = {
format: 'A3',
orientation: 'portrait',
border: '10mm',
header: {
height: '45mm',
contents: '<div style="text-align: center;">Author: Shyam Hajare</div>'
},
footer: {
height: '28mm',
contents: {
first: 'Cover page',
2: 'Second page', // Any page number is working. 1-based index
default:
'<span style="color: #444;">{{page}}</span>/<span>{{pages}}</span>', // fallback value
last: 'Last Page'
}
}
};
let users = [
{
name: 'tom',
age: '26'
},
{
name: 'dick',
age: '26'
},
{
name: 'harry',
age: '26'
}
];
let doc = {
html: htm_template,
data: {
users: users
},
type: 'pdf',
path: './output.pdf'
};
pdf(doc, options);