Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
barcode-bakery-1d
Advanced tools
Generates 1D barcodes from Node server to a file or a buffer.
Barcode Bakery is library written in Node.JS, .NET Standard and PHP which allows you to generate barcodes on the fly on your server for displaying or saving.
The library has minimal dependencies in each language in order to be supported on a wide variety of web servers.
The library is available for free for non-commercial use; however you must purchase a license if you plan to use it in a commercial environment.
There are two ways to install our library:
$ npm install barcode-bakery-1d
For a full example of how to use each symbology type, visit our API page.
import { createServer } from 'http';
import { BCGColor, BCGDrawing, BCGFont } from 'barcode-bakery-common';
import { BCGcode128 } from 'barcode-bakery-1d';
import { parse } from 'querystring';
const defaultText = 'abc123';
let font = new BCGFont('Arial', 18);
let colorBlack = new BCGColor(0, 0, 0);
let colorWhite = new BCGColor(255, 255, 255);
let getDrawing = function (text) {
let drawException = null,
barcode = null;
try {
// Barcode Part
let code = new BCGcode128();
code.setScale(2); // Resolution
code.setThickness(30); // Thickness
code.setBackgroundColor(colorWhite); // Color of spaces
code.setForegroundColor(colorBlack); // Color of bars
code.setFont(font); // Font (or 0)
code.setStart(null);
code.setTilde(true);
code.parse(text); // Text
barcode = code;
} catch (exception) {
drawException = exception;
}
let drawing = new BCGDrawing(barcode, colorWhite);
if (drawException) {
drawing.drawException(drawException);
}
return drawing;
};
createServer(function (request, response) {
// Don't forget to sanitize user inputs.
let drawing = getDrawing(parse(request.url).query?.toString() || defaultText);
drawing.toBuffer(BCGDrawing.ImageFormat.Png, function (err, buffer) {
response.writeHead(200, { 'Content-Type': 'image/png' });
response.end(buffer);
});
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
Replace the last lines of the previous code with the following:
var drawing = new BCGDrawing(code, colorWhite);
drawing.save('image.png', BCGDrawing.ImageFormat.Png, function() {
console.log('Done.');
});
This will generate the following:
Both save
and toBuffer
have counterparts acting synchronously: saveSync
and toBufferSync
.
Simply type npm test
to run the tests.
FAQs
Generates 1D barcodes from Node server to a file or a buffer.
We found that barcode-bakery-1d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.