How to use the bwip-js.toBuffer function in bwip-js

To help you get started, we’ve selected a few bwip-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / bwip-js / bwip-js-tests.ts View on Github external
fs.readFileSync('fonts/Inconsolata.otf', 'binary'));


http.createServer(function(req, res) {
    // If the url does not begin /?bcid= then 404.  Otherwise, we end up
    // returning 400 on requests like favicon.ico.
    if (req.url!.indexOf('/?bcid=') != 0) {
        res.writeHead(404, { 'Content-Type':'text/plain' });
        res.end('BWIPJS: Unknown request format.', 'utf8');
    } else {
        bwipjs(req, res);
    }

}).listen(3030);

bwipjs.toBuffer({
    bcid:        'code128',       // Barcode type
    text:        '0123456789',    // Text to encode
    scale:       3,               // 3x scaling factor
    height:      10,              // Bar height, in millimeters
    includetext: true,            // Show human-readable text
    textxalign:  'center',        // Always good to set this
    textfont:    'Inconsolata',   // Use your custom font
    textsize:    13               // Font size, in points
}, function (err:string|Error, png: Buffer) {
    if (err) {
        console.log(err);
    } else {
        // `png` is a Buffer
        // png.length           : PNG file length
        // png.readUInt32BE(16) : PNG image width
        // png.readUInt32BE(20) : PNG image height
github MomsFriendlyDevCo / pdf-dicer / playground / generate-pdf.js View on Github external
.then((next) => {
        debug('New barcode generation start...');
        var url = `http://localhost/#/forms/filings/${uid(15)}`;
        var id = url.substring(url.lastIndexOf('/') + 1,url.length);
        fileName = `${id}-${fileName}`;

        bwipjs.toBuffer({
          bcid:        'code128',       // Barcode type
          text:        url,             // Text to encode
          scaleX:      2,               // 2x scaling factor
          scaleY:      1,               // 1y scaling factor
          includetext: false,           // Show human-readable text
          textxalign:  'center',        // Always good to set this
        }, function (err, png) {
          if (err) {
            console.error(err);
          } else {
            PNG = png;
            next();
          }
        });
        
      })
github informalsystems / themis-contract / src / shared / barcode-helpers.ts View on Github external
return new Promise((resolve, reject) => {
    bwipjs.toBuffer({
      bcid: 'pdf417',
      text: content,
      backgroundcolor: 'ffffff',
    }, (err, png) => {
      if (err) {
        reject(err)
      } else {
        resolve(png)
      }
    })
  })
}

bwip-js

JavaScript barcode generator supporting over 100 types and standards.

MIT
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis

Popular bwip-js functions