-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinding-example.js
More file actions
54 lines (50 loc) · 1.26 KB
/
Copy pathbinding-example.js
File metadata and controls
54 lines (50 loc) · 1.26 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
const fs = require('fs');
const { Container, Page, StackVertical, Text } = require('../src/components/index.js');
const { PageSize } = 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 Container({
binding: 'tier1',
children: [
new StackVertical({
binding: 'tier2',
children: [
new Text({
binding: 'tier3.tier4',
margin: new Offset(10),
text: 'date = {{tier5.date}}',
}),
],
}),
],
}),
],
});
const data = {
tier1: {
tier2: {
tier3: {
tier4: {
tier5: {
date: new Date(),
}
}
}
}
}
};
let doc = ReplyPDF.generateDocument({
data: data,
template: template,
debug: false,
});
doc.pipe(fs.createWriteStream('examples/outputs/output-binding-example.pdf'));
doc.end();
}
}