@measurequick/measurequick-report-generator 1.5.175 → 1.5.176

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.5.175",
3
+ "version": "1.5.176",
4
4
  "description": "Generates PDF documents for various measureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -51,27 +51,24 @@ export async function getReport(payload) {
51
51
  let pageHeader = payload.meta.report_mode == "heating" ? "Visual Inspection" : payload.project.unit_not_operational ? "Inoperational System Faults" : "Corrective Measures";
52
52
  form.getTextField('Header').setText(pageTitle);
53
53
 
54
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and profile section
54
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of profile picture (50% of cover size)
55
+ let nciLogoImage = null;
55
56
  if (isNCIProject(payload) && base64.nciLogo) {
56
- const nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
57
- const pages = pdfDoc.getPages();
58
- const firstPage = pages[0];
59
- const { width, height } = firstPage.getSize();
60
- // Draw NCI logo centered, below title and above profile/company section
61
- const logoWidth = 200;
62
- const logoHeight = logoWidth * (nciLogoImage.height / nciLogoImage.width);
63
- const x = (width - logoWidth) / 2;
64
- const y = height - 120; // Position below title, above profile section
65
- firstPage.drawImage(nciLogoImage, {
66
- x: x,
67
- y: y,
68
- width: logoWidth,
69
- height: logoHeight,
70
- });
57
+ nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
71
58
  }
72
59
 
73
60
  // print company logo and profile picture
74
- if (profileImage && companyImage) {
61
+ if (nciLogoImage) {
62
+ // NCI project - use NCI logo instead of profile picture
63
+ form.getButton("ProfilePicture").setImage(nciLogoImage);
64
+ if (companyImage) {
65
+ form.getButton("HalfWidthLogo").setImage(companyImage);
66
+ } else {
67
+ form.getButton("HalfWidthLogo").setImage(mqLogo);
68
+ }
69
+ if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
70
+ form.getTextField('TechName').setText(`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`);
71
+ } else if (profileImage && companyImage) {
75
72
  form.getButton("ProfilePicture").setImage(profileImage);
76
73
  form.getButton("HalfWidthLogo").setImage(companyImage);
77
74
  if (payload.meta.profile_settings.techFirstName || payload.meta.profile_settings.techLastName)
@@ -48,11 +48,11 @@ export async function getReport(payload) {
48
48
  const pages = pdfDoc.getPages();
49
49
  const firstPage = pages[0];
50
50
  const { width, height } = firstPage.getSize();
51
- // Draw NCI logo above the profile/company section (centered, upper portion of page)
51
+ // Draw NCI logo above the profile/company section (centered, 2.5 inches lower)
52
52
  const logoWidth = 180;
53
53
  const logoHeight = logoWidth * (nciLogo.height / nciLogo.width);
54
54
  const x = (width - logoWidth) / 2;
55
- const y = height - logoHeight - 60; // 60 points from top
55
+ const y = height - logoHeight - 240; // 240 points from top (~3.3 inches)
56
56
  firstPage.drawImage(nciLogo, {
57
57
  x: x,
58
58
  y: y,
@@ -200,36 +200,42 @@ export async function getReport(payload) {
200
200
  }
201
201
  }
202
202
 
203
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and profile section
203
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of profile picture (50% of cover size)
204
+ let nciLogoImagePg1 = null;
205
+ let nciLogoImagePg2 = null;
204
206
  if (isNCIProject(payload) && base64.nciLogo) {
205
- const nciLogoImagePg1 = await pdfDocPg1.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
206
- const nciLogoImagePg2 = await pdfDocPg2.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
207
- const pagesPg1 = pdfDocPg1.getPages();
208
- const pagesPg2 = pdfDocPg2.getPages();
209
- const firstPagePg1 = pagesPg1[0];
210
- const firstPagePg2 = pagesPg2[0];
211
- const { width, height } = firstPagePg1.getSize();
212
- // Draw NCI logo centered, below title and above profile/company section
213
- const logoWidth = 200;
214
- const logoHeight = logoWidth * (nciLogoImagePg1.height / nciLogoImagePg1.width);
215
- const x = (width - logoWidth) / 2;
216
- const y = height - 120; // Position below title, above profile section
217
- firstPagePg1.drawImage(nciLogoImagePg1, {
218
- x: x,
219
- y: y,
220
- width: logoWidth,
221
- height: logoHeight,
222
- });
223
- firstPagePg2.drawImage(nciLogoImagePg2, {
224
- x: x,
225
- y: y,
226
- width: logoWidth,
227
- height: logoHeight,
228
- });
207
+ nciLogoImagePg1 = await pdfDocPg1.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
208
+ nciLogoImagePg2 = await pdfDocPg2.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
229
209
  }
230
210
 
231
211
  // print company logo and profile picture
232
- if (profileImagePg1 && companyImagePg1) {
212
+ if (nciLogoImagePg1) {
213
+ // NCI project - use NCI logo instead of profile picture
214
+ formPg1.getButton("ProfilePicture").setImage(nciLogoImagePg1);
215
+ formPg2.getButton("ProfilePicture").setImage(nciLogoImagePg2);
216
+ if (companyImagePg1) {
217
+ formPg1.getButton("HalfWidthLogo").setImage(companyImagePg1);
218
+ formPg2.getButton("HalfWidthLogo").setImage(companyImagePg2);
219
+ } else {
220
+ formPg1.getButton("HalfWidthLogo").setImage(mqLogoPg1);
221
+ formPg2.getButton("HalfWidthLogo").setImage(mqLogoPg2);
222
+ }
223
+ if (
224
+ payload.meta.profile_settings.techFirstName ||
225
+ payload.meta.profile_settings.techLastName
226
+ ) {
227
+ formPg1
228
+ .getTextField("TechName")
229
+ .setText(
230
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
231
+ );
232
+ formPg2
233
+ .getTextField("TechName")
234
+ .setText(
235
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
236
+ );
237
+ }
238
+ } else if (profileImagePg1 && companyImagePg1) {
233
239
  formPg1.getButton("ProfilePicture").setImage(profileImagePg1);
234
240
  formPg1.getButton("HalfWidthLogo").setImage(companyImagePg1);
235
241
  formPg2.getButton("ProfilePicture").setImage(profileImagePg2);
@@ -20,26 +20,13 @@ export async function getReport(payload) {
20
20
  const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
21
21
  const mqLogo = await pdfDoc.embedPng(mqLogoBytes);
22
22
 
23
- form.getButton("FullWidthLogo").setImage(mqLogo);
24
-
25
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and logo section
23
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of mQ logo (75% of cover size)
26
24
  if (isNCIProject(payload) && base64.nciLogo) {
27
25
  const nciLogoBytes = util._base64ToArrayBuffer(base64.nciLogo);
28
26
  const nciLogo = await pdfDoc.embedPng(nciLogoBytes);
29
- const pages = pdfDoc.getPages();
30
- const firstPage = pages[0];
31
- const { width, height } = firstPage.getSize();
32
- // Draw NCI logo centered, below title and above logo section
33
- const logoWidth = 200;
34
- const logoHeight = logoWidth * (nciLogo.height / nciLogo.width);
35
- const x = (width - logoWidth) / 2;
36
- const y = height - 120; // Position below title, above logo section
37
- firstPage.drawImage(nciLogo, {
38
- x: x,
39
- y: y,
40
- width: logoWidth,
41
- height: logoHeight,
42
- });
27
+ form.getButton("FullWidthLogo").setImage(nciLogo);
28
+ } else {
29
+ form.getButton("FullWidthLogo").setImage(mqLogo);
43
30
  }
44
31
 
45
32
  form.flatten();
@@ -127,27 +127,31 @@ export async function getReport(payload, _test) {
127
127
  // get text fields
128
128
  let textFields = getTextFields(payload, t);
129
129
 
130
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and profile section
130
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of profile picture (50% of cover size)
131
+ let nciLogoImage = null;
131
132
  if (isNCIProject(payload) && base64.nciLogo) {
132
- const nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
133
- const pages = pdfDoc.getPages();
134
- const firstPage = pages[0];
135
- const { width, height } = firstPage.getSize();
136
- // Draw NCI logo centered, below title and above profile/company section
137
- const logoWidth = 200;
138
- const logoHeight = logoWidth * (nciLogoImage.height / nciLogoImage.width);
139
- const x = (width - logoWidth) / 2;
140
- const y = height - 120; // Position below title, above profile section
141
- firstPage.drawImage(nciLogoImage, {
142
- x: x,
143
- y: y,
144
- width: logoWidth,
145
- height: logoHeight,
146
- });
133
+ nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
147
134
  }
148
135
 
149
136
  // print company logo and profile picture
150
- if (profileImage && companyImage) {
137
+ if (nciLogoImage) {
138
+ // NCI project - use NCI logo instead of profile picture
139
+ form.getButton("ProfilePicture").setImage(nciLogoImage);
140
+ if (companyImage) {
141
+ form.getButton("HalfWidthLogo").setImage(companyImage);
142
+ } else {
143
+ form.getButton("HalfWidthLogo").setImage(mqLogo);
144
+ }
145
+ if (
146
+ payload.meta.profile_settings.techFirstName ||
147
+ payload.meta.profile_settings.techLastName
148
+ )
149
+ form
150
+ .getTextField("TechName")
151
+ .setText(
152
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
153
+ );
154
+ } else if (profileImage && companyImage) {
151
155
  // both images are embedded in the document
152
156
  form.getButton("ProfilePicture").setImage(profileImage);
153
157
  form.getButton("HalfWidthLogo").setImage(companyImage);
@@ -115,27 +115,31 @@ export async function getReport(payload, _test) {
115
115
  t.manifoldKey = manifoldKey;
116
116
  let textFields = getTextFields(payload, t);
117
117
 
118
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and profile section
118
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of profile picture (50% of cover size)
119
+ let nciLogoImage = null;
119
120
  if (isNCIProject(payload) && base64.nciLogo) {
120
- const nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
121
- const pages = pdfDoc.getPages();
122
- const firstPage = pages[0];
123
- const { width, height } = firstPage.getSize();
124
- // Draw NCI logo centered, below title and above profile/company section
125
- const logoWidth = 200;
126
- const logoHeight = logoWidth * (nciLogoImage.height / nciLogoImage.width);
127
- const x = (width - logoWidth) / 2;
128
- const y = height - 120; // Position below title, above profile section
129
- firstPage.drawImage(nciLogoImage, {
130
- x: x,
131
- y: y,
132
- width: logoWidth,
133
- height: logoHeight,
134
- });
121
+ nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
135
122
  }
136
123
 
137
124
  // print company logo and profile picture
138
- if (profileImage && companyImage) {
125
+ if (nciLogoImage) {
126
+ // NCI project - use NCI logo instead of profile picture
127
+ safeSetImage(form, "ProfilePicture", nciLogoImage);
128
+ if (companyImage) {
129
+ safeSetImage(form, "HalfWidthLogo", companyImage);
130
+ } else {
131
+ safeSetImage(form, "HalfWidthLogo", mqLogo);
132
+ }
133
+ if (
134
+ payload.meta.profile_settings.techFirstName ||
135
+ payload.meta.profile_settings.techLastName
136
+ )
137
+ safeSetText(
138
+ form,
139
+ "TechName",
140
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
141
+ );
142
+ } else if (profileImage && companyImage) {
139
143
  safeSetImage(form, "ProfilePicture", profileImage);
140
144
  safeSetImage(form, "HalfWidthLogo", companyImage);
141
145
  if (
@@ -128,27 +128,31 @@ export async function getReport(payload, _test) {
128
128
  t.manifoldKey = manifoldKey;
129
129
  let textFields = getTextFields(payload, t);
130
130
 
131
- // For NCI projects (CoolMaxx/HeatMaxx), draw NCI logo between title and profile section
131
+ // For NCI projects (CoolMaxx/HeatMaxx), use NCI logo instead of profile picture (50% of cover size)
132
+ let nciLogoImage = null;
132
133
  if (isNCIProject(payload) && base64.nciLogo) {
133
- const nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
134
- const pages = pdfDoc.getPages();
135
- const firstPage = pages[0];
136
- const { width, height } = firstPage.getSize();
137
- // Draw NCI logo centered, below title and above profile/company section
138
- const logoWidth = 200;
139
- const logoHeight = logoWidth * (nciLogoImage.height / nciLogoImage.width);
140
- const x = (width - logoWidth) / 2;
141
- const y = height - 120; // Position below title, above profile section
142
- firstPage.drawImage(nciLogoImage, {
143
- x: x,
144
- y: y,
145
- width: logoWidth,
146
- height: logoHeight,
147
- });
134
+ nciLogoImage = await pdfDoc.embedPng(util._base64ToArrayBuffer(base64.nciLogo));
148
135
  }
149
136
 
150
137
  // print company logo and profile picture
151
- if (profileImage && companyImage) {
138
+ if (nciLogoImage) {
139
+ // NCI project - use NCI logo instead of profile picture
140
+ safeSetImage(form, "ProfilePicture", nciLogoImage);
141
+ if (companyImage) {
142
+ safeSetImage(form, "HalfWidthLogo", companyImage);
143
+ } else {
144
+ safeSetImage(form, "HalfWidthLogo", mqLogo);
145
+ }
146
+ if (
147
+ payload.meta.profile_settings.techFirstName ||
148
+ payload.meta.profile_settings.techLastName
149
+ )
150
+ safeSetText(
151
+ form,
152
+ "TechName",
153
+ `${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
154
+ );
155
+ } else if (profileImage && companyImage) {
152
156
  safeSetImage(form, "ProfilePicture", profileImage);
153
157
  safeSetImage(form, "HalfWidthLogo", companyImage);
154
158
  if (