Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active December 2, 2021 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/3d80ec0b502975afa622577a2ca7bf0a to your computer and use it in GitHub Desktop.
Save aspose-cloud/3d80ec0b502975afa622577a2ca7bf0a to your computer and use it in GitHub Desktop.
This Gist repository contains code snippet related to Aspose.BarCode Cloud SDK for Node.js
Aspose.BarCode-Cloud-SDK-Node.js
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
it('should generate image', async () => {
const generated = await api.getBarcodeGenerate(Barcode.EncodeBarcodeType.QR, 'BarCode generator');
const imageSize = generated.body.buffer.byteLength;
assert.ok(imageSize > 0, `ImageSize=${imageSize}`);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.CodablockF,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
it('should generate image', async () => {
const generated = await api.getBarcodeGenerate(Barcode.EncodeBarcodeType.QR, 'BarCode generator');
var writeStream = fs.createWriteStream('D:/temp/GetBarcodeGenerate.png');
writeStream.write(generated.body);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const enable_checksum = 'Yes';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
enable_checksum,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putGenerateMultiple.png';
const firstBarcode = new Barcode.GeneratorParams();
firstBarcode.typeOfBarcode = Barcode.EncodeBarcodeType.Code128;
firstBarcode.text = 'First barcode';
const secondBarcode = new Barcode.GeneratorParams();
secondBarcode.typeOfBarcode = Barcode.EncodeBarcodeType.QR;
secondBarcode.text = 'Second barcode';
const params = new Barcode.GeneratorParamsList();
params.barcodeBuilders = [firstBarcode, secondBarcode];
params.xStep = 0;
params.yStep = 1;
it('should create file on server', async () => {
const response = await api.putGenerateMultiple(filename, params, undefined, tempFolderPath);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const imageBuffer = fs.readFileSync('./data/pdf417Sample.png');
it('should recognize from body', async () => {
const recognized = await api.postBarcodeRecognizeFromUrlOrContent(
undefined,
undefined,
undefined,
Barcode.PresetType.HighPerformance,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
imageBuffer
);
const barcodes = recognized.body.barcodes;
assert.strictEqual(barcodes.length, 1);
const barcode = barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const imageBuffer = fs.readFileSync('./data/pdf417Sample.png');
it('should recognize from body', async () => {
const recognized = await api.postBarcodeRecognizeFromUrlOrContent(
undefined,
undefined,
undefined,
Barcode.PresetType.HighPerformance,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
imageBuffer
);
const barcodes = recognized.body.barcodes;
assert.strictEqual(barcodes.length, 1);
const barcode = barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const config = LoadConfiguration();
const api = new Barcode.BarcodeApi(config);
const fileApi = new Barcode.FileApi(config);
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const imageBuffer = fs.readFileSync('./data/pdf417Sample.png');
const rect_x = 10;
const rect_y = 10;
const rect_width = 200;
const rect_height = 200;
const checksum_validation = 'On'
const strip_fnc = true;
it('getBarcodeRecognize should recognize uploaded image', async () => {
const uploaded = await fileApi.uploadFile(`${tempFolderPath}/${filename}`, imageBuffer); //, "First Storage");
assert.strictEqual(uploaded.body.errors.length, 0, JSON.stringify(uploaded.body.errors));
assert.strictEqual(uploaded.body.uploaded[0], filename);
const recognized = await api.getBarcodeRecognize(
filename,
undefined,
checksum_validation,
undefined,
Barcode.PresetType.HighPerformance,
rect_x,
rect_y,
rect_width,
rect_height,
strip_fnc,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath
);
assert.strictEqual(recognized.body.barcodes.length, 1);
const barcode = recognized.body.barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const url = 'http://www.barcoding.com/images/Barcodes/pdf417.gif';
it('should recognize from body', async () => {
const recognized = await api.postBarcodeRecognizeFromUrlOrContent(
undefined,
undefined,
undefined,
Barcode.PresetType.HighPerformance,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
url,
undefined
);
const barcodes = recognized.body.barcodes;
assert.strictEqual(barcodes.length, 1);
const barcode = barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const imageBuffer = fs.readFileSync('./data/pdf417Sample.png');
const checksum_validation = 'On';
it('should recognize from body', async () => {
const recognized = await api.postBarcodeRecognizeFromUrlOrContent(
undefined,
checksum_validation,
undefined,
Barcode.PresetType.HighPerformance,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
imageBuffer
);
const barcodes = recognized.body.barcodes;
assert.strictEqual(barcodes.length, 1);
const barcode = barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const config = LoadConfiguration();
const api = new Barcode.BarcodeApi(config);
const fileApi = new Barcode.FileApi(config);
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const imageBuffer = fs.readFileSync('./data/pdf417Sample.png');
it('getBarcodeRecognize should recognize uploaded image', async () => {
const uploaded = await fileApi.uploadFile(`${tempFolderPath}/${filename}`, imageBuffer); //, "First Storage");
assert.strictEqual(uploaded.body.errors.length, 0, JSON.stringify(uploaded.body.errors));
assert.strictEqual(uploaded.body.uploaded[0], filename);
const recognized = await api.getBarcodeRecognize(
filename,
undefined,
undefined,
undefined,
Barcode.PresetType.HighPerformance,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath
);
assert.strictEqual(recognized.body.barcodes.length, 1);
const barcode = recognized.body.barcodes[0];
assert.strictEqual(barcode.type, Barcode.DecodeBarcodeType.Pdf417);
assert.strictEqual(barcode.barcodeValue, 'Aspose.BarCode for Cloud Sample');
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const rotation_angle = 90;
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
rotation_angle,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const bar_height = 50.0;
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
bar_height,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const resolution = 200.0;
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
resolution,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const image_height = 1.0;
const image_width = 1.0;
const size_mode = 'None';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
size_mode,
undefined,
image_height,
image_width,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const dimension_x = 200.0;
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
dimension_x,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const format = 'png';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
format
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
const text_location = 'Above';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
text_location,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
// For complete examples and data files, please go to https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-node/
const api = new Barcode.BarcodeApi(LoadConfiguration());
const tempFolderPath = `BarcodeTests/${uuidv4()}`;
const filename = 'putBarcodeGenerateFile.png';
it('should create file on server', async function() {
const response = await api.putBarcodeGenerateFile(
filename,
Barcode.EncodeBarcodeType.Code128,
'Hello!',
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
tempFolderPath,
undefined
);
assert.ok(response.body.fileSize > 0);
assert.ok(response.body.imageWidth > 0);
assert.ok(response.body.imageHeight > 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment