ebta-workflow-prod 4.0.8 → 4.0.10
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/build/activitypack.json +1 -1
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/src/activities/PDFMapGenerator.ts +48 -13
package/package.json
CHANGED
|
@@ -93,6 +93,11 @@ interface PDFMapGeneratorInputs {
|
|
|
93
93
|
* @description specific type name of print template, e.g.'VMP'
|
|
94
94
|
*/
|
|
95
95
|
template: string;
|
|
96
|
+
/**
|
|
97
|
+
* @displayName Object to provide extra field detail, by key-value(string)
|
|
98
|
+
* @description Object to provide extra field detail, by key-value(string)
|
|
99
|
+
*/
|
|
100
|
+
extraField: object;
|
|
96
101
|
}
|
|
97
102
|
/** An interface that defines the outputs of the activity. */
|
|
98
103
|
interface PDFMapGeneratorOutputs {
|
|
@@ -237,10 +242,10 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
237
242
|
const image3url = 'https://cdn.jsdelivr.net/npm/ebta-resources/resources/prints/dbyd.png'
|
|
238
243
|
const imageBarurl = 'https://cdn.jsdelivr.net/npm/ebta-resources/resources/prints/Scalebar.png'
|
|
239
244
|
const imageNorthUrl = 'https://cdn-icons-png.flaticon.com/512/3236/3236586.png'
|
|
245
|
+
const image10kmurl = 'https://ebta.maps.arcgis.com/sharing/rest/content/items/c15211b9826549f69a13c3f3d32a841b/resources/resources/prints/speedlimit10PNG.png'
|
|
240
246
|
let image10Buffer, image1Buffer, image2Buffer, image3Buffer
|
|
241
247
|
|
|
242
248
|
if (inputs.template == 'VMP') {
|
|
243
|
-
const image10kmurl = 'https://ebta.maps.arcgis.com/sharing/rest/content/items/c15211b9826549f69a13c3f3d32a841b/resources/vmp_symbols/speedlimit10.svg'
|
|
244
249
|
image10Buffer = await this.fetchData(image10kmurl);
|
|
245
250
|
console.log('Image10 fetched successfully');
|
|
246
251
|
}
|
|
@@ -267,21 +272,23 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
267
272
|
let newPage = doc.getPage(0)
|
|
268
273
|
let imgBase64 = imgBase64Array[i]
|
|
269
274
|
let imageBuffer = this.base64ToArrayBuffer(imgBase64);
|
|
270
|
-
console.log(`Image ${i} data processed successfully`);
|
|
271
275
|
let image;
|
|
272
276
|
if (imgBase64.startsWith('data:image/png;base64,')) {
|
|
273
277
|
image = await doc.embedPng(imageBuffer);
|
|
274
278
|
} else if (imgBase64.startsWith('data:image/jpeg;base64,') || imgBase64.startsWith('data:image/jpg;base64,')) {
|
|
275
279
|
image = await doc.embedJpg(imageBuffer);
|
|
276
280
|
}
|
|
281
|
+
console.log(`Main Image ${i} data processed successfully`);
|
|
277
282
|
let image1, image2, image3, image10
|
|
278
283
|
if (inputs.template == 'VMP') {
|
|
279
284
|
image10 = await doc.embedPng(image10Buffer);
|
|
285
|
+
console.log('image10 embed successfully')
|
|
280
286
|
}
|
|
281
287
|
else {
|
|
282
288
|
image1 = await doc.embedPng(image1Buffer);
|
|
283
289
|
image2 = await doc.embedPng(image2Buffer);
|
|
284
290
|
image3 = await doc.embedPng(image3Buffer);
|
|
291
|
+
console.log('image1,2,3 embed successfully')
|
|
285
292
|
}
|
|
286
293
|
const imageBar = await doc.embedPng(imageBarBuffer);
|
|
287
294
|
const imageNorth = await doc.embedPng(imageNorthBuffer);
|
|
@@ -292,6 +299,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
292
299
|
} else if (inputs.LegendImgBase64.startsWith('data:image/jpeg;base64,') || inputs.LegendImgBase64.startsWith('data:image/jpg;base64,')) {
|
|
293
300
|
legendImage = await doc.embedJpg(legendBuffer);
|
|
294
301
|
}
|
|
302
|
+
console.log('legend image embed successfully')
|
|
295
303
|
}
|
|
296
304
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
297
305
|
newPage.drawImage(image, {
|
|
@@ -300,6 +308,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
300
308
|
width: width * 0.8113,
|
|
301
309
|
height: height * 0.8029,
|
|
302
310
|
});
|
|
311
|
+
console.log('map image drawn successfully')
|
|
303
312
|
if (inputs.LegendImgBase64) {
|
|
304
313
|
//Define position & size of legend screeshot, depent on width/height ratio
|
|
305
314
|
if (legendImage.width / legendImage.height > 0.259) {
|
|
@@ -455,15 +464,17 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
455
464
|
});
|
|
456
465
|
}
|
|
457
466
|
}
|
|
467
|
+
console.log('legend image drawn successfully')
|
|
458
468
|
}
|
|
459
469
|
const lableSize = 100
|
|
460
470
|
if (inputs.template == 'VMP') {
|
|
461
471
|
newPage.drawImage(image10, {
|
|
462
|
-
x: 28+200,
|
|
472
|
+
x: 28 + 200,
|
|
463
473
|
y: 145,
|
|
464
474
|
width: lableSize,
|
|
465
475
|
height: lableSize * (image10.height / image10.width),
|
|
466
476
|
});
|
|
477
|
+
console.log('image10 drawn successfully')
|
|
467
478
|
}
|
|
468
479
|
else {
|
|
469
480
|
newPage.drawImage(image1, {
|
|
@@ -484,6 +495,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
484
495
|
width: lableSize * .8,
|
|
485
496
|
height: lableSize * .8 * (image3.height / image3.width),
|
|
486
497
|
});
|
|
498
|
+
console.log('image1,2,3 drawn successfully')
|
|
487
499
|
}
|
|
488
500
|
console.log(`success in page. ${i} `)
|
|
489
501
|
// north arrow
|
|
@@ -559,6 +571,18 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
559
571
|
const revField = form.getTextField('Rev.' + i)
|
|
560
572
|
revField.setText(inputs.Rev)
|
|
561
573
|
revField.updateAppearances(font)
|
|
574
|
+
if (inputs.template=='VMP'){
|
|
575
|
+
//supervisor
|
|
576
|
+
const supervisorField = form.getTextField('Supervisor')
|
|
577
|
+
supervisorField.setText(inputs.extraField['supervisor'])
|
|
578
|
+
supervisorField.setAlignment(TextAlignment.Center)
|
|
579
|
+
supervisorField.updateAppearances(font)
|
|
580
|
+
//UHF
|
|
581
|
+
const uhfField = form.getTextField('UHF')
|
|
582
|
+
uhfField.setText(inputs.extraField['UHF'])
|
|
583
|
+
uhfField.setAlignment(TextAlignment.Center)
|
|
584
|
+
uhfField.updateAppearances(font)
|
|
585
|
+
}
|
|
562
586
|
//date
|
|
563
587
|
const today = new Date();
|
|
564
588
|
const formattedDate = today.toLocaleDateString('en-AU');
|
|
@@ -588,6 +612,24 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
588
612
|
}
|
|
589
613
|
console.log('Text Fields removal successful')
|
|
590
614
|
//draw a QR Code image only when Qr URL is given && QR image not given
|
|
615
|
+
const boldFont = await doc.embedFont(StandardFonts.HelveticaBold);
|
|
616
|
+
|
|
617
|
+
if (inputs.template == 'VMP') {
|
|
618
|
+
newPage.drawText('Maximum Speed 10KM/h within Work Area', {
|
|
619
|
+
x: 28+150,
|
|
620
|
+
y: 145,
|
|
621
|
+
size: 10.5,
|
|
622
|
+
color: rgb(255, 255, 255), // White color
|
|
623
|
+
font: boldFont,
|
|
624
|
+
});
|
|
625
|
+
newPage.drawText('Maximum Speed 10KM/h within Work Area', {
|
|
626
|
+
x: 28+151,
|
|
627
|
+
y: 145,
|
|
628
|
+
size: 10,
|
|
629
|
+
color: rgb(255, 0, 0), // red color
|
|
630
|
+
font: boldFont,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
591
633
|
|
|
592
634
|
if (inputs.buttonLink && inputs.buttonLink.length > 0) {
|
|
593
635
|
const buttonX = width * 0.74
|
|
@@ -603,7 +645,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
603
645
|
width: buttonW,
|
|
604
646
|
height: buttonH,
|
|
605
647
|
});
|
|
606
|
-
|
|
648
|
+
|
|
607
649
|
newPage.drawText('Go to EBTA GIS', {
|
|
608
650
|
x: buttonX + 5,
|
|
609
651
|
y: buttonY + 22,
|
|
@@ -611,15 +653,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
611
653
|
color: rgb(1, 1, 1), // White color
|
|
612
654
|
font: boldFont,
|
|
613
655
|
});
|
|
614
|
-
|
|
615
|
-
newPage.drawText('All must operate under', {
|
|
616
|
-
x: 28,
|
|
617
|
-
y: 145,
|
|
618
|
-
size: 10,
|
|
619
|
-
color: rgb(255, 255, 255), // White color
|
|
620
|
-
font: boldFont,
|
|
621
|
-
});
|
|
622
|
-
}
|
|
656
|
+
|
|
623
657
|
|
|
624
658
|
const existingAnnots = newPage.node.lookup(PDFName.of('Annots'));
|
|
625
659
|
let annotationsArray = existingAnnots instanceof PDFArray ? existingAnnots : doc.context.obj([]);
|
|
@@ -755,6 +789,7 @@ export default class PDFMapGeneratorActivity implements IActivityHandler {
|
|
|
755
789
|
|
|
756
790
|
const pdfBytes = await finalPDF.save();
|
|
757
791
|
const base64String = this.arrayBufferToBase64(pdfBytes);
|
|
792
|
+
//was and still working fine, ignore the bug report
|
|
758
793
|
const downloadUrl = this.createDownloadUrl(base64String);
|
|
759
794
|
console.log('pdf file created and ready to download');
|
|
760
795
|
return {
|