@measurequick/measurequick-report-generator 1.2.39 → 1.2.41
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
|
@@ -5,7 +5,7 @@ import * as photos6 from '../base-64/photos6.js';
|
|
|
5
5
|
import * as base64 from '../base-64/icons.js';
|
|
6
6
|
import * as util from '../util.js';
|
|
7
7
|
|
|
8
|
-
export async function getReport(payload) {
|
|
8
|
+
export async function getReport(payload) { console.log(payload);
|
|
9
9
|
|
|
10
10
|
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
11
11
|
let maxPhotosPerPage = payload.meta.pdf_settings.maxPhotosPerPage;
|
|
@@ -21,56 +21,32 @@ export async function getReport(payload) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Process All Photos
|
|
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
|
-
docIndex++;
|
|
51
|
-
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
52
|
-
forms[docIndex] = docs[docIndex].getForm();
|
|
53
|
-
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
54
|
-
forms[docIndex].getTextField("Header").setText(`${util.capitalizeFirstLetter(photoCollectionName)} Photos`);
|
|
55
|
-
}
|
|
56
|
-
let imageToSet;
|
|
57
|
-
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
58
|
-
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
59
|
-
if (imageToSet) {
|
|
60
|
-
console.log(`Printing ${photo.tag} in Position #${photoPosition} on Page #${docIndex+1}`);
|
|
61
|
-
forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
62
|
-
}
|
|
63
|
-
let photoSubText = photoSection.name;
|
|
64
|
-
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
65
|
-
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
66
|
-
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
67
|
-
photoPosition++;
|
|
68
|
-
previousPhotoSectionName = photoCollectionName;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
docIndex++;
|
|
73
|
-
}
|
|
24
|
+
let docIndex = 0;
|
|
25
|
+
if (payload.photos && Object.keys(payload.photos) && Object.keys(payload.photos).length > 0) {
|
|
26
|
+
let s3ReferenceIds = Object.keys(payload.photos);
|
|
27
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
28
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
29
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
30
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
31
|
+
let photoPosition = 1;
|
|
32
|
+
for (let s3IdIndex = 0; s3IdIndex < s3ReferenceIds.length; s3IdIndex++) {
|
|
33
|
+
let s3ReferenceId = s3ReferenceIds[s3IdIndex];
|
|
34
|
+
let photo = payload.photos[s3ReferenceId];
|
|
35
|
+
if (photoPosition > maxPhotosPerPage) {
|
|
36
|
+
photoPosition = 1;
|
|
37
|
+
docIndex++;
|
|
38
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
39
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
40
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
41
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
42
|
+
}
|
|
43
|
+
let imageToSet;
|
|
44
|
+
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
45
|
+
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
46
|
+
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
47
|
+
photoPosition++;
|
|
48
|
+
}
|
|
49
|
+
docIndex++;
|
|
74
50
|
}
|
|
75
51
|
|
|
76
52
|
// Prepare Deliverable
|