-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid-layout-example.js
More file actions
70 lines (63 loc) · 1.69 KB
/
Copy pathgrid-layout-example.js
File metadata and controls
70 lines (63 loc) · 1.69 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const fs = require('fs');
const { Container, Page, Text } = require('../src/components/index.js');
const { PageSize, Alignment } = require('../src/components/enums/index.js');
const { Border, Offset } = require('../src/components/models/index.js');
const ReplyPDF = require('../src/reply-pdf.js');
const GridLayout = require('../src/components/grid-layout.js');
module.exports = {
generate: () => {
const countChildren = [];
for (var i = 0; i < 5; i++) {
countChildren.push(
new Container({
margin: new Offset(10),
border: new Border(),
children: [
new Text({
margin: new Offset(10),
text: `Item: ${i}`,
fontSize: 20
}),
]
})
);
}
const template = new Page({
size: PageSize.A4,
margin: new Offset(50),
header: new Container({
height: 50,
children: [
new Text({
text: 'Sample PDF document - Grid Layout',
}),
],
}),
footer: new Container({
height: 50,
children: [
new Text({
verticalAlignment: Alignment.end,
horizontalAlignment: Alignment.end,
fontSize: 10,
text: 'Page {{pageNumber}} of {{pageCount}}',
}),
],
}),
children: [
new GridLayout({
columns: 3,
children: countChildren
})
]
});
const data = {};
let doc = ReplyPDF.generateDocument({
data: data,
template: template,
debug: false,
});
doc.pipe(fs.createWriteStream('examples/outputs/output-grid-layout-example.pdf'));
doc.end();
}
}