-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathdemo22.js
180 lines (167 loc) · 13.4 KB
/
demo22.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
"use strict";
const ReportBuilder = require('../lib/fluentReportsBuilder').ReportBuilder;
const displayReport = require('./reportDisplayer');
const data = [
{
"date": "01/01/2020",
"items": [
{
"group": 1,
"number": 1,
"blah": [
{"hi": 11},
{"hi": 12}
]
},
{
"group": 2,
"number": 2,
"blah": [
{"hi": 22},
{"hi": 23}
]
}
],
"itemsold": [
{
"group": 3,
"number": 3,
"blah2": [
{"hi": 33},
{"hi": 34}
]
},
{
"group": 4,
"number": 4,
"blah2": [
{"hi": 44},
{"hi": 45}
]
}
]
}
];
// Reports can have multiple States; by default they have one State, so all states will be directed to this value
// However, a specific "type" can have its own state; called "state: <number>"
// All functions that are created should be "function (report, data, state, vars)"
let reportData =
{
"type": "report",
"dataUUID": 10002,
"fontSize": 0,
"autoPrint": false,
"name": "demo22.pdf",
"paperSize": "letter",
"paperOrientation": "portrait",
"fonts": [],
"variables": {},
"subReports": [
{
"dataUUID": 10003,
"dataType": "parent",
"data": "items",
"subReports": [
{
"dataUUID": 10004,
"dataType": "parent",
"data": "blah",
"type": "report",
"detail": [
{
"text": "Subreport items/blah Data",
"settings": {
"align": 0
},
"type": "print"
}
]
}
],
"type": "report",
"header": [
{
"field": "group",
"settings": {
"addY": 1
},
"type": "print"
}
]
},
{
"dataUUID": 10005,
"dataType": "parent",
"data": "itemsold",
"subReports": [
{
"dataUUID": 10006,
"dataType": "parent",
"data": "blah2",
"type": "report",
"detail": [
{
"text": "Subreport itemsold/blah2 Data",
"settings": {
"align": 0
},
"type": "print"
}
]
}
],
"type": "report",
"header": [
{
"field": "group",
"settings": {
"addX": 5,
"addY": 1,
"align": 0
},
"type": "print"
}
]
}
],
"header": [
{
"type": "raw",
"values": [
"Sample Header"
]
},
{
"image": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPAAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8AAEQgAbgDIAwERAAIRAQMRAf/EAKgAAQACAgMBAAAAAAAAAAAAAAAGBwQFAQIIAwEBAAIDAQEAAAAAAAAAAAAAAAQFAgMGAQcQAAEDAwIEBAQEAwQLAAAAAAECAwQAEQUSBiExEwdBUSIUYXEVCJEyIxaBUhdCcjMkocHR8WJDU3OTdBgRAAIBAwEFBAcHBAMBAAAAAAABAhEDBBIhMUFRBWFxIgaBkaGxMkIT8MHR4VIjFPFicjOCohUW/9oADAMBAAIRAxEAPwD1TQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUB8WZbD2rQq4SooJ+I51FxMy3fUnB1UZOPpW8znBx3iXI9vGcetfQL2NauqZcsbHndiquCrQ9tQ1SS5mmO5ze2lHHkOP+2vnv/wBzl71bhT/l+JP/AIC5mTF3FFdWlt2yFq5ceBrrvL3X1nxkpR0XIb1wafFEXIx3b7mb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Wtbi0gqWV/67gWxQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAKAUAoBQCgFAf//Z",
"settings": {
"aspect": "size",
"width": 100,
"height": 50
},
"type": "image"
}
],
"footer": [
{
"type": "raw",
"values": [
"Sample Footer"
]
}
]
};
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");
// Print Structure in Demo Mode
if (typeof process.env.TESTING === "undefined") { rpt.printStructure(); }
console.time("Rendered");
rpt.render().then((name) => {
console.timeEnd("Rendered");
const testing = {images: 1};
displayReport(null, name, testing);
}).catch((err) => {
console.error("Your report had errors while running", err);
});