Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation provides a comprehensive guide on how to set the colorscheme for barcodes using the Aspose.BarCode Cloud SDK for Node.js. The API allows customization of barcode appearance, including foreground and background colors, ensuring your barcodes match your design needs.
The GenerateApi
interface includes methods to generate barcodes using different request formats:
The foregroundColor
and backgroundColor
properties enable you to define the colors for the barcode:
Both properties accept standard color names or ARGB values (e.g., AliceBlue
or #FF000000
).
const fs = require('fs');
const path = require('path');
const Barcode = require('aspose-barcode-cloud-node');
function makeConfiguration() {
const envToken = process.env['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (!envToken) {
return new Barcode.Configuration(
'Client Id from https://dashboard.aspose.cloud/applications',
'Client Secret from https://dashboard.aspose.cloud/applications',
null,
null
);
} else {
return new Barcode.Configuration(null, null, null, envToken);
}
}
const config = makeConfiguration();
async function generateBarcode(api, fileName) {
const request = new Barcode.GenerateRequestWrapper(
Barcode.EncodeBarcodeType.Qr,
'https://products.aspose.cloud/barcode/family/'
);
request.foregroundColor = 'DarkBlue';
request.backgroundColor = 'LightGray';
request.imageFormat = Barcode.BarcodeImageFormat.Png;
const generated = await api.generate(request);
fs.writeFileSync(fileName, generated.body);
}
const genApi = new Barcode.GenerateApi(config);
const fileName = path.resolve('testdata', 'Qr.png');
generateBarcode(genApi, fileName)
.then(() => {
console.log("File '" + fileName + "' generated.");
})
.catch((err) => {
console.error('Error: ' + JSON.stringify(err, null, 2));
process.exitCode = 1;
});
Result Image is:
const fs = require('fs');
const path = require('path');
const Barcode = require('aspose-barcode-cloud-node');
function makeConfiguration() {
const envToken = process.env['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (!envToken) {
return new Barcode.Configuration(
'Client Id from https://dashboard.aspose.cloud/applications',
'Client Secret from https://dashboard.aspose.cloud/applications',
null,
null
);
} else {
return new Barcode.Configuration(null, null, null, envToken);
}
}
const config = makeConfiguration();
async function generateBarcode(api, fileName) {
const imageParams = new Barcode.BarcodeImageParams();
imageParams.foregroundColor = '#FF5733';
imageParams.backgroundColor = '#FFFFFF';
imageParams.imageFormat = Barcode.BarcodeImageFormat.Jpeg;
const encodeData = new Barcode.EncodeData();
encodeData.data = 'Aspose.BarCode.Cloud';
encodeData.dataType = Barcode.EncodeDataType.StringData;
const generateParams = new Barcode.GenerateParams();
generateParams.barcodeType = Barcode.EncodeBarcodeType.Pdf417;
generateParams.encodeData = encodeData;
generateParams.barcodeImageParams = imageParams;
const request = new Barcode.GenerateBodyRequestWrapper(generateParams);
const generated = await api.generateBody(request);
fs.writeFileSync(fileName, generated.body);
}
const genApi = new Barcode.GenerateApi(config);
const fileName = path.resolve('testdata', 'Pdf417.png');
generateBarcode(genApi, fileName)
.then(() => {
console.log("File '" + fileName + "' generated.");
})
.catch((err) => {
console.error('Error: ' + JSON.stringify(err, null, 2));
process.exitCode = 1;
});
Result Image is:
const fs = require('fs');
const path = require('path');
const Barcode = require('aspose-barcode-cloud-node');
function makeConfiguration() {
const envToken = process.env['TEST_CONFIGURATION_ACCESS_TOKEN'];
if (!envToken) {
return new Barcode.Configuration(
'Client Id from https://dashboard.aspose.cloud/applications',
'Client Secret from https://dashboard.aspose.cloud/applications',
null,
null
);
} else {
return new Barcode.Configuration(null, null, null, envToken);
}
}
const config = makeConfiguration();
function generateBarcode(api, fileName) {
return new Promise(async (resolve, reject) => {
try {
const request = new Barcode.GenerateMultipartRequestWrapper(Barcode.EncodeBarcodeType.Code39, 'Aspose');
request.foregroundColor = 'Green';
request.backgroundColor = 'Yellow';
request.imageFormat = Barcode.BarcodeImageFormat.Gif;
const generated = await api.generateMultipart(request);
fs.writeFileSync(fileName, generated.body);
resolve();
} catch (err) {
reject(err);
}
});
}
const genApi = new Barcode.GenerateApi(config);
const fileName = path.resolve('testdata', 'Code39.png');
generateBarcode(genApi, fileName)
.then(() => {
console.log('Barcode saved to ' + fileName);
})
.catch((err) => {
console.error('Error: ' + JSON.stringify(err, null, 2));
process.exitCode = 1;
});
Result Image is:
With GenerateApi
in Aspose.BarCode Cloud SDK for Node.js, you can easily generate barcodes with customized colors. Whether you prefer GET, POST with JSON, or multipart form POST, the flexibility of this API ensures seamless integration and customization of barcodes in your applications.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.