aspose.barcode
Advanced tools
Comparing version 24.4.0 to 24.5.1
@@ -7,3 +7,3 @@ 'use strict' | ||
const recognition_ = require("./Recognition"); | ||
const jar_name_ = "/aspose-barcode-nodejs-24.4.jar"; | ||
const jar_name_ = "/aspose-barcode-nodejs-24.5.jar"; | ||
const jar_path_ = __dirname + jar_name_; | ||
@@ -10,0 +10,0 @@ const fs = require("fs"); |
const java = require('java'); | ||
const fs = require("fs"); | ||
const URL = require('url'); | ||
const https = require('https'); | ||
@@ -18,17 +20,91 @@ | ||
function convertResourceToBase64String(resource) | ||
function isValidURL(str) { | ||
try { | ||
new URL(str); | ||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
} | ||
function isBase64(str) | ||
{ | ||
let is_path_to_image = false; | ||
is_path_to_image = fs.existsSync(resource); | ||
try | ||
{ | ||
return (Buffer.from(str, 'base64').toString('base64')) === str; | ||
} | ||
catch (err) | ||
{ | ||
return false; | ||
} | ||
} | ||
if (is_path_to_image) | ||
function convertImageResourceToBase64(imageResource) | ||
{ | ||
if(imageResource === null) | ||
{ | ||
return fs.readFileSync(resource).toString('base64'); | ||
return null; | ||
} | ||
else if ((typeof imageResource === 'string') && (isBase64(imageResource))) | ||
{ | ||
return imageResource; | ||
} | ||
else if (fs.existsSync(imageResource)) | ||
{ | ||
return fs.readFileSync(imageResource).toString('base64'); | ||
} | ||
throw new BarcodeException("Image is not available or this resouce is not supported!"); | ||
} | ||
function convertDecodeTypeToFormattedDecodeType(decodeTypes) | ||
{ | ||
if (decodeTypes === undefined || decodeTypes == null) | ||
{ | ||
return [DecodeType.ALL_SUPPORTED_TYPES]; | ||
} | ||
else | ||
{ | ||
return resource; | ||
if(!Array.isArray(decodeTypes)) | ||
decodeTypes = [decodeTypes]; | ||
for (let i = 0; i < decodeTypes.length; i++) | ||
{ | ||
if(!Number.isInteger(decodeTypes[i])) | ||
throw new Error("Unsuported decodeType format"); | ||
} | ||
return decodeTypes; | ||
} | ||
} | ||
function convertAreasToStringFormattedAreas(areas) // TODO move to Joint | ||
{ | ||
let stringFormattedAreas = null; | ||
if (areas != null) | ||
{ | ||
stringFormattedAreas = []; | ||
if(Array.isArray(areas)) | ||
{ | ||
if(!areas.every(area => area === null)) | ||
{ | ||
for(let i = 0; i < areas.length; i++) | ||
{ | ||
let area = areas[i]; | ||
if (area === null || !(area instanceof Rectangle)) | ||
throw new BarcodeException('All elements of areas should be instances of Rectangle class'); | ||
stringFormattedAreas.push(area.toString()); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
if (!(areas instanceof Rectangle)) | ||
throw new BarcodeException('All elements of areas should be instances of Rectangle class'); | ||
stringFormattedAreas.push(areas.toString()); | ||
} | ||
stringFormattedAreas = stringFormattedAreas.length > 0 ? stringFormattedAreas : null | ||
} | ||
return stringFormattedAreas; | ||
} | ||
class BaseJavaClass | ||
@@ -488,3 +564,4 @@ { | ||
module.exports = { | ||
BaseJavaClass, BarcodeException, Rectangle, Point, License, BuildVersionInfo, isPath, convertResourceToBase64String | ||
BaseJavaClass, BarcodeException, Rectangle, Point, License, BuildVersionInfo, isPath, convertImageResourceToBase64, | ||
convertDecodeTypeToFormattedDecodeType, convertAreasToStringFormattedAreas | ||
}; |
{ | ||
"name": "aspose.barcode", | ||
"version": "24.4.0", | ||
"version": "24.5.1", | ||
"description": "barcode generation and recognition component", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16612261
15995
1