@measurequick/measurequick-report-generator 1.2.93 → 1.2.95
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
CHANGED
|
@@ -4,33 +4,34 @@ import * as util from '../util.js';
|
|
|
4
4
|
|
|
5
5
|
export async function getReport(payload) {
|
|
6
6
|
try {
|
|
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
|
-
|
|
7
|
+
const pdfDoc = await PDFDocument.load(util._base64ToArrayBuffer(pdf.base64));
|
|
8
|
+
let profileImage, companyImage;
|
|
9
|
+
let profileImageType = util.checkProfilePicture(payload.meta);
|
|
10
|
+
let companyImageType = util.checkCompanyLogo(payload.meta);
|
|
11
|
+
if (profileImageType) {
|
|
12
|
+
if (profileImageType.shape == "square") profileImage = payload.meta.profile_settings.profilePicSquareBase64;
|
|
13
|
+
else if (profileImageType.shape == "circle") profileImage = payload.meta.profile_settings.profilePicCircleBase64;
|
|
14
|
+
if (profileImageType.type == "jpg") profileImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(profileImage));
|
|
15
|
+
else if (profileImageType.type == "png") profileImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(profileImage));
|
|
16
|
+
}
|
|
17
|
+
if (companyImageType == "jpg") companyImage = await pdfDoc.embedJpg(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
18
|
+
else if (companyImageType == "png") companyImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(payload.meta.profile_settings.companyLogoBase64));
|
|
19
|
+
const form = pdfDoc.getForm();
|
|
20
|
+
let l = payload.meta.report_title ? payload.meta.report_title.length : 0;
|
|
21
|
+
let fontSize = 24;
|
|
22
|
+
if (l >= 42) fontSize = 16;
|
|
23
|
+
else if (l >= 34) fontSize = 20;
|
|
24
|
+
form.getTextField(`Report Title${fontSize}`).setText(payload.meta.report_title);
|
|
25
|
+
form.getTextField("Technician Name").setText(payload.meta.technician_name);
|
|
26
|
+
form.getTextField("Company Name").setText(payload.meta.company_name);
|
|
27
|
+
form.getTextField("Date of Service").setText(payload.meta.date_of_service);
|
|
28
|
+
form.getTextField("Time of Service").setText(payload.meta.time_of_service);
|
|
29
|
+
if (profileImage) {
|
|
30
|
+
form.getButton("Profile Picture").setImage(profileImage);
|
|
31
|
+
if (companyImage) form.getButton("Company Logo").setImage(companyImage);
|
|
32
|
+
} else if (companyImage) form.getButton("Company Logo Full").setImage(companyImage);
|
|
33
|
+
form.flatten();
|
|
34
|
+
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
35
|
+
return pdfBase64;
|
|
36
|
+
} catch (error) { }
|
|
36
37
|
}
|
|
@@ -147,9 +147,7 @@ export async function getReport(payload) {
|
|
|
147
147
|
let val = measurement.value ? measurement.value : (+test.data[measurement.ref]);
|
|
148
148
|
if (!val) val = "--";
|
|
149
149
|
else if (measurement.fixTo && typeof val == 'number') val = val.toFixed(measurement.fixTo);
|
|
150
|
-
if (measurement.label == 'Ambient CO' && !measurement.value) val = '0.0';
|
|
151
|
-
else if (measurement.label == 'Return CO' && !measurement.value) val = '0.0';
|
|
152
|
-
else if (measurement.label == 'Supply CO' && !measurement.value) val = '0.0';
|
|
150
|
+
if ((measurement.label == 'Ambient CO' || measurement.label == 'Return CO' || measurement.label == 'Supply CO') && !measurement.value) val = '0.0';
|
|
153
151
|
form.getTextField(`Block${blockNum}-Row${rowNum}-Col2`).setText(`${val}`);
|
|
154
152
|
if (blockNum != 4) {
|
|
155
153
|
let rangeIcon = util.getRangeIcon(test, measurement.ref, embeddedIcons);
|