@measurequick/measurequick-report-generator 1.1.41 → 1.1.42
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,9 +1,6 @@
|
|
|
1
1
|
import { PDFDocument } from 'pdf-lib';
|
|
2
|
-
import fontkit from '@pdf-lib/fontkit';
|
|
3
2
|
import * as base64 from '../base-64/icons.js';
|
|
4
|
-
import * as pdf from '../base-64/
|
|
5
|
-
|
|
6
|
-
const fs = require('fs');
|
|
3
|
+
import * as pdf from '../base-64/corrective-measures-page.js';
|
|
7
4
|
|
|
8
5
|
let embeddedIcons = {};
|
|
9
6
|
|
|
@@ -15,9 +12,56 @@ export async function getReport(payload) {
|
|
|
15
12
|
let labels = ["iconRangeHigh", "iconRangeLow", "iconRangeNormal", "iconTesto", "iconCalculator", "iconFieldpiece",
|
|
16
13
|
"iconUei", "iconSporlanPro", "iconSporlanLegacy", "iconIconnect", "iconImanifold", "iconSensi",
|
|
17
14
|
"iconBluflame", "iconRedfish510", "iconRedfish510333", "iconRedfish550", "iconDg1000", "iconTrueflow"];
|
|
18
|
-
|
|
15
|
+
for (let label of labels) embeddedIcons[label] = await pdfDoc.embedPng(_base64ToArrayBuffer(base64[label]));
|
|
16
|
+
|
|
17
|
+
form.getTextField(`Block1-Title`).setText(payload.titles.block1);
|
|
18
|
+
for (let rowNum = 1; rowNum < 12; rowNum++) {
|
|
19
|
+
let measurement = payload.system_data[`block1`][rowNum];
|
|
20
|
+
if (measurement) {
|
|
21
|
+
form.getTextField(`Block1-Row${rowNum}`).setText(`${payload.equipment[measurement.ref]}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
form.getTextField(`Block2-Title`).setText(payload.titles.block2);
|
|
26
|
+
for (let rowNum = 1; rowNum < 12; rowNum++) {
|
|
27
|
+
let measurement = payload.system_data[`block2`][rowNum];
|
|
28
|
+
if (measurement) {
|
|
29
|
+
form.getTextField(`Block2-Row${rowNum}-Col1`).setText(measurement.label);
|
|
30
|
+
form.getTextField(`Block2-Row${rowNum}-Col2`).setText(`${payload.equipment[measurement.ref]}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let caIndex = 0;
|
|
35
|
+
let header;
|
|
36
|
+
for (let colNum = 1; colNum < 4; colNum++) {
|
|
37
|
+
let caMeas = payload.system_data.block3[caIndex];
|
|
38
|
+
if (caMeas && header == caMeas.ref) {
|
|
39
|
+
form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(`${caMeas.ref} (Cont.)`);
|
|
40
|
+
rowNum++;
|
|
41
|
+
}
|
|
42
|
+
for (let rowNum = 1; rowNum < 24; rowNum++) {
|
|
43
|
+
caMeas = payload.system_data.block3[caIndex];
|
|
44
|
+
if (caMeas) {
|
|
45
|
+
if (header !== caMeas.ref) {
|
|
46
|
+
if (rowNum + 2 > 23) {
|
|
47
|
+
colNum++;
|
|
48
|
+
rowNum = 1;
|
|
49
|
+
} else {
|
|
50
|
+
if (rowNum != 1) rowNum++;
|
|
51
|
+
form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.ref);
|
|
52
|
+
rowNum++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
header = caMeas.ref;
|
|
56
|
+
form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.label);
|
|
57
|
+
caIndex++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
form.flatten();
|
|
63
|
+
return await pdfDoc.saveAsBase64({ dataUri: true });
|
|
19
64
|
|
|
20
|
-
|
|
21
65
|
}
|
|
22
66
|
|
|
23
67
|
function _base64ToArrayBuffer(base64) {
|