-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
demo27.js
140 lines (131 loc) · 4.74 KB
/
demo27.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
"use strict";
const ReportBuilder = require('../lib/fluentReportsBuilder').ReportBuilder;
const displayReport = require('./reportDisplayer');
const data = JSON.parse('[{"name":"Everywhere","hotkeys":[{"keys1":"WinKey","help1":"Tap to show Start","keys2":"CTRL-F4","help2":"Close Panels & Menus"},{"keys1":"?","help1":"Bring up this help","keys2":"ALT+F4","help2":"Quit Application"},{"keys1":"ALT+TAB","help1":"Cycle through Applications","keys2":"Ctrl+Space","help2":"Toggle the App Menu"},{"keys1":"Win+L","help1":"Lock Screen","keys2":"","help2":""}]},{"name":"More navigation","hotkeys":[{"keys1":"Ctrl+Shift-Esc","help1":"Task Manager","keys2":"Alt+Print Screen","help2":"Take Snapshot"}]}]');
const reportData = {
"type": "report",
"fontSize": 8,
"autoPrint": false,
"name": "demo27.pdf",
"paperSize": "letter",
"paperOrientation": "portrait",
"margins": {
"left": 40,
"top": 40,
"right": 40,
"bottom": 40
},
"fonts": [],
"variables": {},
"subReports": [
{
"dataUUID": 10003,
"dataType": "parent",
"data": "hotkeys",
"type": "report",
"detail": [
{
"settings": {
"fillOpacity": 1,
"absoluteX": 1,
"absoluteY": 0,
"border": 1,
"wrap": true,
"padding": 4
},
"type": "band",
"fields": [
{
"field": "keys1",
"width": 100,
"align": 3
},
{
"function": {
"name": "Band Function",
"type": "function",
"async": false,
"function": "return (data.keys1 ? `:` : ``)"
},
"width": 15,
"align": 2
},
{
"field": "help1",
"width": 150
},
{
"field": "keys2",
"width": 100,
"align": 3
},
{
"function": {
"name": "Band Function",
"type": "function",
"async": false,
"function": "return (data.keys2 ? `:` : ``)"
},
"width": 15,
"align": 2
},
{
"field": "help2",
"width": 150
}
]
}
]
}
],
"titleHeader": [
{
"type": "raw",
"values": [
"Windows Keyboard Shortcuts"
]
}
],
"groupBy": [
{
"type": "group",
"groupOn": "name",
"header": [
{
"field": "name",
"settings": {
"absoluteX": 0,
"absoluteY": 0,
"fontSize": 10,
"fontBold": true,
"align": "center"
},
"type": "print"
}
],
"footer": [
{
"thickness": 0.5,
"type": "bandLine"
},
{
"type": "newLine"
}
]
}
]
};
let rpt = new ReportBuilder(reportData, data);
// These two lines are not normally needed for any normal reports unless you want to use your own fonts...
// We need to add this because of TESTING and making the report consistent for CI environments
rpt.registerFont("Arimo", {normal: __dirname+'/Fonts/Arimo-Regular.ttf', bold: __dirname+'/Fonts/Arimo-Bold.ttf', 'italic': __dirname+'/Fonts/Arimo-Italic.ttf'})
.font("Arimo");
if (typeof process.env.TESTING === "undefined") { rpt.printStructure(); }
console.time("Rendered");
rpt.render().then((name) => {
console.timeEnd("Rendered");
const testing = {images: 1, blocks: ["60,60,180,70"]};
displayReport(null, name, testing);
}).catch((err) => {
console.error("Your report had errors while running", err);
});