@measurequick/measurequick-report-generator 1.2.39 → 1.2.40
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
|
@@ -21,56 +21,45 @@ 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
|
-
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
49
|
-
photoPosition = 1;
|
|
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
|
-
}
|
|
24
|
+
let previousPhotoSectionName;
|
|
25
|
+
let docIndex = 0;
|
|
26
|
+
let photoSectionKeys = Object.keys(payload.photos);
|
|
27
|
+
if (photoSectionKeys && photoSectionKeys.length > 0) {
|
|
28
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
29
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
30
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
31
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
32
|
+
let photoPosition = 1;
|
|
33
|
+
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
34
|
+
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
35
|
+
let photoSection = payload.photos[photoSectionKey];
|
|
36
|
+
let photoSectionName = photoSection.name;
|
|
37
|
+
let photos = photoSection.photos;
|
|
38
|
+
if (photos && photos.length > 0) {
|
|
39
|
+
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
40
|
+
let photo = photos[pIndex-1];
|
|
41
|
+
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
42
|
+
photoPosition = 1;
|
|
43
|
+
docIndex++;
|
|
44
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
45
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
46
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
47
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
71
48
|
}
|
|
72
|
-
|
|
49
|
+
let imageToSet;
|
|
50
|
+
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
51
|
+
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
52
|
+
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
53
|
+
let photoSubText = photoSection.name;
|
|
54
|
+
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
55
|
+
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
56
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
57
|
+
photoPosition++;
|
|
58
|
+
previousPhotoSectionName = photoSectionName;
|
|
73
59
|
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
docIndex++;
|
|
74
63
|
}
|
|
75
64
|
|
|
76
65
|
// Prepare Deliverable
|