@measurequick/measurequick-report-generator 1.4.29 → 1.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/report-gen-scripts/acca-certificate.js +2 -4
- package/report-gen-scripts/bluvac-report.js +6 -6
- package/report-gen-scripts/classic-report.js +1 -1
- package/report-gen-scripts/corrective-measures.js +10 -11
- package/report-gen-scripts/cover-page.js +2 -4
- package/report-gen-scripts/energy-star-certificate.js +2 -4
- package/report-gen-scripts/franklin-energy-report.js +3 -2
- package/report-gen-scripts/full-report.js +14 -38
- package/report-gen-scripts/measurement-details-acca.js +6 -5
- package/report-gen-scripts/measurement-details.js +8 -7
- package/report-gen-scripts/photos-report-s3.js +11 -16
- package/report-gen-scripts/photos-report.js +115 -118
- package/report-gen-scripts/ptcs-heat-pump-report.js +20 -25
- package/report-gen-scripts/sign-terms-conditions.js +12 -17
- package/report-gen-scripts/system-info-page.js +11 -11
- package/report-gen-scripts/vitals-cooling-report.js +197 -199
- package/report-gen-scripts/vitals-heating-report.js +2 -4
package/package.json
CHANGED
|
@@ -23,8 +23,6 @@ export async function getReport(payload) {
|
|
|
23
23
|
// flatten and return as base64
|
|
24
24
|
form.flatten();
|
|
25
25
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
26
|
-
return
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return { code: 400, error: error };
|
|
29
|
-
}
|
|
26
|
+
return pdfBase64;
|
|
27
|
+
} catch (error) { }
|
|
30
28
|
}
|
|
@@ -6,10 +6,10 @@ import * as util from '../util.js';
|
|
|
6
6
|
|
|
7
7
|
export async function getReport(payload) {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const pdfDoc = await PDFDocument.load(util._base64ToArrayBuffer(payload.meta.base64));
|
|
10
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
11
|
+
return pdfBase64;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
15
|
}
|
|
@@ -97,12 +97,12 @@ export async function getReport(payload) {
|
|
|
97
97
|
|
|
98
98
|
/** START CORRECTIVE ACTIONS **/
|
|
99
99
|
let header,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
text = "",
|
|
101
|
+
col = 1,
|
|
102
|
+
maxWidth = 165,
|
|
103
|
+
maxHeight = 362,
|
|
104
|
+
maxLines = Math.floor(maxHeight / font.heightAtSize(8)) - 3,
|
|
105
|
+
numLines = 1;
|
|
106
106
|
for (let i = 0; i < payload.system_data.block3.length && col < 7; i++) {
|
|
107
107
|
let action = payload.system_data.block3[i];
|
|
108
108
|
if (header != action.ref) {
|
|
@@ -128,9 +128,8 @@ export async function getReport(payload) {
|
|
|
128
128
|
/** END CORRECTIVE ACTIONS **/
|
|
129
129
|
|
|
130
130
|
form.flatten();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
131
|
+
return await pdfDoc.saveAsBase64({
|
|
132
|
+
dataUri: true
|
|
133
|
+
});
|
|
134
|
+
} catch (error) { console.log(error) }
|
|
136
135
|
}
|
|
@@ -32,8 +32,6 @@ export async function getReport(payload) {
|
|
|
32
32
|
} else if (companyImage) form.getButton("Company Logo Full").setImage(companyImage);
|
|
33
33
|
form.flatten();
|
|
34
34
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
35
|
-
return
|
|
36
|
-
} catch (error) {
|
|
37
|
-
return { code: 400, error: error };
|
|
38
|
-
}
|
|
35
|
+
return pdfBase64;
|
|
36
|
+
} catch (error) { }
|
|
39
37
|
}
|
|
@@ -26,8 +26,6 @@ export async function getReport(payload) {
|
|
|
26
26
|
// flatten and return as base64
|
|
27
27
|
form.flatten();
|
|
28
28
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
29
|
-
return
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return { code: 400, error: error };
|
|
32
|
-
}
|
|
29
|
+
return pdfBase64;
|
|
30
|
+
} catch (error) { }
|
|
33
31
|
}
|
|
@@ -22,8 +22,9 @@ export async function getReport(payload) {
|
|
|
22
22
|
// flatten and return as base64
|
|
23
23
|
form.flatten();
|
|
24
24
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
25
|
-
return
|
|
25
|
+
return pdfBase64;
|
|
26
26
|
} catch (error) {
|
|
27
|
-
|
|
27
|
+
console.log(error);
|
|
28
|
+
return error;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -26,9 +26,7 @@ export async function getReport(payload) {
|
|
|
26
26
|
const coverPageDoc = coverPageBase64 ? await PDFDocument.load(util._base64ToArrayBuffer(coverPageBase64)) : false;
|
|
27
27
|
const [_coverPageDoc] = coverPageDoc ? await coreDoc.copyPages(coverPageDoc, [0]) : false;
|
|
28
28
|
if (_coverPageDoc) coreDoc.insertPage(coreDoc.getPages().length, _coverPageDoc);
|
|
29
|
-
} catch (
|
|
30
|
-
return { code: 400, error: error };
|
|
31
|
-
}
|
|
29
|
+
} catch (e) { }
|
|
32
30
|
|
|
33
31
|
/******** TEST IN VITALS (2 PAGES) *********/
|
|
34
32
|
try {
|
|
@@ -58,9 +56,7 @@ export async function getReport(payload) {
|
|
|
58
56
|
coreDoc.insertPage(coreDoc.getPages().length, _vitalsReportPg1);
|
|
59
57
|
coreDoc.insertPage(coreDoc.getPages().length, _vitalsReportPg2);
|
|
60
58
|
}
|
|
61
|
-
} catch (
|
|
62
|
-
return { code: 400, error: error };
|
|
63
|
-
}
|
|
59
|
+
} catch (e) { }
|
|
64
60
|
|
|
65
61
|
/******** TEST IN MEASUREMENTS (1 PAGE) *********/
|
|
66
62
|
try {
|
|
@@ -68,9 +64,7 @@ export async function getReport(payload) {
|
|
|
68
64
|
const measurementDetailsDoc = measurementDetailsBase64 ? await PDFDocument.load(util._base64ToArrayBuffer(measurementDetailsBase64)) : false;
|
|
69
65
|
const [_measurementDetailsDoc] = measurementDetailsDoc ? await coreDoc.copyPages(measurementDetailsDoc, [0]) : false;
|
|
70
66
|
if (_measurementDetailsDoc) coreDoc.insertPage(coreDoc.getPages().length, _measurementDetailsDoc);
|
|
71
|
-
} catch (
|
|
72
|
-
return { code: 400, error: error };
|
|
73
|
-
}
|
|
67
|
+
} catch (e) { }
|
|
74
68
|
|
|
75
69
|
/******** TEST IN ACCA MEASUREMENTS (1 PAGE) *********/
|
|
76
70
|
try {
|
|
@@ -80,9 +74,7 @@ export async function getReport(payload) {
|
|
|
80
74
|
const [_measurementDetailsAccaDoc] = measurementDetailsAccaDoc ? await coreDoc.copyPages(measurementDetailsAccaDoc, [0]) : false;
|
|
81
75
|
if (_measurementDetailsAccaDoc) coreDoc.insertPage(coreDoc.getPages().length, _measurementDetailsAccaDoc);
|
|
82
76
|
}
|
|
83
|
-
} catch (
|
|
84
|
-
return { code: 400, error: error };
|
|
85
|
-
}
|
|
77
|
+
} catch (e) { }
|
|
86
78
|
|
|
87
79
|
/******** TEST OUT VITALS (2 PAGES) *********/
|
|
88
80
|
try {
|
|
@@ -95,9 +87,7 @@ export async function getReport(payload) {
|
|
|
95
87
|
coreDoc.insertPage(coreDoc.getPages().length, _vitalsReportPg1);
|
|
96
88
|
coreDoc.insertPage(coreDoc.getPages().length, _vitalsReportPg2);
|
|
97
89
|
}
|
|
98
|
-
} catch (
|
|
99
|
-
return { code: 400, error: error };
|
|
100
|
-
}
|
|
90
|
+
} catch (e) { }
|
|
101
91
|
|
|
102
92
|
/******** TEST OUT MEASUREMENTS (1 PAGE) *********/
|
|
103
93
|
try {
|
|
@@ -107,9 +97,7 @@ export async function getReport(payload) {
|
|
|
107
97
|
const [_measurementDetailsDocPg2] = measurementDetailsDoc ? await coreDoc.copyPages(measurementDetailsDoc, [1]) : false;
|
|
108
98
|
if (_measurementDetailsDocPg2) coreDoc.insertPage(coreDoc.getPages().length, _measurementDetailsDocPg2);
|
|
109
99
|
}
|
|
110
|
-
} catch (
|
|
111
|
-
return { code: 400, error: error };
|
|
112
|
-
}
|
|
100
|
+
} catch (e) { }
|
|
113
101
|
|
|
114
102
|
/******** TEST OUT ACCA MEASUREMENTS (1 PAGE) *********/
|
|
115
103
|
try {
|
|
@@ -119,9 +107,7 @@ export async function getReport(payload) {
|
|
|
119
107
|
const [_measurementDetailsAccaDocPg2] = measurementDetailsAccaDoc ? await coreDoc.copyPages(measurementDetailsAccaDoc, [1]) : false;
|
|
120
108
|
if (_measurementDetailsAccaDocPg2) coreDoc.insertPage(coreDoc.getPages().length, _measurementDetailsAccaDocPg2);
|
|
121
109
|
}
|
|
122
|
-
} catch (
|
|
123
|
-
return { code: 400, error: error };
|
|
124
|
-
}
|
|
110
|
+
} catch (e) { }
|
|
125
111
|
|
|
126
112
|
/******** ACCA / ESVI CERTIFICATES (1 PAGE) *********/
|
|
127
113
|
try {
|
|
@@ -138,9 +124,7 @@ export async function getReport(payload) {
|
|
|
138
124
|
if (_accaCertificateDoc) coreDoc.insertPage(coreDoc.getPages().length, _accaCertificateDoc);
|
|
139
125
|
}
|
|
140
126
|
}
|
|
141
|
-
} catch (
|
|
142
|
-
return { code: 400, error: error };
|
|
143
|
-
}
|
|
127
|
+
} catch (e) { }
|
|
144
128
|
|
|
145
129
|
/******** BLUVAC REPORT (1 PAGE) *********/
|
|
146
130
|
if (payload.project.evacuation_pdf && payload.meta.pdf_settings.includeBluvacReport) {
|
|
@@ -149,9 +133,7 @@ export async function getReport(payload) {
|
|
|
149
133
|
const bluvacReportDoc = bluvacReportBase64 ? await PDFDocument.load(util._base64ToArrayBuffer(bluvacReportBase64)) : false;
|
|
150
134
|
const [_bluvacReportDoc] = bluvacReportDoc ? await coreDoc.copyPages(bluvacReportDoc, [0]) : false;
|
|
151
135
|
if (_bluvacReportDoc) coreDoc.insertPage(coreDoc.getPages().length, _bluvacReportDoc);
|
|
152
|
-
} catch (
|
|
153
|
-
return { code: 400, error: error };
|
|
154
|
-
}
|
|
136
|
+
} catch (e) { }
|
|
155
137
|
}
|
|
156
138
|
|
|
157
139
|
/******** CORRECTIVE MEASURES (1-2 PAGES) *********/
|
|
@@ -165,9 +147,7 @@ export async function getReport(payload) {
|
|
|
165
147
|
if (_correctiveMeasuresDoc) coreDoc.insertPage(coreDoc.getPages().length, _correctiveMeasuresDoc);
|
|
166
148
|
if (_correctiveMeasuresDocPage2) coreDoc.insertPage(coreDoc.getPages().length, _correctiveMeasuresDocPage2);
|
|
167
149
|
} else if (_correctiveMeasuresDoc) coreDoc.insertPage(coreDoc.getPages().length, _correctiveMeasuresDoc);
|
|
168
|
-
} catch (
|
|
169
|
-
return { code: 400, error: error };
|
|
170
|
-
}
|
|
150
|
+
} catch (e) { }
|
|
171
151
|
}
|
|
172
152
|
|
|
173
153
|
/******** PHOTOS (X PAGES) *********/
|
|
@@ -179,9 +159,7 @@ export async function getReport(payload) {
|
|
|
179
159
|
const [_photosReport] = await coreDoc.copyPages(photosReportDoc, [i]);
|
|
180
160
|
coreDoc.insertPage(coreDoc.getPages().length, _photosReport);
|
|
181
161
|
}
|
|
182
|
-
} catch (
|
|
183
|
-
return { code: 400, error: error };
|
|
184
|
-
}
|
|
162
|
+
} catch (e) { }
|
|
185
163
|
|
|
186
164
|
/******** SYSTEM INFO (1 PAGE) *********/
|
|
187
165
|
try {
|
|
@@ -189,10 +167,8 @@ export async function getReport(payload) {
|
|
|
189
167
|
const systemInfoPageDoc = systemInfoPageBase64 ? await PDFDocument.load(util._base64ToArrayBuffer(systemInfoPageBase64)) : false;
|
|
190
168
|
const [_systemInfoPageDoc] = systemInfoPageDoc ? await coreDoc.copyPages(systemInfoPageDoc, [0]) : false;
|
|
191
169
|
if (_systemInfoPageDoc) coreDoc.insertPage(coreDoc.getPages().length, _systemInfoPageDoc);
|
|
192
|
-
} catch (
|
|
193
|
-
return { code: 400, error: error };
|
|
194
|
-
}
|
|
170
|
+
} catch (e) { }
|
|
195
171
|
|
|
196
|
-
|
|
197
|
-
return
|
|
172
|
+
let b64 = await coreDoc.saveAsBase64({ dataUri: true });
|
|
173
|
+
return b64;
|
|
198
174
|
}
|
|
@@ -154,6 +154,8 @@ export async function getReport(payload) { // DAVID TODO
|
|
|
154
154
|
form.getButton(`SSR${c + 1}`).setImage(icon);
|
|
155
155
|
c++;
|
|
156
156
|
}
|
|
157
|
+
// else if (val == true || val == 'true') form.getButton(`Block${blockNum}-Row${rowNum}-Col2-Icon`).setImage(embeddedIcons.iconRangeGreen);
|
|
158
|
+
// else if (val == false || val == 'false') form.getButton(`Block${blockNum}-Row${rowNum}-Col2-Icon`).setImage(embeddedIcons.iconRangeRed);
|
|
157
159
|
else form.getTextField(`Block${blockNum}-Row${rowNum}-Col2`).setText(`${val}`);
|
|
158
160
|
} else break;
|
|
159
161
|
}
|
|
@@ -167,9 +169,8 @@ export async function getReport(payload) { // DAVID TODO
|
|
|
167
169
|
pdfDocPg1.insertPage(1, secondPage);
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
172
|
+
return await pdfDocPg1.saveAsBase64({
|
|
173
|
+
dataUri: true
|
|
174
|
+
});
|
|
175
|
+
} catch (error) { console.log(error) }
|
|
175
176
|
}
|
|
@@ -155,7 +155,9 @@ export async function getReport(payload) {
|
|
|
155
155
|
if (!val) val = "--";
|
|
156
156
|
else if (measurement.fixTo && typeof val == 'number') val = val.toFixed(measurement.fixTo);
|
|
157
157
|
if ((measurement.label == 'Ambient CO' || measurement.label == 'Return CO' || measurement.label == 'Supply CO') && !measurement.value) val = '0.0';
|
|
158
|
+
//if (measurement.fixTo && typeof val == 'number') val = val.toFixed(measurement.fixTo);
|
|
158
159
|
if (typeof val == 'number' || !isNaN(val)) val = val.toLocaleString("en-US");
|
|
160
|
+
//else if (!isNaN(parseFloat(val))) val = parseFloat(val).toLocaleString("en-US");
|
|
159
161
|
if (measurement.fixTo && typeof val == 'number') val = val.toFixed(measurement.fixTo);
|
|
160
162
|
if (measurement.ref == 'co' || measurement.ref == 'o2' || measurement.ref == 'temperature_air' || measurement.ref == 'temperature_stack' || measurement.ref == 'coaf' || measurement.ref == 'excess_air' || measurement.ref == 'efficiency_gcv' || measurement.ref == 'efficiency_ncv' || measurement.ref == 'dew_point') val = measurement.value;
|
|
161
163
|
else if (measurement.ref == 'pressure_fuel' || measurement.ref == 'pressure_manifold' || measurement.ref == 'pressure_static_total_external' || measurement.ref == 'temperature_rise' || measurement.ref == 'temperature_rise_target' || measurement.ref == 'temperature_return' || measurement.ref == 'temperature_supply' || measurement.ref == 'airflow' || measurement.ref == 'gas_input_rated' || measurement.ref == 'gas_input_after' || measurement.ref == 'gas_output') val = measurement.value;
|
|
@@ -163,13 +165,13 @@ export async function getReport(payload) {
|
|
|
163
165
|
form.getTextField(`Block${blockNum}-Row${rowNum}-Col2${altLabel}`).setText(`${val}`);
|
|
164
166
|
if (blockNum != 4) {
|
|
165
167
|
let rangeIcon;
|
|
166
|
-
|
|
168
|
+
|
|
167
169
|
if (measurement.label == 'Ambient CO' || measurement.label == 'Return CO' || measurement.label == 'Supply CO') {
|
|
168
170
|
let v = measurement.value;
|
|
169
171
|
if (typeof v == 'string') v = parseFloat(v);
|
|
170
172
|
if (v > 9) rangeIcon = embeddedIcons.iconRangeHigh;
|
|
171
173
|
} else rangeIcon = util.getRangeIcon(test, measurement.ref, embeddedIcons);
|
|
172
|
-
|
|
174
|
+
|
|
173
175
|
if (rangeIcon && payload.meta.pdf_settings.includeRangeIndicators) form.getButton(`Block${blockNum}-Row${rowNum}-Col3`).setImage(rangeIcon);
|
|
174
176
|
let toolIcon = false;
|
|
175
177
|
if (measurement.ref == "superheat" || measurement.ref == "subcooling" || measurement.ref == "compression_ratio" || measurement.ref == "airflow_estimated") toolIcon = embeddedIcons.iconCalculator;
|
|
@@ -194,9 +196,8 @@ export async function getReport(payload) {
|
|
|
194
196
|
pdfDocPg1.insertPage(1, secondPage);
|
|
195
197
|
}
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
199
|
+
return await pdfDocPg1.saveAsBase64({
|
|
200
|
+
dataUri: true
|
|
201
|
+
});
|
|
202
|
+
} catch (error) { console.log(error) }
|
|
202
203
|
}
|
|
@@ -6,18 +6,18 @@ import * as base64 from '../base-64/icons.js';
|
|
|
6
6
|
import * as util from '../util.js';
|
|
7
7
|
|
|
8
8
|
export async function getReport(payload) {
|
|
9
|
-
|
|
10
|
-
const mqLogoBytes =
|
|
9
|
+
|
|
10
|
+
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
11
11
|
let maxPhotosPerPage = payload.meta.pdf_settings.maxPhotosPerPage ? payload.meta.pdf_settings.maxPhotosPerPage : 2;
|
|
12
12
|
|
|
13
13
|
// Layout Configuration
|
|
14
14
|
let docs = [], forms = [], page = photos6, pSize = "Small";
|
|
15
15
|
if (maxPhotosPerPage == 4) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
page = photos4;
|
|
17
|
+
pSize = "Mid";
|
|
18
18
|
} else if (maxPhotosPerPage == 2) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
page = photos2;
|
|
20
|
+
pSize = "Large";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Process All Photos
|
|
@@ -49,8 +49,8 @@ export async function getReport(payload) {
|
|
|
49
49
|
}
|
|
50
50
|
let imageToSet;
|
|
51
51
|
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
if (photo.base64 && photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
53
|
+
else if (photo.base64 && photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
54
54
|
}
|
|
55
55
|
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
56
56
|
let caption = photo.section;
|
|
@@ -66,13 +66,8 @@ export async function getReport(payload) {
|
|
|
66
66
|
forms.forEach(form => { form.flatten() });
|
|
67
67
|
let pdfDoc = await PDFDocument.create();
|
|
68
68
|
for (let i = 0; i < docs.length; i++) {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const [nextPage] = await pdfDoc.copyPages(docs[i], [0]);
|
|
70
|
+
pdfDoc.insertPage(i, nextPage);
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
return { code: 200, pdf: pdfBase64 };
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
return { code: 400, error: error };
|
|
77
|
-
}
|
|
72
|
+
return await pdfDoc.saveAsBase64({ dataUri: true });
|
|
78
73
|
}
|
|
@@ -7,139 +7,136 @@ import * as util from '../util.js';
|
|
|
7
7
|
|
|
8
8
|
export async function getReport(payload) {
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
11
|
+
let maxPhotosPerPage = payload.meta.pdf_settings.maxPhotosPerPage;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
// Layout Configuration
|
|
14
|
+
let docs = [], forms = [], page = photos6, pSize = "Small";
|
|
15
|
+
if (maxPhotosPerPage == 4) {
|
|
16
|
+
page = photos4;
|
|
17
|
+
pSize = "Mid";
|
|
18
|
+
} else if (maxPhotosPerPage == 2) {
|
|
19
|
+
page = photos2;
|
|
20
|
+
pSize = "Large";
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
41
|
-
if (!initialProjectPhotoPageLoaded) {
|
|
42
|
-
initialProjectPhotoPageLoaded = true;
|
|
43
|
-
canProcessReport = true;
|
|
44
|
-
//Initial Page, this needs to only publish this page IF and only IF it has valid image data
|
|
45
|
-
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
46
|
-
forms[docIndex] = docs[docIndex].getForm();
|
|
47
|
-
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
48
|
-
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
49
|
-
}
|
|
50
|
-
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
51
|
-
photoPosition = 1;
|
|
52
|
-
docIndex++;
|
|
53
|
-
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
54
|
-
forms[docIndex] = docs[docIndex].getForm();
|
|
55
|
-
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
56
|
-
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
57
|
-
}
|
|
58
|
-
let imageToSet;
|
|
23
|
+
// Process All Photos
|
|
24
|
+
let canProcessReport = false;
|
|
25
|
+
let previousPhotoSectionName;
|
|
26
|
+
let docIndex = 0;
|
|
27
|
+
let initialProjectPhotoPageLoaded = false;
|
|
28
|
+
let photoSectionKeys = Object.keys(payload.photos.project);
|
|
29
|
+
if (photoSectionKeys && photoSectionKeys.length > 0) {
|
|
30
|
+
let photoPosition = 1;
|
|
31
|
+
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
32
|
+
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
33
|
+
let photoSection = payload.photos.project[photoSectionKey];
|
|
34
|
+
let photoSectionName = photoSection.name;
|
|
35
|
+
let photos = photoSection.photos;
|
|
36
|
+
if (photos && photos.length > 0) {
|
|
37
|
+
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
38
|
+
let photo = photos[pIndex-1];
|
|
39
|
+
//If image has proper photo data, continue processing, else do not try and make an empty page.
|
|
59
40
|
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
60
|
-
if
|
|
61
|
-
|
|
41
|
+
if(!initialProjectPhotoPageLoaded){
|
|
42
|
+
initialProjectPhotoPageLoaded = true;
|
|
43
|
+
canProcessReport = true;
|
|
44
|
+
//Initial Page, this needs to only publish this page IF and only IF it has valid image data
|
|
45
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
46
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
47
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
48
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
49
|
+
}
|
|
50
|
+
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
51
|
+
photoPosition = 1;
|
|
52
|
+
docIndex++;
|
|
53
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
54
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
55
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
56
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
57
|
+
}
|
|
58
|
+
let imageToSet;
|
|
59
|
+
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
60
|
+
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
61
|
+
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
62
|
+
}
|
|
63
|
+
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
64
|
+
let photoSubText = photoSection.name;
|
|
65
|
+
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
66
|
+
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
67
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
68
|
+
photoPosition++;
|
|
69
|
+
previousPhotoSectionName = photoSectionName;
|
|
62
70
|
}
|
|
63
|
-
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
64
|
-
let photoSubText = photoSection.name;
|
|
65
|
-
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
66
|
-
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
67
|
-
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
68
|
-
photoPosition++;
|
|
69
|
-
previousPhotoSectionName = photoSectionName;
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let initialEquipmentPhotoPageLoaded = false;
|
|
77
|
-
photoSectionKeys = Object.keys(payload.photos.equipment);
|
|
78
|
-
let hasPhotos = payload.photos.equipment && payload.photos.equipment.photo_models_serials && payload.photos.equipment.photo_models_serials.photos && payload.photos.equipment.photo_models_serials.photos.length > 0;
|
|
79
|
-
if (photoSectionKeys && photoSectionKeys.length > 0 && hasPhotos) {
|
|
80
|
-
let photoPosition = 1;
|
|
81
|
-
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
82
|
-
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
83
|
-
let photoSection = payload.photos.equipment[photoSectionKey];
|
|
84
|
-
let photoSectionName = photoSection.name;
|
|
85
|
-
let photos = photoSection.photos;
|
|
86
|
-
if (photos && photos.length > 0) {
|
|
87
|
-
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
88
|
-
let photo = photos[pIndex - 1];
|
|
89
|
-
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
90
|
-
//Initial page load, this should wait until we know there is VALID image data
|
|
91
|
-
if (!initialEquipmentPhotoPageLoaded) {
|
|
92
|
-
initialEquipmentPhotoPageLoaded = true;
|
|
93
|
-
canProcessReport = true;
|
|
94
|
-
if (initialProjectPhotoPageLoaded && docIndex === 0) docIndex++;
|
|
95
|
-
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
96
|
-
forms[docIndex] = docs[docIndex].getForm();
|
|
97
|
-
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
98
|
-
forms[docIndex].getTextField("Header").setText(`Equipment Photos`);
|
|
99
|
-
}
|
|
100
75
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
76
|
+
let initialEquipmentPhotoPageLoaded = false;
|
|
77
|
+
photoSectionKeys = Object.keys(payload.photos.equipment);
|
|
78
|
+
let hasPhotos = payload.photos.equipment && payload.photos.equipment.photo_models_serials && payload.photos.equipment.photo_models_serials.photos && payload.photos.equipment.photo_models_serials.photos.length > 0;
|
|
79
|
+
if (photoSectionKeys && photoSectionKeys.length > 0 && hasPhotos) {
|
|
80
|
+
let photoPosition = 1;
|
|
81
|
+
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
82
|
+
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
83
|
+
let photoSection = payload.photos.equipment[photoSectionKey];
|
|
84
|
+
let photoSectionName = photoSection.name;
|
|
85
|
+
let photos = photoSection.photos;
|
|
86
|
+
if (photos && photos.length > 0) {
|
|
87
|
+
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
88
|
+
let photo = photos[pIndex-1];
|
|
110
89
|
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
//Initial page load, this should wait until we know there is VALID image data
|
|
91
|
+
if (!initialEquipmentPhotoPageLoaded){
|
|
92
|
+
initialEquipmentPhotoPageLoaded = true;
|
|
93
|
+
canProcessReport = true;
|
|
94
|
+
if (initialProjectPhotoPageLoaded && docIndex===0) docIndex++;
|
|
95
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
96
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
97
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
98
|
+
forms[docIndex].getTextField("Header").setText(`Equipment Photos`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
102
|
+
photoPosition = 1;
|
|
103
|
+
docIndex++;
|
|
104
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
105
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
106
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
107
|
+
forms[docIndex].getTextField("Header").setText(`Equipment Photos`);
|
|
108
|
+
}
|
|
109
|
+
let imageToSet;
|
|
110
|
+
if (photo && photo.base64 && typeof photo.base64 == 'string') {
|
|
111
|
+
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
112
|
+
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
113
|
+
}
|
|
114
|
+
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
115
|
+
let photoSubText = photoSection.name;
|
|
116
|
+
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
117
|
+
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
118
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
119
|
+
photoPosition++;
|
|
120
|
+
previousPhotoSectionName = photoSectionName;
|
|
113
121
|
}
|
|
114
|
-
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
115
|
-
let photoSubText = photoSection.name;
|
|
116
|
-
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
117
|
-
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
118
|
-
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
119
|
-
photoPosition++;
|
|
120
|
-
previousPhotoSectionName = photoSectionName;
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
docIndex++;
|
|
124
126
|
}
|
|
125
|
-
docIndex++;
|
|
126
|
-
}
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
// Prepare Deliverable
|
|
129
|
+
if (canProcessReport){
|
|
130
|
+
forms.forEach(form => { form.flatten() });
|
|
131
|
+
let pdfDoc = await PDFDocument.create();
|
|
132
|
+
for (let i = 0; i < docs.length; i++) {
|
|
133
|
+
const [nextPage] = await pdfDoc.copyPages(docs[i], [0]);
|
|
134
|
+
pdfDoc.insertPage(i, nextPage);
|
|
135
|
+
}
|
|
136
|
+
return await pdfDoc.saveAsBase64({ dataUri: true });
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return false;
|
|
135
140
|
}
|
|
136
|
-
|
|
137
|
-
return { code: 200, pdf: pdfBase64 };
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
return { code: 400, error: error };
|
|
144
|
-
}
|
|
141
|
+
} catch (error) {}
|
|
145
142
|
}
|
|
@@ -3,29 +3,24 @@ import * as pdf from '../base-64/ptcs-heat-pump.js';
|
|
|
3
3
|
import * as util from '../util.js';
|
|
4
4
|
|
|
5
5
|
export async function getReport(payload) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return { code: 200, pdf: pdfBase64 };
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return { code: 400, error: error };
|
|
30
|
-
}
|
|
6
|
+
const formPdfBytes = util._base64ToArrayBuffer(pdf.base64);
|
|
7
|
+
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
8
|
+
const photoBytesStripHeat = util._base64ToArrayBuffer(payload.images.imageStripHeatBase64);
|
|
9
|
+
const photoBytesHpThermostat = util._base64ToArrayBuffer(payload.images.imageHpThermostatBase64);
|
|
10
|
+
var imageStripHeat;
|
|
11
|
+
var imageHpThermostat;
|
|
12
|
+
if (photoBytesStripHeat) imageStripHeat = await pdfDoc.embedJpg(photoBytesStripHeat);
|
|
13
|
+
if (photoBytesHpThermostat) imageHpThermostat = await pdfDoc.embedJpg(photoBytesHpThermostat);
|
|
14
|
+
const form = pdfDoc.getForm();
|
|
15
|
+
Object.keys(payload.textFields).forEach(fieldKey => {
|
|
16
|
+
if (payload.textFields[fieldKey]) form.getTextField(fieldKey).setText(`${payload.textFields[fieldKey]}`);
|
|
17
|
+
});
|
|
18
|
+
Object.keys(payload.checkFields).forEach(fieldKey => {
|
|
19
|
+
if (payload.checkFields[fieldKey]) form.getCheckBox(`${payload.checkFields[fieldKey]}`).check();
|
|
20
|
+
});
|
|
21
|
+
if (imageStripHeat) form.getButton("customImage1").setImage(imageStripHeat);
|
|
22
|
+
if (imageHpThermostat) form.getButton("customImage2").setImage(imageHpThermostat);
|
|
23
|
+
form.flatten();
|
|
24
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
25
|
+
return pdfBase64;
|
|
31
26
|
}
|
|
@@ -5,23 +5,18 @@ import * as termsConditionsArkansas from '../base-64/terms-arkansas-thermostat.j
|
|
|
5
5
|
import * as util from '../util.js';
|
|
6
6
|
|
|
7
7
|
export async function getReport(payload) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} else return false;
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
return { code: 400, error: error };
|
|
24
|
-
}
|
|
8
|
+
let termsConditionsBase64 = getPdfBase64(payload.meta.signature_type);
|
|
9
|
+
if (termsConditionsBase64) {
|
|
10
|
+
const formPdfBytes = util._base64ToArrayBuffer(termsConditionsBase64);
|
|
11
|
+
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
12
|
+
const signatureBytes = util._base64ToArrayBuffer(payload.signatureBase64);
|
|
13
|
+
const signature = await pdfDoc.embedPng(signatureBytes);
|
|
14
|
+
const form = pdfDoc.getForm();
|
|
15
|
+
form.getButton("SignatureCustomer").setImage(signature);
|
|
16
|
+
form.flatten();
|
|
17
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
18
|
+
return pdfBase64;
|
|
19
|
+
} else return false;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
function getPdfBase64(reportType) {
|
|
@@ -6,15 +6,15 @@ import * as util from '../util.js';
|
|
|
6
6
|
|
|
7
7
|
export async function getReport(payload) {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const pdfDoc = payload.meta.report_mode == "heating" ? await PDFDocument.load(util._base64ToArrayBuffer(pdfHeating.base64)) : await PDFDocument.load(util._base64ToArrayBuffer(pdfCooling.base64));
|
|
10
|
+
const form = pdfDoc.getForm();
|
|
11
|
+
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
12
|
+
const mqLogo = await pdfDoc.embedPng(mqLogoBytes);
|
|
13
|
+
form.getButton("FullWidthLogo").setImage(mqLogo);
|
|
14
|
+
form.flatten();
|
|
15
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
16
|
+
return pdfBase64;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
20
|
}
|
|
@@ -1,214 +1,212 @@
|
|
|
1
1
|
import { PDFDocument } from 'pdf-lib';
|
|
2
|
-
import * as base64
|
|
2
|
+
import * as base64 from '../base-64/icons.js';
|
|
3
3
|
import * as pdf from '../base-64/mq-vitals-cooling.js';
|
|
4
|
-
import * as systemInfoPage
|
|
4
|
+
import * as systemInfoPage from './system-info-page.js';
|
|
5
5
|
import * as util from '../util.js';
|
|
6
6
|
|
|
7
7
|
export async function getReport(payload, _test) {
|
|
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
|
-
}
|
|
8
|
+
try {
|
|
9
|
+
// fetch and load form
|
|
10
|
+
const formPdfBytes = util._base64ToArrayBuffer(pdf.base64);
|
|
11
|
+
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
12
|
+
|
|
13
|
+
// fetch resources
|
|
14
|
+
const iconRangeGreenBytes = util._base64ToArrayBuffer(base64.iconRangeGreen);
|
|
15
|
+
const iconRangeRedBytes = util._base64ToArrayBuffer(base64.iconRangeRed);
|
|
16
|
+
const iconFlagBlackBytes = util._base64ToArrayBuffer(base64.iconFlagBlack);
|
|
17
|
+
const iconFlagGreenBytes = util._base64ToArrayBuffer(base64.iconFlagGreen);
|
|
18
|
+
const iconFlagRedBytes = util._base64ToArrayBuffer(base64.iconFlagRed);
|
|
19
|
+
const iconFlagYellowBytes = util._base64ToArrayBuffer(base64.iconFlagYellow);
|
|
20
|
+
const iconStabilityBytes = util._base64ToArrayBuffer(base64.iconStability);
|
|
21
|
+
const iconThumbprintGreenBytes = util._base64ToArrayBuffer(base64.iconThumbprintGreen);
|
|
22
|
+
const iconThumbprintRedBytes = util._base64ToArrayBuffer(base64.iconThumbprintRed);
|
|
23
|
+
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
24
|
+
|
|
25
|
+
// load resources
|
|
26
|
+
const iconRangeGreen = await pdfDoc.embedPng(iconRangeGreenBytes);
|
|
27
|
+
const iconRangeRed = await pdfDoc.embedPng(iconRangeRedBytes);
|
|
28
|
+
const iconFlagBlack = await pdfDoc.embedPng(iconFlagBlackBytes);
|
|
29
|
+
const iconFlagGreen = await pdfDoc.embedPng(iconFlagGreenBytes);
|
|
30
|
+
const iconFlagRed = await pdfDoc.embedPng(iconFlagRedBytes);
|
|
31
|
+
const iconFlagYellow = await pdfDoc.embedPng(iconFlagYellowBytes);
|
|
32
|
+
const iconStability = await pdfDoc.embedPng(iconStabilityBytes);
|
|
33
|
+
const iconThumbprintGreen = await pdfDoc.embedPng(iconThumbprintGreenBytes);
|
|
34
|
+
const iconThumbprintRed = await pdfDoc.embedPng(iconThumbprintRedBytes);
|
|
35
|
+
const mqLogo = await pdfDoc.embedPng(mqLogoBytes);
|
|
36
|
+
|
|
37
|
+
// embed company logo and profile picture
|
|
38
|
+
let profileImage, companyImage;
|
|
39
|
+
let profileImageType = util.checkProfilePicture(payload.meta);
|
|
40
|
+
let companyImageType = util.checkCompanyLogo(payload.meta);
|
|
41
|
+
if (profileImageType) {
|
|
42
|
+
if (profileImageType.shape == "square") profileImage = payload.meta.profile_settings.profilePicSquareBase64;
|
|
43
|
+
else if (profileImageType.shape == "circle") profileImage = payload.meta.profile_settings.profilePicCircleBase64;
|
|
44
|
+
if (profileImageType.type == "jpg") profileImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(profileImage));
|
|
45
|
+
else if (profileImageType.type == "png") profileImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(profileImage));
|
|
46
|
+
}
|
|
47
|
+
if (companyImageType == "jpg") companyImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
48
|
+
else if (companyImageType == "png") companyImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
49
|
+
|
|
50
|
+
// get form for filling
|
|
51
|
+
const form = pdfDoc.getForm();
|
|
52
|
+
|
|
53
|
+
// print system diagnostics section
|
|
54
|
+
let t = payload.tests[0].testInfo;
|
|
55
|
+
if (_test) t = _test.testInfo;
|
|
56
|
+
if (t && t.diagnostics && t.diagnostics.multi_point_analysis && t.diagnostics.multi_point_analysis.length > 0) {
|
|
57
|
+
for (let i = 0; i < 9; i++) {
|
|
58
|
+
let d = t.diagnostics.multi_point_analysis[i];
|
|
59
|
+
if (d) {
|
|
60
|
+
let diagnosticIcon = iconFlagBlack;
|
|
61
|
+
if (d.type === 'stability') diagnosticIcon = iconStability;
|
|
62
|
+
else if (d.score > 1 && d.score < 10) diagnosticIcon = iconFlagRed;
|
|
63
|
+
else if (d.score >= 10 && d.score < 15) diagnosticIcon = iconFlagYellow;
|
|
64
|
+
form.getButton(`ImageDiagnostics${i+1}_af_image`).setImage(diagnosticIcon);
|
|
65
|
+
form.getTextField(`SystemDiagnostics${i+1}`).setText(`${d.title}`);
|
|
66
|
+
form.getTextField(`SystemDiagnostics${i+1}a`).setText(`${d.score}`);
|
|
68
67
|
}
|
|
69
|
-
} else {
|
|
70
|
-
form.getButton("ImageDiagnostics1_af_image").setImage(iconFlagGreen);
|
|
71
|
-
form.getTextField("SystemDiagnostics1").setText("No system-wide issues were detected.");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let header = payload.meta.header ? payload.meta.header : "A/C System Vitals";
|
|
75
|
-
form.getTextField('Header').setText(header);
|
|
76
|
-
|
|
77
|
-
// get text fields
|
|
78
|
-
let textFields = getTextFields(payload, t);
|
|
79
|
-
|
|
80
|
-
// print company logo and profile picture
|
|
81
|
-
if (profileImage && companyImage) { // both images are embedded in the document
|
|
82
|
-
form.getButton("ProfilePicture").setImage(profileImage);
|
|
83
|
-
form.getButton("HalfWidthLogo").setImage(companyImage);
|
|
84
|
-
if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
|
|
85
|
-
form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
|
|
86
|
-
} else if (profileImage) { // no company logo is embedded in the document
|
|
87
|
-
form.getButton("ProfilePicture").setImage(profileImage);
|
|
88
|
-
form.getButton("HalfWidthLogo").setImage(mqLogo);
|
|
89
|
-
if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
|
|
90
|
-
form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
|
|
91
|
-
} else { // no profile picture is embedded in the document
|
|
92
|
-
if (companyImage) form.getButton("FullWidthLogo").setImage(companyImage);
|
|
93
|
-
else form.getButton("FullWidthLogo").setImage(mqLogo);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// print customer data
|
|
97
|
-
let dateTimePlacement = "Upper";
|
|
98
|
-
let e = "";
|
|
99
|
-
let d = "";
|
|
100
|
-
|
|
101
|
-
let date = new Date();
|
|
102
|
-
if (textFields.cName && textFields.address && textFields.city && textFields.state && textFields.zip) {
|
|
103
|
-
dateTimePlacement = "Lower";
|
|
104
|
-
form.getTextField('Name').setText(`${textFields.cName}`);
|
|
105
|
-
form.getTextField('Address1').setText(`${textFields.address}`);
|
|
106
|
-
if (textFields.address2) {
|
|
107
|
-
form.getTextField('Address2').setText(`${textFields.address2}`);
|
|
108
|
-
form.getTextField('CityStateZip').setText(`${textFields.city}${textFields.state}${textFields.zip}`);
|
|
109
|
-
} else form.getTextField('Address2').setText(`${textFields.city}${textFields.state}${textFields.zip}`);
|
|
110
|
-
form.getTextField('DateOfServiceLabelUpper').setText("");
|
|
111
|
-
form.getTextField('TimeOfServiceLabelUpper').setText("");
|
|
112
|
-
form.getTextField('DateOfServiceLabelLower').setText("Date of Service:");
|
|
113
|
-
form.getTextField('TimeOfServiceLabelLower').setText("Time of Service:");
|
|
114
|
-
form.getTextField('DateOfServiceLower').setText(date.toLocaleDateString("en-US"));
|
|
115
|
-
form.getTextField('TimeOfServiceLower').setText(date.toLocaleTimeString("en-US"));
|
|
116
|
-
} else {
|
|
117
|
-
form.getTextField('DateOfServiceLabelLower').setText("");
|
|
118
|
-
form.getTextField('TimeOfServiceLabelLower').setText("");
|
|
119
|
-
form.getTextField('DateOfServiceLabelUpper').setText("Date of Service:");
|
|
120
|
-
form.getTextField('TimeOfServiceLabelUpper').setText("Time of Service:");
|
|
121
|
-
form.getTextField('DateOfServiceUpper').setText(date.toLocaleDateString("en-US"));
|
|
122
|
-
form.getTextField('TimeOfServiceUpper').setText(date.toLocaleTimeString("en-US"));
|
|
123
68
|
}
|
|
69
|
+
} else {
|
|
70
|
+
form.getButton("ImageDiagnostics1_af_image").setImage(iconFlagGreen);
|
|
71
|
+
form.getTextField("SystemDiagnostics1").setText("No system-wide issues were detected.");
|
|
72
|
+
}
|
|
124
73
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
form.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
form.
|
|
139
|
-
form.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
form.getTextField(`AgeLosses${lossColor}`).setText(`${prefix}${textFields.ageLosses}`);
|
|
147
|
-
lossColor = textFields.tempSplitLosses < 3 ? "Green" : "Red";
|
|
148
|
-
prefix = textFields.tempSplitLosses == 0 ? "" : "-";
|
|
149
|
-
form.getTextField(`TemperatureSplitLosses${lossColor}`).setText(`${prefix}${textFields.tempSplitLosses}`);
|
|
150
|
-
lossColor = textFields.staticLosses < 3 ? "Green" : "Red";
|
|
151
|
-
prefix = textFields.staticLosses == 0 ? "" : "-";
|
|
152
|
-
form.getTextField(`StaticPressureLosses${lossColor}`).setText(`${prefix}${textFields.staticLosses}`);
|
|
153
|
-
lossColor = textFields.approachLosses < 3 ? "Green" : "Red";
|
|
154
|
-
prefix = textFields.approachLosses == 0 ? "" : "-";
|
|
155
|
-
form.getTextField(`ApproachLosses${lossColor}`).setText(`${prefix}${textFields.approachLosses}`);
|
|
156
|
-
lossColor = textFields.refChargeLosses < 3 ? "Green" : "Red";
|
|
157
|
-
prefix = textFields.refChargeLosses == 0 ? "" : "-";
|
|
158
|
-
form.getTextField(`RefrigerantChargeIssues${lossColor}`).setText(`${prefix}${textFields.refChargeLosses}`);
|
|
159
|
-
form.getTextField('YourSystemScorePage2').setText(`${systemScorePercentage} ${systemScoreGrade}`);
|
|
160
|
-
|
|
161
|
-
// print targets and range icons
|
|
162
|
-
const measureLabels = ["Superheat", "Subcooling", "Condenser", "TempSplit", "Tesp", "FilterFace"];
|
|
163
|
-
const targetKeys = ["superheat", "subcooling", "approach", "temperature_split", "pressure_static_total_external", "velocity_face_filter1"];
|
|
164
|
-
for (let i = 0; i < measureLabels.length; i++) {
|
|
165
|
-
let iconPlacement = "Mid";
|
|
166
|
-
let icon = iconRangeRed;
|
|
167
|
-
let actual = +t.data[targetKeys[i]];
|
|
168
|
-
let mid = +t.targets[targetKeys[i]];
|
|
169
|
-
let low = +t.targets[`${targetKeys[i]}_ideal_low`];
|
|
170
|
-
let high = +t.targets[`${targetKeys[i]}_ideal_high`];
|
|
171
|
-
low = mid - low;
|
|
172
|
-
high = mid + high;
|
|
173
|
-
if (targetKeys[i] == "pressure_static_total_external") high = mid * 1.4;
|
|
174
|
-
else if (targetKeys[i] == "velocity_face_filter1") high = 500;
|
|
175
|
-
let val = t.data[targetKeys[i]];
|
|
176
|
-
if (actual < low && targetKeys[i] != "velocity_face_filter1") iconPlacement = "Low";
|
|
177
|
-
else if (actual > high) iconPlacement = "High";
|
|
178
|
-
else if (val) icon = iconRangeGreen;
|
|
179
|
-
if (icon) form.getButton(`Image${measureLabels[i]}${iconPlacement}_af_image`).setImage(icon);
|
|
180
|
-
let targetZone = "";
|
|
181
|
-
if (targetKeys[i] == "pressure_static_total_external" || targetKeys[i] == "velocity_face_filter1") targetZone = `(< ${high.toFixed(1)})`;
|
|
182
|
-
else if (!isNaN(low) && low != "NaN" && !isNaN(high) && high != "NaN") targetZone = `(${low.toFixed(1)} - ${high.toFixed(1)})`;
|
|
183
|
-
form.getTextField(`${measureLabels[i]}Target`).setText(targetZone);
|
|
184
|
-
}
|
|
74
|
+
let header = payload.meta.header ? payload.meta.header : "A/C System Vitals";
|
|
75
|
+
form.getTextField('Header').setText(header);
|
|
76
|
+
|
|
77
|
+
// get text fields
|
|
78
|
+
let textFields = getTextFields(payload, t);
|
|
79
|
+
|
|
80
|
+
// print company logo and profile picture
|
|
81
|
+
if (profileImage && companyImage) { // both images are embedded in the document
|
|
82
|
+
form.getButton("ProfilePicture").setImage(profileImage);
|
|
83
|
+
form.getButton("HalfWidthLogo").setImage(companyImage);
|
|
84
|
+
if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
|
|
85
|
+
form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
|
|
86
|
+
} else if (profileImage) { // no company logo is embedded in the document
|
|
87
|
+
form.getButton("ProfilePicture").setImage(profileImage);
|
|
88
|
+
form.getButton("HalfWidthLogo").setImage(mqLogo);
|
|
89
|
+
if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
|
|
90
|
+
form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
|
|
91
|
+
} else { // no profile picture is embedded in the document
|
|
92
|
+
if (companyImage) form.getButton("FullWidthLogo").setImage(companyImage);
|
|
93
|
+
else form.getButton("FullWidthLogo").setImage(mqLogo);
|
|
94
|
+
}
|
|
185
95
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
96
|
+
// print customer data
|
|
97
|
+
let dateTimePlacement = "Upper";
|
|
98
|
+
let e = "";
|
|
99
|
+
let d = "";
|
|
100
|
+
|
|
101
|
+
let date = new Date();
|
|
102
|
+
if (textFields.cName && textFields.address && textFields.city && textFields.state && textFields.zip) {
|
|
103
|
+
dateTimePlacement = "Lower";
|
|
104
|
+
form.getTextField('Name').setText(`${textFields.cName}`);
|
|
105
|
+
form.getTextField('Address1').setText(`${textFields.address}`);
|
|
106
|
+
if (textFields.address2) {
|
|
107
|
+
form.getTextField('Address2').setText(`${textFields.address2}`);
|
|
108
|
+
form.getTextField('CityStateZip').setText(`${textFields.city}${textFields.state}${textFields.zip}`);
|
|
109
|
+
} else form.getTextField('Address2').setText(`${textFields.city}${textFields.state}${textFields.zip}`);
|
|
110
|
+
form.getTextField('DateOfServiceLabelUpper').setText("");
|
|
111
|
+
form.getTextField('TimeOfServiceLabelUpper').setText("");
|
|
112
|
+
form.getTextField('DateOfServiceLabelLower').setText("Date of Service:");
|
|
113
|
+
form.getTextField('TimeOfServiceLabelLower').setText("Time of Service:");
|
|
114
|
+
form.getTextField('DateOfServiceLower').setText(date.toLocaleDateString("en-US"));
|
|
115
|
+
form.getTextField('TimeOfServiceLower').setText(date.toLocaleTimeString("en-US"));
|
|
116
|
+
} else {
|
|
117
|
+
form.getTextField('DateOfServiceLabelLower').setText("");
|
|
118
|
+
form.getTextField('TimeOfServiceLabelLower').setText("");
|
|
119
|
+
form.getTextField('DateOfServiceLabelUpper').setText("Date of Service:");
|
|
120
|
+
form.getTextField('TimeOfServiceLabelUpper').setText("Time of Service:");
|
|
121
|
+
form.getTextField('DateOfServiceUpper').setText(date.toLocaleDateString("en-US"));
|
|
122
|
+
form.getTextField('TimeOfServiceUpper').setText(date.toLocaleTimeString("en-US"));
|
|
123
|
+
}
|
|
197
124
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
125
|
+
let systemScorePercentage = t.data.vitals_score ? +t.data.vitals_score.toFixed(0) : 0;
|
|
126
|
+
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
127
|
+
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
128
|
+
if (!t.data.vitals_score) {
|
|
129
|
+
systemScorePercentage = "--";
|
|
130
|
+
systemScoreGrade = "";
|
|
131
|
+
} else systemScorePercentage += "%";
|
|
132
|
+
|
|
133
|
+
// print measurement data (first page)
|
|
134
|
+
form.getTextField(`YourSystemScore${systemScoreColor}`).setText(`${systemScorePercentage} ${systemScoreGrade}`);
|
|
135
|
+
form.getTextField('Superheat').setText(`${textFields.superheat} °${payload.units.temperature}`);
|
|
136
|
+
form.getTextField('Subcooling').setText(`${textFields.subcooling} °${payload.units.temperature}`);
|
|
137
|
+
form.getTextField('CondenserApproach').setText(`${textFields.approach} °${payload.units.temperature}`);
|
|
138
|
+
form.getTextField('TemperatureSplit').setText(`${textFields.tempSplit} °${payload.units.temperature}`);
|
|
139
|
+
form.getTextField('TotalExternalStaticPressure').setText(`${textFields.tesp} inH2O`);
|
|
140
|
+
form.getTextField('FilterFaceVelocity').setText(`${textFields.fltrFace} FPM`);
|
|
141
|
+
|
|
142
|
+
// print losses data (second page)
|
|
143
|
+
let prefix;
|
|
144
|
+
let lossColor = textFields.ageLosses < 3 ? "Green" : "Red";
|
|
145
|
+
prefix = textFields.ageLosses == 0 ? "" : "-";
|
|
146
|
+
form.getTextField(`AgeLosses${lossColor}`).setText(`${prefix}${textFields.ageLosses}`);
|
|
147
|
+
lossColor = textFields.tempSplitLosses < 3 ? "Green" : "Red";
|
|
148
|
+
prefix = textFields.tempSplitLosses == 0 ? "" : "-";
|
|
149
|
+
form.getTextField(`TemperatureSplitLosses${lossColor}`).setText(`${prefix}${textFields.tempSplitLosses}`);
|
|
150
|
+
lossColor = textFields.staticLosses < 3 ? "Green" : "Red";
|
|
151
|
+
prefix = textFields.staticLosses == 0 ? "" : "-";
|
|
152
|
+
form.getTextField(`StaticPressureLosses${lossColor}`).setText(`${prefix}${textFields.staticLosses}`);
|
|
153
|
+
lossColor = textFields.approachLosses < 3 ? "Green" : "Red";
|
|
154
|
+
prefix = textFields.approachLosses == 0 ? "" : "-";
|
|
155
|
+
form.getTextField(`ApproachLosses${lossColor}`).setText(`${prefix}${textFields.approachLosses}`);
|
|
156
|
+
lossColor = textFields.refChargeLosses < 3 ? "Green" : "Red";
|
|
157
|
+
prefix = textFields.refChargeLosses == 0 ? "" : "-";
|
|
158
|
+
form.getTextField(`RefrigerantChargeIssues${lossColor}`).setText(`${prefix}${textFields.refChargeLosses}`);
|
|
159
|
+
form.getTextField('YourSystemScorePage2').setText(`${systemScorePercentage} ${systemScoreGrade}`);
|
|
160
|
+
|
|
161
|
+
// print targets and range icons
|
|
162
|
+
const measureLabels = ["Superheat", "Subcooling", "Condenser", "TempSplit", "Tesp", "FilterFace"];
|
|
163
|
+
const targetKeys = ["superheat", "subcooling", "approach", "temperature_split", "pressure_static_total_external", "velocity_face_filter1"];
|
|
164
|
+
for (let i = 0; i < measureLabels.length; i++) {
|
|
165
|
+
let iconPlacement = "Mid";
|
|
166
|
+
let icon = iconRangeRed;
|
|
167
|
+
let actual = +t.data[targetKeys[i]];
|
|
168
|
+
let mid = +t.targets[targetKeys[i]];
|
|
169
|
+
let low = +t.targets[`${targetKeys[i]}_ideal_low`];
|
|
170
|
+
let high = +t.targets[`${targetKeys[i]}_ideal_high`];
|
|
171
|
+
low = mid - low;
|
|
172
|
+
high = mid + high;
|
|
173
|
+
if (targetKeys[i] == "pressure_static_total_external") high = mid * 1.4;
|
|
174
|
+
else if (targetKeys[i] == "velocity_face_filter1") high = 500;
|
|
175
|
+
let val = t.data[targetKeys[i]];
|
|
176
|
+
if (actual < low && targetKeys[i] != "velocity_face_filter1") iconPlacement = "Low";
|
|
177
|
+
else if (actual > high) iconPlacement = "High";
|
|
178
|
+
else if (val) icon = iconRangeGreen;
|
|
179
|
+
if (icon) form.getButton(`Image${measureLabels[i]}${iconPlacement}_af_image`).setImage(icon);
|
|
180
|
+
let targetZone = "";
|
|
181
|
+
if (targetKeys[i] == "pressure_static_total_external" || targetKeys[i] == "velocity_face_filter1") targetZone = `(< ${high.toFixed(1)})`;
|
|
182
|
+
else if (!isNaN(low) && low != "NaN" && !isNaN(high) && high != "NaN" ) targetZone = `(${low.toFixed(1)} - ${high.toFixed(1)})`;
|
|
183
|
+
form.getTextField(`${measureLabels[i]}Target`).setText(targetZone);
|
|
184
|
+
}
|
|
204
185
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
186
|
+
// print pass fail measures
|
|
187
|
+
if (t.subsystem_review_complete) {
|
|
188
|
+
let passFails = ["electrical_system_pass_fail", "air_distribution_system_pass_fail", "air_filtration_system_pass_fail", "condensate_drain_system_pass_fail", "refrigerant_charge_pass_fail", "outdoor_equipment_pass_fail", "indoor_equipment_pass_fail", "cooling_capacity_pass_fail", "cooling_electrical_efficiency_pass_fail"];
|
|
189
|
+
let pfLabels = ["Electrical system", "Air distribution system", "Air filtration system", "Condensate drain system", "Refrigerant charge", "Outdoor equipment", "Indoor equipment", "Cooling capacity", "Cooling electrical efficiency"];
|
|
190
|
+
for (let i = 1; i <= passFails.length; i++) {
|
|
191
|
+
let meas = t[passFails[i - 1]];
|
|
192
|
+
let icon = meas == "Pass" || meas == "High" || meas == "Mid" ? iconRangeGreen : iconRangeRed;
|
|
193
|
+
form.getButton(`ImageSubsystem${i}_af_image`).setImage(icon);
|
|
194
|
+
form.getTextField(`SSR${i}`).setText(pfLabels[i-1]);
|
|
195
|
+
}
|
|
196
|
+
} else form.getTextField(`SSR1`).setText("Not yet reviewed");
|
|
197
|
+
|
|
198
|
+
if (payload.meta.report_type != "FullReport") {
|
|
199
|
+
let systemInfoPageBase64 = await systemInfoPage.getReport(payload);
|
|
200
|
+
const systemInfoPageDoc = systemInfoPageBase64 ? await PDFDocument.load(util._base64ToArrayBuffer(systemInfoPageBase64)) : false;
|
|
201
|
+
const [_systemInfoPageDoc] = systemInfoPageDoc ? await pdfDoc.copyPages(systemInfoPageDoc, [0]) : false;
|
|
202
|
+
if (_systemInfoPageDoc) pdfDoc.insertPage(pdfDoc.getPages().length, _systemInfoPageDoc);
|
|
211
203
|
}
|
|
204
|
+
|
|
205
|
+
// flatten and return as base64
|
|
206
|
+
form.flatten();
|
|
207
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
208
|
+
return pdfBase64;
|
|
209
|
+
} catch (error) { }
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
function getTextFields(payload, test) {
|
|
@@ -232,10 +232,8 @@ export async function getReport(payload, _test) {
|
|
|
232
232
|
// flatten and return as base64
|
|
233
233
|
form.flatten();
|
|
234
234
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
235
|
-
return
|
|
236
|
-
} catch (error) {
|
|
237
|
-
return { code: 400, error: error };
|
|
238
|
-
}
|
|
235
|
+
return pdfBase64;
|
|
236
|
+
} catch (error) { console.log(error) }
|
|
239
237
|
}
|
|
240
238
|
|
|
241
239
|
function getTextFields(payload, test) {
|