-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathdemo14.js
77 lines (53 loc) · 1.9 KB
/
demo14.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
66
67
68
69
70
71
72
73
74
75
76
77
"use strict";
const Report = require('../lib/fluentReports' ).Report;
const displayReport = require('./reportDisplayer');
const data = {
today: "Today",
tomorrow: "Tomorrow",
meta:
{ high: "85", low: '50' }
};
function printreport() {
const header = function(rpt, row) {
//rpt.font(Report.fonts.times);
//rpt.fontBold();
// Again CI hates the built in fonts as they render slightly differently...
// Example: "font:" on next line was "Report.fonts.times"
rpt.print("Today is "+row.today, {font: "Arimo"});
rpt.fontBold();
rpt.print("Tomorrow is "+row.tomorrow);
rpt.fontNormal();
};
const subDetail = function(rpt, row){
rpt.band([
{data: "high", width: 240},
{data: row.high, width: 60, align: 3},
], {x: 30});
rpt.band([
{data: "low", width: 240},
{data: row.low, width: 60, align: 3},
], {x: 30});
};
const subHeader = function(rpt) {
rpt.print("Sub Report Header");
};
const reportName = __dirname + "/demo14.pdf";
const report = new Report(reportName, {font: "Arimo"})
.registerFont("Arimo", {normal: __dirname+'/Fonts/Arimo-Regular.ttf', bold: __dirname+'/Fonts/Arimo-Bold.ttf', 'italic': __dirname+'/Fonts/Arimo-Italic.ttf'})
.data(data)
.pageHeader(["Daily Report"])
.header(header)
.footer("main footer");
// Adding sub-report
new Report(report)
.data(data.meta)
.detail(subDetail)
.pageheader(subHeader)
.pagefooter("footer");
if (typeof process.env.TESTING === "undefined") { report.printStructure(); }
report.render((err, name) => {
const testing = {images: 1, blocks: ["120,130,300,100"]};
displayReport(err, name, testing);
});
}
printreport();