@measurequick/measurequick-report-generator 1.2.104 → 1.2.106

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.104",
3
+ "version": "1.2.106",
4
4
  "description": "Generates PDF documents for various MeasureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@pdf-lib/fontkit": "^1.1.1",
11
+ "@pdf-lib/standard-fonts": "^1.0.0",
11
12
  "jspdf": "^1.5.3",
12
13
  "pdf-lib": "^1.16.0"
13
14
  },
@@ -11,14 +11,20 @@ import * as util from '../util.js';
11
11
 
12
12
  let embeddedIcons = {};
13
13
 
14
- export async function getReport(payload) {
14
+ export async function getReport(payload) { console.log(payload);
15
15
  try {
16
16
  let b64 = payload.tests.length < 2 ? pdf : pdf2;
17
-
18
17
  const pdfDoc = await PDFDocument.load(util._base64ToArrayBuffer(b64.base64));
19
-
20
18
  const form = pdfDoc.getForm();
21
19
 
20
+ // let text1 = "Lorem Ipsum \n is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
21
+ // const fontBytes = await fetch('https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf').then(res => res.arrayBuffer());
22
+ // pdfDoc.registerFontkit(fontkit);
23
+ // const customFont = await pdfDoc.embedFont(fontBytes);
24
+ // const textWidth = customFont.widthOfTextAtSize(text1, 12);
25
+ // const textHeight = customFont.heightAtSize(12);
26
+ // form.getTextField("Text1").setText(textWidth + " x " + textHeight);
27
+
22
28
  let labels = ["iconRangeHigh", "iconRangeLow", "iconRangeNormal", "iconTesto", "iconCalculator", "iconFieldpiece",
23
29
  "iconUei", "iconSporlanPro", "iconSporlanLegacy", "iconIconnect", "iconImanifold", "iconSensi", "iconDg8",
24
30
  "iconBluflame", "iconRedfish510", "iconRedfish510333", "iconRedfish550", "iconDg1000", "iconTrueflow", "iconThumbprintRed", "iconThumbprintGreen", "iconThumbprintYellow", "whiteBox"
@@ -103,40 +109,33 @@ export async function getReport(payload) {
103
109
 
104
110
  form.getTextField(`Block3-Title`).setText(payload.system_data.title3);
105
111
 
106
- // let caIndex = 0;
107
- // let header;
108
- // for (let colNum = 1; colNum < 4; colNum++) {
109
- // let row = 1;
110
- // let caMeas = payload.system_data.block3[caIndex];
111
- // if (caMeas && header == caMeas.ref) {
112
- // form.getTextField(`CA-Col${colNum}-Row${row}-Bold`).setText(`${caMeas.ref} (Cont.)`);
113
- // row++;
114
- // }
115
- // for (let rowNum = row; rowNum < 24; rowNum++) {
116
- // caMeas = payload.system_data.block3[caIndex];
117
- // if (caMeas && (payload.meta.report_type == 'CorrectiveMeasures' || (payload.meta.report_type == 'FullReport' && caMeas.ref != 'Condensate Drain System' && caMeas.ref != 'Outdoor Equipment' && caMeas.ref != 'Indoor Equipment' && caMeas.ref != 'Cooling Efficiency'))) {
118
- // if (header !== caMeas.ref) {
119
- // if (rowNum + 2 > 23) {
120
- // colNum++;
121
- // rowNum = 1;
122
- // } else {
123
- // if (rowNum != 1) rowNum++;
124
- // form.getTextField(`CA-Col${colNum}-Row${rowNum}-Bold`).setText(caMeas.ref);
125
- // rowNum++;
126
- // }
127
- // }
128
- // header = caMeas.ref;
129
- // form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.label);
130
- // caIndex++;
131
- // } else caIndex++;
132
- // }
133
- // }
134
-
135
- let loremIpsum = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
136
-
137
- let width = font.widthOfTextAtSize(loremIpsum, 12);
138
- form.getTextField(`Text1`).setText(loremIpsum);
139
- form.getTextField(`Text2`).setText(width+"");
112
+ let header, caIndex = 0;
113
+ for (let colNum = 1; colNum <= 3; colNum++) {
114
+ let row = 1;
115
+ let caMeas = payload.system_data.block3[caIndex];
116
+ if (caMeas && header == caMeas.ref) {
117
+ form.getTextField(`CA-Col${colNum}-Row${row}-Bold`).setText(`${caMeas.ref} (Cont.)`);
118
+ row++;
119
+ }
120
+ for (let rowNum = row; rowNum < 24; rowNum++) {
121
+ caMeas = payload.system_data.block3[caIndex];
122
+ if (caMeas && (payload.meta.report_type == 'CorrectiveMeasures' || (payload.meta.report_type == 'FullReport' && caMeas.ref != 'Condensate Drain System' && caMeas.ref != 'Outdoor Equipment' && caMeas.ref != 'Indoor Equipment' && caMeas.ref != 'Cooling Efficiency'))) {
123
+ if (header !== caMeas.ref) {
124
+ if (rowNum + 2 > 23) {
125
+ colNum++;
126
+ rowNum = 1;
127
+ } else {
128
+ if (rowNum != 1) rowNum++;
129
+ form.getTextField(`CA-Col${colNum}-Row${rowNum}-Bold`).setText(caMeas.ref);
130
+ rowNum++;
131
+ }
132
+ }
133
+ header = caMeas.ref;
134
+ form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.label);
135
+ caIndex++;
136
+ } else caIndex++;
137
+ }
138
+ }
140
139
 
141
140
  form.flatten();
142
141
  return await pdfDoc.saveAsBase64({