@measurequick/measurequick-report-generator 1.2.20 → 1.2.21

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.20",
3
+ "version": "1.2.21",
4
4
  "description": "Generates PDF documents for various MeasureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,18 +27,19 @@ export async function getReport(payload) {
27
27
  let photoCollectionName = photoCollectionNames[pcnIndex];
28
28
  let photoCollection = payload.photos[photoCollectionName];
29
29
  let photoSectionKeys = Object.keys(photoCollection);
30
+ if (!photoSectionKeys || photoSectionKeys.length == 0) break;
31
+ let photoPosition = 1;
32
+ let doc = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
33
+ let form = doc.getForm();
34
+ docs.push(doc);
35
+ forms.push(form);
36
+ form.getButton("FullWidthLogo").setImage(await doc.embedPng(mqLogoBytes));
37
+ form.getTextField("Header").setText(`${util.capitalizeFirstLetter(photoCollectionName)} Photos`);
30
38
  for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
31
39
  let photoSectionKey = photoSectionKeys[pskIndex];
32
40
  let photoSection = photoCollection[photoSectionKey];
33
41
  let photos = photoSection.photos;
34
42
  if (!photos || photos.length == 0) break;
35
- let photoPosition = 1;
36
- let doc = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
37
- let form = doc.getForm();
38
- docs.push(doc);
39
- forms.push(form);
40
- form.getButton("FullWidthLogo").setImage(await doc.embedPng(mqLogoBytes));
41
- form.getTextField("Header").setText(`${util.capitalizeFirstLetter(photoCollectionName)} Photos`);
42
43
  for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
43
44
  let photo = photos[pIndex-1];
44
45
  if (photoPosition > maxPhotosPerPage) { // Need a new page