aspose.barcode 26.2.0 → 26.4.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.
@@ -0,0 +1,231 @@
1
+ const ea = require("./ExamplesAssist")
2
+ const aspose_barcode = ea.aspose_barcode
3
+ let BarcodeGenerator = aspose_barcode.BarcodeGenerator;
4
+ let EncodeTypes = aspose_barcode.EncodeTypes;
5
+
6
+ class BarcodeGeneratorExamples
7
+ {
8
+ subfolder = "resources/generating/";
9
+
10
+ howToGenerateBarcodeImage()
11
+ {
12
+ console.log("\n---\nfunction '" + this.howToGenerateBarcodeImage.name + "'\n");
13
+ let encode_type = EncodeTypes.CODE_128;
14
+ let generator = new BarcodeGenerator(encode_type, null);
15
+ generator.setCodeText("123ABC");
16
+ generator.save(this.subfolder + "howToGenerateBarcodeImage.png", aspose_barcode.BarCodeImageFormat.PNG);
17
+ console.log("image saved to " + this.subfolder + "howToGenerateBarcodeImage.png");
18
+ }
19
+
20
+ howToSave()
21
+ {
22
+ console.log("\n---\nfunction '" + this.howToSave.name + "'\n");
23
+ let type_expected = EncodeTypes.AZTEC;
24
+ let code_text_expected = "123678943";
25
+ let generator = new BarcodeGenerator(type_expected, code_text_expected);
26
+ generator.save(this.subfolder + "howToSave.png", aspose_barcode.BarCodeImageFormat.PNG);
27
+ console.log("image saved to " + this.subfolder + "howToSave.png");
28
+ }
29
+
30
+ howToGenerateBase64Image()
31
+ {
32
+ let gen = new BarcodeGenerator(EncodeTypes.MACRO_PDF_417, "1234567");
33
+ let base64EncodedImage = gen.generateBarCodeImage(aspose_barcode.BarCodeImageFormat.PNG);
34
+ ea.saveImageBase64(base64EncodedImage, this.subfolder + "howToGenerateBase64Image.png")
35
+ console.log("image saved to " + this.subfolder + "howToGenerateBase64Image.png");
36
+ }
37
+
38
+ howToSetBarcodeType()
39
+ {
40
+ console.log("\n---\nfunction '" + this.howToSetBarcodeType.name + "'\n");
41
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_128, "12367891011");
42
+ let type_expected = EncodeTypes.CODABAR;
43
+ generator.setBarcodeType(type_expected);
44
+ generator.save(this.subfolder + "howToSetBarcodeType.png", aspose_barcode.BarCodeImageFormat.PNG);
45
+ let type_actual = generator.getBarcodeType();
46
+ console.log("type_expected = " + type_expected + "\n");
47
+ console.log("type_actual = " + type_actual + "\n");
48
+ console.log("image saved to " + this.subfolder + "howToSetBarcodeType.png");
49
+ }
50
+
51
+ howToGetCodeText()
52
+ {
53
+ console.log("\n---\nfunction '" + this.howToGetCodeText.name + "'\n");
54
+ let expected = "1234567890DCBV";
55
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_128, expected);
56
+ generator.save(this.subfolder + "howToGetCodeText.png", aspose_barcode.BarCodeImageFormat.PNG);
57
+ console.log("CodeText = " + generator.getCodeText());
58
+ console.log("image saved to " + this.subfolder + "howToGetCodeText.png");
59
+
60
+ }
61
+
62
+ howToGenerateOneD()
63
+ {
64
+ console.log("\n---\nfunction '" + this.howToGenerateOneD.name + "'\n");
65
+ let codeText = '01234567';
66
+ let encodeType = EncodeTypes.CODE_39;
67
+ let generator = new BarcodeGenerator(encodeType, codeText);
68
+ generator.save(this.subfolder + "howToGenerateOneD.png", aspose_barcode.BarCodeImageFormat.PNG);
69
+ console.log("image saved to " + this.subfolder + "howToGenerateOneD.png");
70
+ }
71
+
72
+ howToGenerateTwoD()
73
+ {
74
+ console.log("\n---\nfunction '" + this.howToGenerateTwoD.name + "'\n");
75
+ let codeText = '01234567';
76
+ let encodeType = EncodeTypes.QR;
77
+ let generator = new BarcodeGenerator(encodeType, codeText);
78
+ generator.save(this.subfolder + "howToGenerateTwoD.png", aspose_barcode.BarCodeImageFormat.PNG);
79
+ console.log("image saved to " + this.subfolder + "howToGenerateTwoD.png");
80
+ }
81
+
82
+ howToSetBackColor()
83
+ {
84
+ console.log("\n---\nfunction '" + this.howToSetBackColor.name + "'\n");
85
+ let color_expected = "#FF0000";
86
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
87
+ generator.getParameters().setBackColor(color_expected);
88
+ let color_actual = generator.getParameters().getBackColor();
89
+ generator.save(this.subfolder + "howToSetBackColor.png", aspose_barcode.BarCodeImageFormat.PNG);
90
+ console.log("color_expected = " + color_expected + "\n");
91
+ console.log("color_actual = " + color_actual + "\n");
92
+ console.log("image saved to " + this.subfolder + "howToSetBackColor.png");
93
+ }
94
+
95
+ howToGetDefaultBackColor()
96
+ {
97
+ console.log("\n---\nfunction '" + this.howToGetDefaultBackColor.name + "'\n");
98
+ let color_expected = "#FFFFFF";
99
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
100
+ let color_actual = generator.getParameters().getBackColor();
101
+ generator.save(this.subfolder + "howToGetDefaultBackColor.png", aspose_barcode.BarCodeImageFormat.PNG);
102
+ console.log("color_expected = " + color_expected + "\n");
103
+ console.log("color_actual = " + color_actual + "\n");
104
+ console.log("image saved to " + this.subfolder + "howToGetDefaultBackColor.png");
105
+ }
106
+
107
+ howToGetDefaultBarColor()
108
+ {
109
+ console.log("\n---\nfunction '" + this.howToGetDefaultBarColor.name + "'\n");
110
+ let color_expected = "#000000";
111
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
112
+ let color_actual = generator.getParameters().getBarcode().getBarColor();
113
+ generator.save(this.subfolder + "howToGetDefaultBarColor.png", aspose_barcode.BarCodeImageFormat.PNG);
114
+ console.log("color_expected = " + color_expected + "\n");
115
+ console.log("color_actual = " + color_actual + "\n");
116
+ console.log("image saved to " + this.subfolder + "howToGetDefaultBarColor.png");
117
+ }
118
+
119
+ howToSetBarColor()
120
+ {
121
+ console.log("\n---\nfunction '" + this.howToSetBarColor.name + "'\n");
122
+ let color_expected = "#FA00AA";
123
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
124
+ generator.getParameters().getBarcode().setBarColor(color_expected);
125
+ let color_actual = generator.getParameters().getBarcode().getBarColor();
126
+ generator.save(this.subfolder + "howToSetBarColor.png", aspose_barcode.BarCodeImageFormat.PNG);
127
+ console.log("color_expected = " + color_expected + "\n");
128
+ console.log("color_actual = " + color_actual + "\n");
129
+ console.log("image saved to " + this.subfolder + "howToSetBarColor.png");
130
+ }
131
+
132
+ howToSetCodeText()
133
+ {
134
+ console.log("\n---\nfunction '" + this.howToSetCodeText.name + "'\n");
135
+ let encode_type = EncodeTypes.CODE_128;
136
+ let generator = new BarcodeGenerator(encode_type, null);
137
+ let expected = "555777";
138
+ generator.setCodeText(expected);
139
+ let actual = generator.getCodeText();
140
+ generator.save(this.subfolder + "howToSetCodeText.png", aspose_barcode.BarCodeImageFormat.PNG);
141
+ console.log("CodeText actual = " + actual + "\n");
142
+ console.log("CodeText expected = " + expected + "\n");
143
+ console.log("image saved to " + this.subfolder + "howToSetCodeText.png");
144
+ }
145
+
146
+
147
+ howToGetBarcodeTypeAndCodeText()
148
+ {
149
+ console.log("\n---\nfunction '" + this.howToGetBarcodeTypeAndCodeText.name + "'\n");
150
+ let encode_type_expected = EncodeTypes.AZTEC;
151
+ let code_text_expected = "444555777665";
152
+ let generator = new BarcodeGenerator(encode_type_expected, code_text_expected);
153
+ let encode_type_actual = generator.getBarcodeType();
154
+ let code_text_actual = generator.getCodeText();
155
+ generator.save(this.subfolder + "howToGetBarcodeTypeAndCodeText.png", aspose_barcode.BarCodeImageFormat.PNG);
156
+ console.log("code text actual = " + code_text_actual + "\n");
157
+ console.log("code text expected = " + code_text_expected + "\n");
158
+ console.log("encode type actual = " + encode_type_actual + "\n");
159
+ console.log("encode type expected = " + encode_type_expected + "\n");
160
+ console.log("image saved to " + this.subfolder + "howToGetBarcodeTypeAndCodeText.png");
161
+ }
162
+
163
+ howToGetDefaultDashStyle()
164
+ {
165
+ console.log("\n---\nfunction '" + this.howToGetDefaultDashStyle.name + "'\n");
166
+ let dash_style_expected = BorderDashStyle.SOLID;
167
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
168
+ let dash_style_actual = generator.getParameters().getBorder().getDashStyle();
169
+ generator.save(this.subfolder + "howToGetDefaultDashStyle.png", aspose_barcode.BarCodeImageFormat.PNG);
170
+ console.log("dash_style_actual = " + dash_style_actual + "\n");
171
+ console.log("dash_style_expected" + dash_style_expected + "\n");
172
+ console.log("image saved to " + this.subfolder + "howToGetDefaultDashStyle.png");
173
+ }
174
+
175
+ howToDefaultBorderColor()
176
+ {
177
+ console.log("\n---\nfunction '" + this.howToDefaultBorderColor.name + "'\n");
178
+ let border_color_expected = "#000000";
179
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
180
+ let border_color_actual = generator.getParameters().getBorder().getColor();
181
+ generator.save(this.subfolder + "howToDefaultBorderColor.png", aspose_barcode.BarCodeImageFormat.PNG);
182
+ console.log("border_color_expected = " + border_color_expected + "\n");
183
+ console.log("border_color_actual = " + border_color_actual + "\n");
184
+ console.log("image saved to " + this.subfolder + "howToDefaultBorderColor.png");
185
+ }
186
+
187
+ howToSetBorderColor()
188
+ {
189
+ console.log("\n---\nfunction '" + this.howToSetBorderColor.name + "'\n");
190
+ let border_color_expected = "#AA00BB";
191
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_39, '01234567');
192
+ generator.getParameters().getBorder().setColor(border_color_expected);
193
+ let border_color_actual = generator.getParameters().getBorder().getColor();
194
+ generator.save(this.subfolder + "howToSetBorderColor.png", aspose_barcode.BarCodeImageFormat.PNG);
195
+ console.log("border_color_expected = " + border_color_expected + "\n");
196
+ console.log("border_color_actual = " + border_color_actual + "\n");
197
+ }
198
+
199
+ howToSetFont()
200
+ {
201
+ console.log("\n---\nfunction '" + this.howToSetFont.name + "'\n");
202
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_128, null);
203
+ generator.getParameters().getCaptionAbove().setText("CAPTION ABOOVE");
204
+ generator.getParameters().getCaptionAbove().setVisible(true);
205
+ generator.getParameters().getCaptionAbove().getFont().setStyle(FontStyle.ITALIC);
206
+ generator.getParameters().getCaptionAbove().getFont().getSize().setPoint(5);
207
+ let save_path = this.subfolder + "howToSetFont.bmp";
208
+ generator.save(save_path, aspose_barcode.BarCodeImageFormat.BMP);
209
+ console.log("image saved to " + save_path);
210
+ }
211
+ }
212
+
213
+ ea.setLicense();
214
+ let barcodeGeneratorExamples = new BarcodeGeneratorExamples();
215
+ barcodeGeneratorExamples.howToGenerateBarcodeImage();
216
+ barcodeGeneratorExamples.howToGenerateBase64Image();
217
+ barcodeGeneratorExamples.howToGetCodeText();
218
+ barcodeGeneratorExamples.howToGenerateOneD();
219
+ barcodeGeneratorExamples.howToGenerateTwoD();
220
+ barcodeGeneratorExamples.howToSetBackColor();
221
+ barcodeGeneratorExamples.howToGetDefaultBackColor();
222
+ barcodeGeneratorExamples.howToGetDefaultBarColor();
223
+ barcodeGeneratorExamples.howToSetBarColor();
224
+ barcodeGeneratorExamples.howToSetCodeText();
225
+ barcodeGeneratorExamples.howToGetBarcodeTypeAndCodeText();
226
+ barcodeGeneratorExamples.howToGetDefaultDashStyle();
227
+ barcodeGeneratorExamples.howToDefaultBorderColor();
228
+ barcodeGeneratorExamples.howToSetBorderColor();
229
+ barcodeGeneratorExamples.howToSave();
230
+ barcodeGeneratorExamples.howToSetBarcodeType();
231
+ barcodeGeneratorExamples.howToSetFont();
@@ -0,0 +1,198 @@
1
+ const ea = require("./ExamplesAssist")
2
+ const aspose_barcode = ea.aspose_barcode
3
+ let BarCodeReader = aspose_barcode.BarCodeReader;
4
+ let BarcodeGenerator = aspose_barcode.BarcodeGenerator;
5
+ let EncodeTypes = aspose_barcode.EncodeTypes;
6
+ let QualitySettings = aspose_barcode.QualitySettings;
7
+
8
+ class BarCodeReaderExamples
9
+ {
10
+ subfolder = "resources/recognition/";
11
+
12
+ howToReadFromFile()
13
+ {
14
+ console.log("\n---\nfunction '" + this.howToReadFromFile.name + "'\n");
15
+ let file_name = "code11.png";
16
+ let full_path = this.subfolder + file_name;
17
+ let reader = new BarCodeReader(full_path, null, null);
18
+ reader.readBarCodes().forEach(function (result, i, results)
19
+ {
20
+ console.log(result.getCodeText());
21
+
22
+ console.log(result.getCodeTypeName());
23
+ });
24
+
25
+ }
26
+
27
+ howToReadImageBytes()
28
+ {
29
+ let fileName = "code11.png";
30
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, null);
31
+ reader.readBarCodes().forEach(function (result, i, results)
32
+ {
33
+ console.log(result.getCodeText());
34
+
35
+ console.log(result.getCodeTypeName());
36
+ });
37
+ }
38
+
39
+ howToSetQualitySettings()
40
+ {
41
+ console.log("\n---\nfunction '" + this.howToSetQualitySettings.name + "'\n");
42
+ let file_name = "code11.png";
43
+ let full_path = this.subfolder + file_name;
44
+ let reader = new BarCodeReader(full_path, null, null);
45
+ reader.setQualitySettings(QualitySettings.getHighPerformance());
46
+
47
+ reader.readBarCodes().forEach(function (result, i, results)
48
+ {
49
+ console.log(result.getCodeText());
50
+
51
+ console.log(result.getCodeTypeName());
52
+ });
53
+
54
+ }
55
+
56
+
57
+ howToGetCodeBytes()
58
+ {
59
+ console.log("\n---\nfunction '" + this.howToGetCodeBytes.name + "'\n");
60
+ let expectedCodeBytes = ["105", "99", "70", "1", "61", "0", "0", "2", "70", "10", "82", "20", "40", "0", "97", "106"];
61
+ let fileName = "example2.jpg";
62
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, null);
63
+ reader.readBarCodes().forEach(function (result, i, results)
64
+ {
65
+ let actualCodeBytes = result.getCodeBytes();
66
+ console.log("expected code bytes : " + expectedCodeBytes.length);
67
+
68
+ console.log("actual code bytes : " + actualCodeBytes.length);
69
+ });
70
+ }
71
+
72
+ howToRecognitionCode128()
73
+ {
74
+ console.log("\n---\nfunction '" + this.howToRecognitionCode128.name + "'\n");
75
+ try
76
+ {
77
+ let fileName = "code128.jpg";
78
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, DecodeType.CODE_128);
79
+ reader.readBarCodes().forEach(function (result, i, results)
80
+ {
81
+ console.log("Code Text : " + result.getCodeTypeName());
82
+
83
+ console.log("Code Type : " + result.getCodeText());
84
+ });
85
+
86
+ } catch (e)
87
+ {
88
+ console.log(e.getMessage());
89
+ }
90
+ }
91
+
92
+ howToRecognitionCode11()
93
+ {
94
+ console.log("\n---\nfunction '" + this.howToRecognitionCode11.name + "'\n");
95
+ try
96
+ {
97
+ let fileName = "code11.png";
98
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, DecodeType.CODE_11);
99
+ reader.readBarCodes().forEach(function (result, i, results)
100
+ {
101
+ console.log("Code Text : " + result.getCodeTypeName());
102
+
103
+ console.log("Code Type : " + result.getCodeText());
104
+ });
105
+
106
+ } catch (e)
107
+ {
108
+ console.log(e.getMessage());
109
+ }
110
+ }
111
+
112
+ howToRecognitionCodeAllSupportedTypes()
113
+ {
114
+ console.log("\n---\nfunction '" + this.howToRecognitionCodeAllSupportedTypes.name + "'\n");
115
+ try
116
+ {
117
+ let fileName = "example2.jpg";
118
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, DecodeType.ALL_SUPPORTED_TYPES);
119
+ reader.readBarCodes().forEach(function (result, i, results)
120
+ {
121
+ console.log("Code Text : " + result.getCodeTypeName());
122
+
123
+ console.log("Code Type : " + result.getCodeText());
124
+ });
125
+
126
+ } catch (e)
127
+ {
128
+ console.log(e.getMessage());
129
+ }
130
+ }
131
+
132
+ howToRecognitionCodeAllSupportedTypes2()
133
+ {
134
+ console.log("\n---\nfunction '" + this.howToRecognitionCodeAllSupportedTypes2.name + "'\n");
135
+ try
136
+ {
137
+ let fileName = "example1.png";
138
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, DecodeType.ALL_SUPPORTED_TYPES);
139
+ reader.readBarCodes().forEach(function (result, i, results)
140
+ {
141
+ console.log("Code Text : " + result.getCodeTypeName());
142
+ console.log("Code Type : " + result.getCodeText());
143
+ });
144
+
145
+ } catch (e)
146
+ {
147
+ console.log(e.getMessage());
148
+ }
149
+ }
150
+
151
+ howToRecognitionSetBarCodeImage()
152
+ {
153
+ console.log("\n---\nfunction '" + this.howToRecognitionSetBarCodeImage.name + "'\n");
154
+ let fileName = "code128.jpg";
155
+ let reader = new BarCodeReader(ea.loadImageByName(this.subfolder, fileName), null, DecodeType.ALL_SUPPORTED_TYPES);
156
+ reader.setBarCodeImage(this.subfolder + "code11.png", null);
157
+
158
+ reader.readBarCodes().forEach(function (result, i, results)
159
+ {
160
+ console.log("Code Text : " + result.getCodeTypeName());
161
+
162
+ console.log("Code Type : " + result.getCodeText());
163
+ });
164
+
165
+ }
166
+
167
+ howToMacroPdf417()
168
+ {
169
+ console.log("\n---\nfunction '" + this.howToMacroPdf417.name + "'\n");
170
+ let barcodeGenerator = new BarcodeGenerator(EncodeTypes.MACRO_PDF_417, null);
171
+ barcodeGenerator.setCodeText("codeSomecode");
172
+ barcodeGenerator.getParameters().getBarcode().getPdf417().setPdf417MacroFileID(15900);
173
+ barcodeGenerator.getParameters().getBarcode().getPdf417().setPdf417MacroSegmentID(2);
174
+ barcodeGenerator.getParameters().getBarcode().getPdf417().setPdf417MacroSegmentsCount(3);
175
+ let image = barcodeGenerator.generateBarCodeImage(aspose_barcode.BarCodeImageFormat.PNG);
176
+ let reader = new BarCodeReader((image), null, DecodeType.MACRO_PDF_417);
177
+ reader.readBarCodes().forEach(function (result, i, results)
178
+ {
179
+ console.log("CodeText : " + result.getCodeText());
180
+ console.log("getMacroPdf417FileID : " + result.getExtended().getPdf417().getMacroPdf417FileID() + "\n");
181
+ console.log("getMacroPdf417SegmentID : " + result.getExtended().getPdf417().getMacroPdf417SegmentID() + "\n");
182
+ console.log('getMacroPdf417SegmentsCount : ' + result.getExtended().getPdf417().getMacroPdf417SegmentsCount() + "\n");
183
+ });
184
+ }
185
+ }
186
+
187
+ ea.setLicense();
188
+ let barCodeReaderExamples = new BarCodeReaderExamples();
189
+ barCodeReaderExamples.howToReadFromFile();
190
+ barCodeReaderExamples.howToReadImageBytes();
191
+ barCodeReaderExamples.howToSetQualitySettings();
192
+ barCodeReaderExamples.howToGetCodeBytes();
193
+ barCodeReaderExamples.howToRecognitionCode128();
194
+ barCodeReaderExamples.howToRecognitionCode11();
195
+ barCodeReaderExamples.howToRecognitionCodeAllSupportedTypes();
196
+ barCodeReaderExamples.howToRecognitionCodeAllSupportedTypes2();
197
+ barCodeReaderExamples.howToRecognitionSetBarCodeImage();
198
+ barCodeReaderExamples.howToMacroPdf417();
@@ -0,0 +1,75 @@
1
+ let libs_root = "../"
2
+ const index_path = libs_root + "index.js";
3
+ const barcode_ = require(index_path)
4
+ const aspose_barcode = barcode_.AsposeBarcode
5
+ //in case you obtained the lib from npmjs.com by calling the command "npm i aspose.barcode"
6
+ // replace all above lines by two lines
7
+ // const barcode_ = require("aspose.barcode");
8
+ // const aspose_barcode = barcode_.AsposeBarcode
9
+
10
+ const path_to_license_file = "./lic/Aspose.BarCode.NodeJsviaJava.lic";
11
+ const fs = require("fs");
12
+
13
+
14
+ function setLicense()
15
+ {
16
+ let license = new aspose_barcode.License();
17
+ if (fs.existsSync(path_to_license_file))
18
+ {
19
+ license.setLicense(path_to_license_file);
20
+ }
21
+ else
22
+ {
23
+ console.log("Path \"" + path_to_license_file + "\" doesn't exist\n");
24
+ }
25
+ let is_licensed = license.isLicensed();
26
+ console.log('is licensed: ' + is_licensed);
27
+ }
28
+
29
+ function isExists(file_path)
30
+ {
31
+ if (fs.existsSync(file_path))
32
+ {
33
+ console.log(file_path + " exists")
34
+ }
35
+ else
36
+ {
37
+ console.log(file_path + " doesn't exist")
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @param subFolder path to image
43
+ * @param fileName name of image
44
+ * @returns base64 encoded image
45
+ */
46
+ function loadImageByName(subFolder, fileName)
47
+ {
48
+ let filePath = subFolder + "/" + fileName;
49
+ try
50
+ {
51
+ return fs.readFileSync(filePath).toString('base64');
52
+ } catch (ex)
53
+ {
54
+ console.error(ex.toString());
55
+ }
56
+ }
57
+
58
+ function saveImageBase64(image64, path)
59
+ {
60
+ try
61
+ {
62
+ console.log("Will be saved to : " + path);
63
+ let image_bytes = Buffer.from(image64, 'base64');
64
+ fs.writeFileSync(path, image_bytes);
65
+ return fs.existsSync(path);
66
+ } catch (ex)
67
+ {
68
+ let barcode_exception = new barcodetestexception_.BarcodeTestException(ex);
69
+ throw barcode_exception;
70
+ }
71
+ }
72
+
73
+ module.exports = {
74
+ aspose_barcode, setLicense, isExists, loadImageByName, saveImageBase64
75
+ };
@@ -0,0 +1,25 @@
1
+ const fs = require("fs");
2
+ const ea = require("./ExamplesAssist")
3
+ const aspose_barcode = ea.aspose_barcode
4
+ let BarcodeGenerator = aspose_barcode.BarcodeGenerator;
5
+ let EncodeTypes = aspose_barcode.EncodeTypes;
6
+ let BarCodeReader = aspose_barcode.BarCodeReader;
7
+
8
+ function generateAndRead()
9
+ {
10
+ ea.setLicense();
11
+ let generator = new BarcodeGenerator(EncodeTypes.CODE_128, "12367891011");
12
+ let file_path = "resources/generating/setBarcodeType.png";
13
+ generator.save(file_path, aspose_barcode.BarCodeImageFormat.PNG);
14
+
15
+ let image_data_base64 = fs.readFileSync(file_path).toString('base64');
16
+ let reader = new BarCodeReader(image_data_base64, null, DecodeType.ALL_SUPPORTED_TYPES);
17
+
18
+ reader.readBarCodes().forEach(function(result, i, results)
19
+ {
20
+ console.log("Recognized barcode code text: " + result.getCodeText() + "\n");
21
+ console.log("Recognized barcode code type: " + result.getCodeTypeName() + "\n");
22
+ });
23
+ }
24
+
25
+ generateAndRead();
@@ -0,0 +1,15 @@
1
+ 1. If you're launching the tests outside of 'node_modules' folder, replace lines in 'ExamplesAssist.js'
2
+ Instead of first four lines should be added
3
+ const barcode_ = require("aspose.barcode");
4
+ const aspose_barcode = barcode_.AsposeBarcode
5
+ 2. Run command 'npm install'
6
+ 3. Put the license file 'Aspose.BarCode.NodeJsviaJava.lic' to the folder lic.
7
+ The expected name of the license file is Aspose.BarCode.NodeJsviaJava.lic.
8
+ You can change it by changing line 10 of ExampleAssist.js.
9
+ 4. Open and run every file consistently :
10
+ how_to_generate_and_read_example.js
11
+ how_to_generate_barcode_examples.js
12
+ how_to_read_barcode_examples.js
13
+ You can run them from the command line,
14
+ for example 'node how_to_generate_and_read_example.js.cmd'
15
+
@@ -0,0 +1,2 @@
1
+ node GenerateAndReadExample.js
2
+ pause 10
@@ -0,0 +1,2 @@
1
+ node BarcodeGeneratorExamples.js
2
+ pause 10
@@ -0,0 +1,2 @@
1
+ node BarcodeReaderExamples.js
2
+ pause 10
@@ -0,0 +1 @@
1
+ Place license to this folder
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "barcode.nodejs.examples",
3
+ "description": "Aspose.Barcode for Node.js via Java examples",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "author": "",
9
+ "license": "ISC",
10
+ "dependencies": {
11
+ "java": "^0.12.1"
12
+ }
13
+ }
@@ -0,0 +1 @@
1
+ Folder for generated files
@@ -4,7 +4,7 @@ const joint_ = require('./Joint');
4
4
  const complexbarcode_ = require("./ComplexBarcode");
5
5
  const generation_ = require("./Generation");
6
6
  const recognition_ = require("./Recognition");
7
- const jar_name_ = "/aspose-barcode-nodejs-26.2.jar";
7
+ const jar_name_ = "/aspose-barcode-nodejs-26.4.jar";
8
8
  const jar_path_ = __dirname + jar_name_;
9
9
  const fs = require("fs");
10
10
 
@@ -6,8 +6,6 @@ const joint = require('./Joint');
6
6
  const java = require('java');
7
7
  const aspose_barcode = require("./AsposeBarcode");
8
8
  const {BaseJavaClass} = require("./Joint");
9
- const {Base} = require("mocha/lib/reporters");
10
-
11
9
 
12
10
  /**
13
11
  * Interface for complex codetext used with ComplexBarcodeGenerator.
@@ -3340,7 +3338,11 @@ class SecondaryAndAdditionalData extends joint.BaseJavaClass
3340
3338
  */
3341
3339
  getExpiryDate()
3342
3340
  {
3343
- return new Date(this.getJavaClass().getExpiryDateSync() * 1000);
3341
+ const value = this.getJavaClass().getExpiryDateSync();
3342
+
3343
+ if (!value) return null;
3344
+
3345
+ return new Date(value);
3344
3346
  }
3345
3347
  /**
3346
3348
  * <p>
@@ -3349,7 +3351,12 @@ class SecondaryAndAdditionalData extends joint.BaseJavaClass
3349
3351
  */
3350
3352
  setExpiryDate(value)
3351
3353
  {
3352
- this.getJavaClass().setExpiryDateSync((value.getTime() / 1000).toString());
3354
+ if (!value) {
3355
+ this.getJavaClass().setExpiryDateSync(null);
3356
+ return;
3357
+ }
3358
+
3359
+ this.getJavaClass().setExpiryDateSync(value.toISOString());
3353
3360
  }
3354
3361
 
3355
3362
  /**
@@ -3405,7 +3412,11 @@ class SecondaryAndAdditionalData extends joint.BaseJavaClass
3405
3412
  */
3406
3413
  getDateOfManufacture()
3407
3414
  {
3408
- return new Date(this.getJavaClass().getDateOfManufactureSync() * 1000);
3415
+ const value = this.getJavaClass().getDateOfManufactureSync();
3416
+
3417
+ if (!value) return null;
3418
+
3419
+ return new Date(value);
3409
3420
  }
3410
3421
 
3411
3422
  /**
@@ -3417,7 +3428,13 @@ class SecondaryAndAdditionalData extends joint.BaseJavaClass
3417
3428
  */
3418
3429
  setDateOfManufacture(value)
3419
3430
  {
3420
- this.getJavaClass().setDateOfManufactureSync((value.getTime() / 1000).toString());
3431
+ if (!value)
3432
+ {
3433
+ this.getJavaClass().setDateOfManufactureSync(null);
3434
+ return;
3435
+ }
3436
+
3437
+ this.getJavaClass().setDateOfManufactureSync(value.toISOString());
3421
3438
  }
3422
3439
 
3423
3440
  /**
package/lib/Generation.js CHANGED
@@ -3699,7 +3699,11 @@ class Pdf417Parameters extends joint.BaseJavaClass
3699
3699
  */
3700
3700
  getMacroPdf417TimeStamp()
3701
3701
  {
3702
- return new Date(this.getJavaClass().getMacroPdf417TimeStampSync() * 1000);
3702
+ const value = this.getJavaClass().getMacroPdf417TimeStampSync();
3703
+
3704
+ if (!value) return null;
3705
+
3706
+ return new Date(value);
3703
3707
  }
3704
3708
 
3705
3709
  /**
@@ -3710,7 +3714,12 @@ class Pdf417Parameters extends joint.BaseJavaClass
3710
3714
  */
3711
3715
  setMacroPdf417TimeStamp(value)
3712
3716
  {
3713
- this.getJavaClass().setMacroPdf417TimeStampSync((value.getTime() / 1000).toString());
3717
+ if (!value)
3718
+ {
3719
+ this.getJavaClass().setMacroPdf417TimeStampSync(null);
3720
+ return;
3721
+ }
3722
+ this.getJavaClass().setMacroPdf417TimeStampSync(value.toISOString());
3714
3723
  }
3715
3724
 
3716
3725
  /**
@@ -3719,7 +3728,11 @@ class Pdf417Parameters extends joint.BaseJavaClass
3719
3728
  */
3720
3729
  getPdf417MacroTimeStamp()
3721
3730
  {
3722
- return new Date(this.getJavaClass().getPdf417MacroTimeStampSync() * 1000);
3731
+ const value = this.getJavaClass().getPdf417MacroTimeStampSync();
3732
+
3733
+ if (!value) return null;
3734
+
3735
+ return new Date(value);
3723
3736
  }
3724
3737
 
3725
3738
  /**
@@ -3728,7 +3741,12 @@ class Pdf417Parameters extends joint.BaseJavaClass
3728
3741
  */
3729
3742
  setPdf417MacroTimeStamp(value)
3730
3743
  {
3731
- this.getJavaClass().setPdf417MacroTimeStampSync((value.getTime() / 1000).toString());
3744
+ if (!value)
3745
+ {
3746
+ this.getJavaClass().setPdf417MacroTimeStampSync(null);
3747
+ return;
3748
+ }
3749
+ this.getJavaClass().setPdf417MacroTimeStampSync(value.toISOString());
3732
3750
  }
3733
3751
 
3734
3752
  /**
@@ -7146,45 +7164,86 @@ ITF14BorderType =
7146
7164
  QREncodeMode =
7147
7165
  {
7148
7166
  /**
7149
- * Encode codetext as is non-unicode charset. <br>
7150
- * If there is any unicode character, <br>
7151
- * the codetext will be encoded with value which is set in CodeTextEncoding.
7167
+ * In Auto mode, the CodeText is encoded with maximum data compactness.
7168
+ * Unicode characters are encoded in kanji mode if possible, or they are re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier.
7169
+ * If a character is found that is not supported by the selected ECI encoding, an exception is thrown.
7152
7170
  */
7153
7171
  AUTO: 0,
7172
+
7154
7173
  /**
7155
- * Encode codetext as plain bytes. If it detects any unicode character, the character will be encoded as two bytes, lower byte first.
7174
+ * Encode codetext as plain bytes. If it detects any Unicode character, the character will be encoded as two bytes, lower byte first.
7175
+ * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method to convert the message to byte array with specified encoding.
7156
7176
  */
7157
7177
  BYTES: 1,
7158
- //https://en.wikipedia.org/wiki/Byte_order_mark
7178
+
7159
7179
  /**
7160
7180
  * Encode codetext with UTF8 encoding with first ByteOfMark character.
7181
+ * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with UTF8 encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode.
7161
7182
  */
7162
7183
  UTF_8_BOM: 2,
7184
+
7185
+
7163
7186
  /**
7164
- * Encode codetext with UTF8 encoding with first ByteOfMark character. It can be problems with some barcode scaners.
7187
+ * Encode codetext with UTF8 encoding with first ByteOfMark character. It can be problems with some barcode scanners.
7188
+ * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'SetCodeText' method with BigEndianUnicode encoding to add a byte order mark (BOM) and encode the message. After that, the CodeText can be encoded using the 'Auto' mode.
7165
7189
  */
7166
7190
  UTF_16_BEBOM: 3,
7167
7191
 
7168
7192
  /**
7169
- * Encode codetext with value set in the ECI_ENCODING property. It can be problems with some old (pre 2006) barcode scaners.
7193
+ * Encode codetext with value set in the ECIEncoding property. It can be problems with some old (pre 2006) barcode scanners.
7194
+ * This mode is not supported by MicroQR barcodes.
7195
+ * @deprecated This property is obsolete and will be removed in future releases. Instead, use ECI option.
7170
7196
  */
7171
7197
  ECI_ENCODING: 4,
7172
7198
 
7173
7199
  /**
7174
- * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes.<br>
7175
- * It is better to use QrExtCodetextBuilder for extended codetext generation.<br>
7176
- * Use Display2DText property to set visible text to removing managing characters.<br>
7177
- * Encoding Principles:<br>
7178
- * All symbols "\" must be doubled "\\" in the codetext.<br>
7179
- * FNC1 in first position is set in codetext as as "&lt;FNC1&gt;"<br>
7180
- * FNC1 in second position is set in codetext as as "&lt;FNC1(value)&gt;". The value must be single symbols (a-z, A-Z) or digits from 0 to 99.<br>
7181
- * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' <br>
7182
- * If you need to insert "&lt;FNC1&gt;" string into barcode write it as "&lt;\FNC1&gt;" <br>
7183
- * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier<br>
7184
- * TO disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000"<br>
7185
- * All unicode characters after ECI identifier are automatically encoded into correct character codeset.<br>
7186
- */
7187
- EXTENDED_CODETEXT: 5
7200
+ * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes.</para>
7201
+ * It is better to use QrExtCodetextBuilder for extended codetext generation.</para>
7202
+ * Use Display2DText property to set visible text to removing managing characters.</para>
7203
+ * Encoding Principles:</para>
7204
+ * All symbols "\" must be doubled "\\" in the codetext.</para>
7205
+ * FNC1 in first position is set in codetext as as "&lt;FNC1&gt;"</para>
7206
+ * FNC1 in second position is set in codetext as as "&lt;FNC1(value)&gt;". The value must be single symbols (a-z, A-Z) or digits from 0 to 99.</para>
7207
+ * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' </para>
7208
+ * If you need to insert "&lt;FNC1&gt;" string into barcode write it as "&lt;\FNC1&gt;" </para>
7209
+ * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier</para>
7210
+ * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000"</para>
7211
+ * All unicode characters after ECI identifier are automatically encoded into correct character codeset.</para>
7212
+ * This mode is not supported by MicroQR barcodes.</para>
7213
+ * @deprecated This property is obsolete and will be removed in future releases. Instead, use the 'Extended' encode mode.
7214
+ */
7215
+ EXTENDED_CODETEXT: 5,
7216
+
7217
+ /**
7218
+ * Extended Channel mode which supports FNC1 first position, FNC1 second position and multi ECI modes.</para>
7219
+ * It is better to use QrExtCodetextBuilder for extended codetext generation.</para>
7220
+ * Use Display2DText property to set visible text to removing managing characters.</para>
7221
+ * Encoding Principles:</para>
7222
+ * All symbols "\" must be doubled "\\" in the codetext.</para>
7223
+ * FNC1 in first position is set in codetext as as "&lt;FNC1&gt;"</para>
7224
+ * FNC1 in second position is set in codetext as as "&lt;FNC1(value)&gt;". The value must be single symbols (a-z, A-Z) or digits from 0 to 99.</para>
7225
+ * Group Separator for FNC1 modes is set as 0x1D character '\\u001D' </para>
7226
+ * If you need to insert "&lt;FNC1&gt;" string into barcode write it as "&lt;\FNC1&gt;" </para>
7227
+ * ECI identifiers are set as single slash and six digits identifier "\000026" - UTF8 ECI identifier</para>
7228
+ * To disable current ECI mode and convert to default JIS8 mode zero mode ECI indetifier is set. "\000000"</para>
7229
+ * All unicode characters after ECI identifier are automatically encoded into correct character codeset.</para>
7230
+ * This mode is not supported by MicroQR barcodes.</para>
7231
+ */
7232
+ EXTENDED: 6,
7233
+
7234
+ /**
7235
+ * In Binary mode, the CodeText is encoded with maximum data compactness.
7236
+ * If a Unicode character is found, an exception is thrown.
7237
+ */
7238
+ BINARY: 7,
7239
+
7240
+ /**
7241
+ * In ECI mode, the entire message is re-encoded in the ECIEncoding specified encoding with the insertion of an ECI identifier.
7242
+ * If a character is found that is not supported by the selected ECI encoding, an exception is thrown.
7243
+ * Please note that some old (pre 2006) scanners may not support this mode.
7244
+ * This mode is not supported by MicroQR barcodes.
7245
+ */
7246
+ ECI: 8
7188
7247
 
7189
7248
  };
7190
7249
 
@@ -433,7 +433,8 @@ class BarCodeReader extends joint.BaseJavaClass
433
433
  {
434
434
  let xmlData = fs.readFileSync(xmlFile).toString();
435
435
  let java_class_link = new java.import(BarCodeReader.javaClassName);
436
- return BarCodeReader.construct(java_class_link.importFromXmlSync(xmlData.substring(3, xmlData.length)));
436
+ xmlData = xmlData.substring(0, 3) === "п»ї" ? xmlData.substring(3, xmlData.length) : xmlData;
437
+ return BarCodeReader.construct(java_class_link.importFromXmlSync(xmlData));
437
438
  } catch (ex)
438
439
  {
439
440
  let barcode_exception = new joint.BarcodeException(ex);
@@ -938,7 +939,11 @@ class Pdf417ExtendedParameters extends joint.BaseJavaClass
938
939
  */
939
940
  getMacroPdf417TimeStamp()
940
941
  {
941
- return new Date(this.getJavaClass().getMacroPdf417TimeStampSync() * 1000);
942
+ const value = this.getJavaClass().getMacroPdf417TimeStampSync();
943
+
944
+ if (!value) return null;
945
+
946
+ return new Date(value);
942
947
  }
943
948
 
944
949
  /**
@@ -1965,7 +1970,7 @@ class Code128DataPortion extends joint.BaseJavaClass
1965
1970
  /**
1966
1971
  * Stores a DataBar additional information of recognized barcode
1967
1972
  *@example
1968
- * let reader = new BarCodeReader("c:\\test.png", DecodeType.DATABAR_OMNI_DIRECTIONAL);
1973
+ * let reader = new BarCodeReader("test.png", DecodeType.DATABAR_OMNI_DIRECTIONAL);
1969
1974
  * let results = reader.readBarCodes();
1970
1975
  * for(let i = 0; i < results.length; i++)
1971
1976
  * {
@@ -2292,6 +2297,88 @@ class BarcodeSettings extends joint.BaseJavaClass
2292
2297
  this.getJavaClass().setStripFNCSync(value);
2293
2298
  }
2294
2299
 
2300
+
2301
+
2302
+ /**
2303
+ * Returns only barcode types explicitly specified for recognition.
2304
+ * When enabled, recognized barcodes of other compatible or equivalent types are filtered out.
2305
+ * Default value is false.
2306
+ *
2307
+ * <p>Example:</p>
2308
+ * <pre>
2309
+ * // generate EAN13 barcode
2310
+ * let generator = new BarcodeGenerator(EncodeTypes.EAN_13, "2383823482894");
2311
+ * generator.save("test.png");
2312
+ *
2313
+ * // recognize only UPCA barcodes (no results, because source is EAN13)
2314
+ * const reader = new BarCodeReader("test.png", null, DecodeType.UPCA);
2315
+ * reader.getBarcodeSettings().setOnlyRequestedTypes(true);
2316
+ *
2317
+ * let results = reader.readBarCodes();
2318
+ * for (let i = 0; i < results.length; i++)
2319
+ * {
2320
+ * console.log("BarCode CodeText: " + results[i].getCodeText());
2321
+ * }
2322
+ *
2323
+ * // recognize compatible types: EAN13, UPCA, ISSN, ISMN, ISBN
2324
+ * // (EAN13 will be returned as UPCA-equivalent)
2325
+ * let reader2 = new BarCodeReader("test.png", null, DecodeType.UPCA);
2326
+ * reader2.getBarcodeSettings().setOnlyRequestedTypes(false);
2327
+ *
2328
+ * let results2 = reader2.readBarCodes();
2329
+ * for (let i = 0; i < results2.length; i++)
2330
+ * {
2331
+ * console.log("BarCode CodeText: " + results2[i].getCodeText());
2332
+ * }
2333
+ * </pre>
2334
+ *
2335
+ * @return true if only explicitly requested barcode types are returned; otherwise false
2336
+ */
2337
+ isOnlyRequestedTypes()
2338
+ {
2339
+ return this.getJavaClass().isOnlyRequestedTypesSync();
2340
+ }
2341
+
2342
+ /**
2343
+ * Returns only barcode types explicitly specified for recognition.
2344
+ * When enabled, recognized barcodes of other compatible or equivalent types are filtered out.
2345
+ * Default value is false.
2346
+ *
2347
+ * <p>Example:</p>
2348
+ * <pre>
2349
+ * // generate EAN13 barcode
2350
+ * let generator = new BarcodeGenerator(EncodeTypes.EAN_13, "2383823482894");
2351
+ * generator.save("test.png");
2352
+ *
2353
+ * // recognize only UPCA barcodes (no results, because source is EAN13)
2354
+ * const reader = new BarCodeReader("test.png", null, DecodeType.UPCA);
2355
+ * reader.getBarcodeSettings().setOnlyRequestedTypes(true);
2356
+ *
2357
+ * let results = reader.readBarCodes();
2358
+ * for (let i = 0; i < results.length; i++)
2359
+ * {
2360
+ * console.log("BarCode CodeText: " + results[i].getCodeText());
2361
+ * }
2362
+ *
2363
+ * // recognize compatible types: EAN13, UPCA, ISSN, ISMN, ISBN
2364
+ * // (EAN13 will be returned as UPCA-equivalent)
2365
+ * let reader2 = new BarCodeReader("test.png", null, DecodeType.UPCA);
2366
+ * reader2.getBarcodeSettings().setOnlyRequestedTypes(false);
2367
+ *
2368
+ * let results2 = reader2.readBarCodes();
2369
+ * for (let i = 0; i < results2.length; i++)
2370
+ * {
2371
+ * console.log("BarCode CodeText: " + results2[i].getCodeText());
2372
+ * }
2373
+ * </pre>
2374
+ *
2375
+ * @return true if only explicitly requested barcode types are returned; otherwise false
2376
+ */
2377
+ setOnlyRequestedTypes(value)
2378
+ {
2379
+ this.getJavaClass().setOnlyRequestedTypesSync(value);
2380
+ }
2381
+
2295
2382
  /**
2296
2383
  * The flag which force engine to detect codetext encoding for Unicode codesets. Default value is true.
2297
2384
  *
@@ -2558,9 +2645,9 @@ class MaxiCodeExtendedParameters extends joint.BaseJavaClass
2558
2645
  *
2559
2646
  * @example
2560
2647
  * let generator = new BarcodeGenerator(EncodeTypes.DOT_CODE, "12345");
2561
- * generator.save("c:\\test.png", BarCodeImageFormat.PNG);
2648
+ * generator.save("test.png", BarCodeImageFormat.PNG);
2562
2649
  *
2563
- * let reader = new BarCodeReader("c:\\test.png", null, DecodeType.DOT_CODE);
2650
+ * let reader = new BarCodeReader("test.png", null, DecodeType.DOT_CODE);
2564
2651
  * let results = reader.readBarCodes();
2565
2652
  * for(let i = 0; i < results.length; i++)
2566
2653
  * {
@@ -2681,9 +2768,9 @@ class DotCodeExtendedParameters extends joint.BaseJavaClass
2681
2768
  * This sample shows how to get DataMatrix raw values
2682
2769
  * <pre>
2683
2770
  * let generator = new BarcodeGenerator(EncodeTypes.DATA_MATRIX, "12345"))
2684
- * generator.save("c:\\test.png", BarcodeImageFormat.PNG);
2771
+ * generator.save("test.png", BarcodeImageFormat.PNG);
2685
2772
  *
2686
- * let reader = new BarCodeReader("c:\\test.png", null, DecodeType.DATA_MATRIX))
2773
+ * let reader = new BarCodeReader("test.png", null, DecodeType.DATA_MATRIX))
2687
2774
  * let results = reader.readBarCodes();
2688
2775
  * for(let i = 0; i < results.length; i++)
2689
2776
  * {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aspose.barcode",
3
- "version": "26.2.0",
3
+ "version": "26.4.0",
4
4
  "description": "barcode generation and recognition component",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"