@measurequick/measurequick-report-generator 1.2.103 → 1.2.105
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.
|
|
3
|
+
"version": "1.2.105",
|
|
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
|
},
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
PDFDocument
|
|
2
|
+
PDFDocument,
|
|
3
|
+
PDFFont,
|
|
4
|
+
StandardFonts
|
|
3
5
|
} from 'pdf-lib';
|
|
6
|
+
import fontkit from '@pdf-lib/fontkit';
|
|
4
7
|
import * as base64 from '../base-64/icons.js';
|
|
5
8
|
import * as pdf from '../base-64/corrective-measures-page.js';
|
|
6
9
|
import * as pdf2 from '../base-64/corrective-measures-page-2.js';
|
|
@@ -8,14 +11,23 @@ import * as util from '../util.js';
|
|
|
8
11
|
|
|
9
12
|
let embeddedIcons = {};
|
|
10
13
|
|
|
11
|
-
export async function getReport(payload) {
|
|
14
|
+
export async function getReport(payload) { console.log(payload);
|
|
12
15
|
try {
|
|
13
16
|
let b64 = payload.tests.length < 2 ? pdf : pdf2;
|
|
14
17
|
|
|
15
18
|
const pdfDoc = await PDFDocument.load(util._base64ToArrayBuffer(b64.base64));
|
|
16
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
|
+
|
|
17
27
|
const form = pdfDoc.getForm();
|
|
18
28
|
|
|
29
|
+
form.getTextField("Text1").setText(textWidth + " x " + textHeight);
|
|
30
|
+
|
|
19
31
|
let labels = ["iconRangeHigh", "iconRangeLow", "iconRangeNormal", "iconTesto", "iconCalculator", "iconFieldpiece",
|
|
20
32
|
"iconUei", "iconSporlanPro", "iconSporlanLegacy", "iconIconnect", "iconImanifold", "iconSensi", "iconDg8",
|
|
21
33
|
"iconBluflame", "iconRedfish510", "iconRedfish510333", "iconRedfish550", "iconDg1000", "iconTrueflow", "iconThumbprintRed", "iconThumbprintGreen", "iconThumbprintYellow", "whiteBox"
|
|
@@ -99,34 +111,34 @@ export async function getReport(payload) {
|
|
|
99
111
|
}
|
|
100
112
|
|
|
101
113
|
form.getTextField(`Block3-Title`).setText(payload.system_data.title3);
|
|
102
|
-
|
|
103
|
-
let header;
|
|
104
|
-
for (let colNum = 1; colNum
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
114
|
+
|
|
115
|
+
// let header, caIndex = 0;
|
|
116
|
+
// for (let colNum = 1; colNum <= 3; colNum++) {
|
|
117
|
+
// let row = 1;
|
|
118
|
+
// let caMeas = payload.system_data.block3[caIndex];
|
|
119
|
+
// if (caMeas && header == caMeas.ref) {
|
|
120
|
+
// form.getTextField(`CA-Col${colNum}-Row${row}-Bold`).setText(`${caMeas.ref} (Cont.)`);
|
|
121
|
+
// row++;
|
|
122
|
+
// }
|
|
123
|
+
// for (let rowNum = row; rowNum < 24; rowNum++) {
|
|
124
|
+
// caMeas = payload.system_data.block3[caIndex];
|
|
125
|
+
// 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'))) {
|
|
126
|
+
// if (header !== caMeas.ref) {
|
|
127
|
+
// if (rowNum + 2 > 23) {
|
|
128
|
+
// colNum++;
|
|
129
|
+
// rowNum = 1;
|
|
130
|
+
// } else {
|
|
131
|
+
// if (rowNum != 1) rowNum++;
|
|
132
|
+
// form.getTextField(`CA-Col${colNum}-Row${rowNum}-Bold`).setText(caMeas.ref);
|
|
133
|
+
// rowNum++;
|
|
134
|
+
// }
|
|
135
|
+
// }
|
|
136
|
+
// header = caMeas.ref;
|
|
137
|
+
// form.getTextField(`CA-Col${colNum}-Row${rowNum}`).setText(caMeas.label);
|
|
138
|
+
// caIndex++;
|
|
139
|
+
// } else caIndex++;
|
|
140
|
+
// }
|
|
141
|
+
// }
|
|
130
142
|
|
|
131
143
|
form.flatten();
|
|
132
144
|
return await pdfDoc.saveAsBase64({
|