aspose.barcode 24.4.0 → 24.6.0
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/lib/AsposeBarcode.js +1 -1
- package/lib/Generation.js +321 -167
- package/lib/Joint.js +84 -7
- package/lib/Recognition.js +175 -235
- package/lib/{aspose-barcode-nodejs-24.4.jar → aspose-barcode-nodejs-24.6.jar} +0 -0
- package/package.json +1 -1
package/lib/Joint.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const java = require('java');
|
|
2
2
|
const fs = require("fs");
|
|
3
|
+
const URL = require('url');
|
|
4
|
+
const https = require('https');
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
function isPath(image)
|
|
@@ -15,19 +17,93 @@ function isPath(image)
|
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
function isValidURL(str) {
|
|
22
|
+
try {
|
|
23
|
+
new URL(str);
|
|
24
|
+
return true;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isBase64(str)
|
|
19
31
|
{
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
try
|
|
33
|
+
{
|
|
34
|
+
return (Buffer.from(str, 'base64').toString('base64')) === str;
|
|
35
|
+
}
|
|
36
|
+
catch (err)
|
|
37
|
+
{
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
22
41
|
|
|
23
|
-
|
|
42
|
+
function convertImageResourceToBase64(imageResource)
|
|
43
|
+
{
|
|
44
|
+
if(imageResource === null)
|
|
45
|
+
{
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
else if ((typeof imageResource === 'string') && (isBase64(imageResource)))
|
|
49
|
+
{
|
|
50
|
+
return imageResource;
|
|
51
|
+
}
|
|
52
|
+
else if (fs.existsSync(imageResource))
|
|
24
53
|
{
|
|
25
|
-
return fs.readFileSync(
|
|
54
|
+
return fs.readFileSync(imageResource).toString('base64');
|
|
55
|
+
}
|
|
56
|
+
throw new BarcodeException("Image is not available or this resouce is not supported!");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function convertDecodeTypeToFormattedDecodeType(decodeTypes)
|
|
60
|
+
{
|
|
61
|
+
if (decodeTypes === undefined || decodeTypes == null)
|
|
62
|
+
{
|
|
63
|
+
return [DecodeType.ALL_SUPPORTED_TYPES];
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
{
|
|
67
|
+
if(!Array.isArray(decodeTypes))
|
|
68
|
+
decodeTypes = [decodeTypes];
|
|
69
|
+
|
|
70
|
+
for (let i = 0; i < decodeTypes.length; i++)
|
|
71
|
+
{
|
|
72
|
+
if(!Number.isInteger(decodeTypes[i]))
|
|
73
|
+
throw new Error("Unsuported decodeType format");
|
|
74
|
+
}
|
|
75
|
+
return decodeTypes;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function convertAreasToStringFormattedAreas(areas) // TODO move to Joint
|
|
80
|
+
{
|
|
81
|
+
let stringFormattedAreas = null;
|
|
82
|
+
if (areas != null)
|
|
83
|
+
{
|
|
84
|
+
stringFormattedAreas = [];
|
|
85
|
+
if(Array.isArray(areas))
|
|
86
|
+
{
|
|
87
|
+
if(!areas.every(area => area === null))
|
|
88
|
+
{
|
|
89
|
+
for(let i = 0; i < areas.length; i++)
|
|
90
|
+
{
|
|
91
|
+
let area = areas[i];
|
|
92
|
+
if (area === null || !(area instanceof Rectangle))
|
|
93
|
+
throw new BarcodeException('All elements of areas should be instances of Rectangle class');
|
|
94
|
+
stringFormattedAreas.push(area.toString());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
26
97
|
}
|
|
27
98
|
else
|
|
28
99
|
{
|
|
29
|
-
|
|
100
|
+
if (!(areas instanceof Rectangle))
|
|
101
|
+
throw new BarcodeException('All elements of areas should be instances of Rectangle class');
|
|
102
|
+
stringFormattedAreas.push(areas.toString());
|
|
103
|
+
}
|
|
104
|
+
stringFormattedAreas = stringFormattedAreas.length > 0 ? stringFormattedAreas : null
|
|
30
105
|
}
|
|
106
|
+
return stringFormattedAreas;
|
|
31
107
|
}
|
|
32
108
|
|
|
33
109
|
class BaseJavaClass
|
|
@@ -484,5 +560,6 @@ class BuildVersionInfo
|
|
|
484
560
|
}
|
|
485
561
|
|
|
486
562
|
module.exports = {
|
|
487
|
-
BaseJavaClass, BarcodeException, Rectangle, Point, License, BuildVersionInfo, isPath,
|
|
563
|
+
BaseJavaClass, BarcodeException, Rectangle, Point, License, BuildVersionInfo, isPath, convertImageResourceToBase64,
|
|
564
|
+
convertDecodeTypeToFormattedDecodeType, convertAreasToStringFormattedAreas
|
|
488
565
|
};
|