@measurequick/measurequick-report-generator 1.2.108 → 1.2.109
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
|
@@ -11,19 +11,15 @@ 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) {
|
|
15
15
|
try {
|
|
16
16
|
let b64 = payload.tests.length < 2 ? pdf : pdf2;
|
|
17
17
|
const pdfDoc = await PDFDocument.load(util._base64ToArrayBuffer(b64.base64));
|
|
18
18
|
const form = pdfDoc.getForm();
|
|
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.";
|
|
19
|
+
// TODO: Embed Proper Font From Local File -- Eliminate Remote Request
|
|
21
20
|
const fontBytes = await fetch('https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf').then(res => res.arrayBuffer());
|
|
22
21
|
pdfDoc.registerFontkit(fontkit);
|
|
23
22
|
const font = await pdfDoc.embedFont(fontBytes);
|
|
24
|
-
const textWidth = font.widthOfTextAtSize(text1, 12);
|
|
25
|
-
const textHeight = font.heightAtSize(12);
|
|
26
|
-
form.getTextField("Text1").setText(textWidth + " x " + textHeight);
|
|
27
23
|
|
|
28
24
|
let labels = ["iconRangeHigh", "iconRangeLow", "iconRangeNormal", "iconTesto", "iconCalculator", "iconFieldpiece",
|
|
29
25
|
"iconUei", "iconSporlanPro", "iconSporlanLegacy", "iconIconnect", "iconImanifold", "iconSensi", "iconDg8",
|
|
@@ -109,49 +105,25 @@ export async function getReport(payload) { console.log(payload);
|
|
|
109
105
|
|
|
110
106
|
form.getTextField(`Block3-Title`).setText(payload.system_data.title3);
|
|
111
107
|
|
|
112
|
-
let header
|
|
108
|
+
let header, text = "", maxWidth = 165, maxHeight = 362, col = 1, maxLines = 20; // TODO: Calculate Max Lines
|
|
113
109
|
for (let i = 0; i < payload.system_data.block3.length; i++) {
|
|
114
110
|
let action = payload.system_data.block3[i];
|
|
115
|
-
if (header != action.ref) text +=
|
|
111
|
+
if (header != action.ref) text += `\n${action.ref}\n`;
|
|
116
112
|
header = action.ref;
|
|
117
|
-
let textWidth = font.widthOfTextAtSize(action.label,
|
|
118
|
-
let textHeight = font.heightAtSize(
|
|
113
|
+
let textWidth = font.widthOfTextAtSize(action.label, 8);
|
|
114
|
+
let textHeight = font.heightAtSize(8);
|
|
119
115
|
let numLines = 1;
|
|
120
116
|
if (textWidth > maxWidth) {
|
|
121
117
|
numLines = textWidth / maxWidth;
|
|
122
118
|
let words = action.label.split(" ");
|
|
119
|
+
// TODO: Calculate Line & Column Splits
|
|
123
120
|
}
|
|
124
121
|
text += action.label + "\n";
|
|
122
|
+
if (true) { // TODO: Calculate Condition
|
|
123
|
+
form.getTextField(`Text${col}`).setText(text);
|
|
124
|
+
col++;
|
|
125
|
+
}
|
|
125
126
|
}
|
|
126
|
-
form.getTextField('Text2').setText(text);
|
|
127
|
-
|
|
128
|
-
// let header, caIndex = 0;
|
|
129
|
-
// for (let colNum = 1; colNum <= 3; colNum++) {
|
|
130
|
-
// let row = 1;
|
|
131
|
-
// let caMeas = payload.system_data.block3[caIndex];
|
|
132
|
-
// if (caMeas && header == caMeas.ref) {
|
|
133
|
-
// form.getTextField(`CA-Col${colNum}-Row${row}-Bold`).setText(`${caMeas.ref} (Cont.)`);
|
|
134
|
-
// row++;
|
|
135
|
-
// }
|
|
136
|
-
// for (let rowNum = row; rowNum < 24; rowNum++) {
|
|
137
|
-
// caMeas = payload.system_data.block3[caIndex];
|
|
138
|
-
// 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'))) {
|
|
139
|
-
// if (header !== caMeas.ref) {
|
|
140
|
-
// if (rowNum + 2 > 23) {
|
|
141
|
-
// colNum++;
|
|
142
|
-
// rowNum = 1;
|
|
143
|
-
// } else {
|
|
144
|
-
// if (rowNum != 1) rowNum++;
|
|
145
|
-
// form.getTextField(`CA-Col${colNum}-Row${rowNum}-Bold`).setText(caMeas.ref);
|
|
146
|
-
// rowNum++;
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
|
-
// header = caMeas.ref;
|
|
150
|
-
// form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.label);
|
|
151
|
-
// caIndex++;
|
|
152
|
-
// } else caIndex++;
|
|
153
|
-
// }
|
|
154
|
-
// }
|
|
155
127
|
|
|
156
128
|
form.flatten();
|
|
157
129
|
return await pdfDoc.saveAsBase64({
|
|
@@ -206,9 +206,7 @@ export async function getReport(payload, _test) {
|
|
|
206
206
|
form.flatten();
|
|
207
207
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
208
208
|
return pdfBase64;
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.log(error);
|
|
211
|
-
}
|
|
209
|
+
} catch (error) { }
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
function getTextFields(payload, test) {
|