@measurequick/measurequick-report-generator 1.2.47 → 1.2.49
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
|
@@ -22,8 +22,10 @@ export async function getReport(payload) { console.log("Cover Page");
|
|
|
22
22
|
form.getTextField("Company Name").setText(payload.meta.company_name);
|
|
23
23
|
form.getTextField("Date of Service Cover").setText(payload.meta.date_of_service);
|
|
24
24
|
form.getTextField("Time of Service Cover").setText(payload.meta.time_of_service);
|
|
25
|
-
if (
|
|
26
|
-
|
|
25
|
+
if (profilePicture) {
|
|
26
|
+
form.getButton("Profile Picture").setImage(profilePicture);
|
|
27
|
+
if (companyLogo) form.getButton("Company Logo").setImage(companyLogo);
|
|
28
|
+
} else if (companyLogo) form.getButton("Company Logo Full").setImage(companyLogo);
|
|
27
29
|
form.flatten();
|
|
28
30
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
29
31
|
return pdfBase64;
|
|
@@ -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) { console.log(payload);
|
|
8
|
+
export async function getReport(payload) { console.log("photos-report-s3 -> getReport() ->"); console.log(payload);
|
|
9
9
|
|
|
10
10
|
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
11
11
|
let maxPhotosPerPage = payload.meta.pdf_settings.maxPhotosPerPage ? payload.meta.pdf_settings.maxPhotosPerPage : 2;
|
|
@@ -22,13 +22,12 @@ export async function getReport(payload) { console.log(payload);
|
|
|
22
22
|
|
|
23
23
|
// Process All Photos
|
|
24
24
|
let docIndex = 0;
|
|
25
|
-
let photos = payload.photos;
|
|
26
|
-
|
|
25
|
+
let photos = payload.photos.project;
|
|
26
|
+
delete photos.unsynced;
|
|
27
27
|
if (photos && Object.keys(photos) && Object.keys(photos).length > 0) {
|
|
28
28
|
let s3ReferenceIds = Object.keys(photos);
|
|
29
29
|
let arrPhotos = [];
|
|
30
30
|
for (let i = 0; i < s3ReferenceIds.length; i++) { if (s3ReferenceIds[i] !== 'unsynced') arrPhotos.push(photos[s3ReferenceIds[i]]); }
|
|
31
|
-
console.log(arrPhotos);
|
|
32
31
|
arrPhotos.sort((a, b) => (a.section > b.section) ? 1 : -1);
|
|
33
32
|
console.log(arrPhotos);
|
|
34
33
|
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
@@ -39,27 +38,25 @@ export async function getReport(payload) { console.log(payload);
|
|
|
39
38
|
let prevSection, currSection;
|
|
40
39
|
for (let s3IdIndex = 0; s3IdIndex < s3ReferenceIds.length; s3IdIndex++) {
|
|
41
40
|
let s3ReferenceId = s3ReferenceIds[s3IdIndex];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
52
|
-
}
|
|
53
|
-
let imageToSet;
|
|
54
|
-
if ((photo.base64 && photo.base64.includes("image/jpeg")) || photo.fileType == 'jpg') imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
55
|
-
else if ((photo.base64 && photo.base64.includes("image/png")) || photo.fileType == 'png') imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
56
|
-
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
57
|
-
photoPosition++;
|
|
58
|
-
let caption = photo.section;
|
|
59
|
-
if (prevSection == currSection) caption += photo.notes;
|
|
60
|
-
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(caption);
|
|
61
|
-
prevSection = currSection;
|
|
41
|
+
let photo = photos[s3ReferenceId];
|
|
42
|
+
currSection = photo.section;
|
|
43
|
+
if (photoPosition > maxPhotosPerPage) {
|
|
44
|
+
photoPosition = 1;
|
|
45
|
+
docIndex++;
|
|
46
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
47
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
48
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
49
|
+
forms[docIndex].getTextField("Header").setText(`Project Photos`);
|
|
62
50
|
}
|
|
51
|
+
let imageToSet;
|
|
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
|
+
if (imageToSet) forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
55
|
+
let caption = photo.section;
|
|
56
|
+
if (prevSection == currSection) caption += photo.notes;
|
|
57
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(caption);
|
|
58
|
+
photoPosition++;
|
|
59
|
+
prevSection = currSection;
|
|
63
60
|
}
|
|
64
61
|
docIndex++;
|
|
65
62
|
}
|