@measurequick/measurequick-report-generator 1.2.38 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measurequick/measurequick-report-generator",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "description": "Generates PDF documents for various MeasureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,21 +21,21 @@ export async function getReport(payload) {
21
21
  }
22
22
 
23
23
  // Process All Photos
24
- let previousPhotoSectionName;
25
- let docIndex = 0;
26
- let photoCollection = payload.photos;
27
- let photoSectionKeys = Object.keys(photoCollection);
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 = photoCollection[photoSectionKey];
36
- let photoSectionName = photoSection.name;
37
- let photos = photoSection.photos;
38
- if (!photos || photos.length == 0) break;
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
39
  for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
40
40
  let photo = photos[pIndex-1];
41
41
  if (photoPosition > maxPhotosPerPage) { // Need a new page
@@ -58,7 +58,9 @@ export async function getReport(payload) {
58
58
  previousPhotoSectionName = photoSectionName;
59
59
  }
60
60
  }
61
- docIndex++;
61
+ }
62
+ docIndex++;
63
+ }
62
64
 
63
65
  // Prepare Deliverable
64
66
  forms.forEach(form => { form.flatten() });