Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

symbology

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symbology

Generate 50+ different 1D or 2D barcodes in png, eps, or svg format.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

symbology

Coverage Status Build Status npm version

Introduction

This Node.js module will allow you to generate over 50+ different types of 1D or 2D symbologies, including barcodes for books, grocery, shipping carriers, healthcare, and international codes. It can save a png, svg, or eps image, or render a base64 png bitmap.

Installation

symbology can be downloaded directly or installed via npm.

npm install symbology --save

Usage

Import the module

var symbology = require('../symbology');

Struct

Prepare a Symbol json object with your desired settings (see docs for more info):

var Symbol = {
  symbology: symbology.BARCODE_CODE128,
  foregroundColor: 'fff000',
  backgroundColor: '000000',
  fileName: '/my/directory/barcode.png'
};

Available functions

Each function returns a promise that completes with an object containing the exit code and message of the function (see error handling for more info).


createStream(Symbol, data, type)

Writes a stream in to the output object in a property data.

ParameterTypeValues
SymbolStructStruct of symbology settings
dataStringDesired data to encode
typeStringpng, svg or eps

Example:

symbology
  .createStream(Symbol, '12345', 'png')
  .then(function(data) {
    console.log('Result: ', data);
  }, function(err) { 
    console.log('Error: ', err); 
  });

Returns:

{ 
  message: '',
  code: 0,
  data: 'data:image/png;base64,iVBOR [...] g==' 
}

createFile(Symbol, data)

Writes a stream in to the output object in a property data.

ParameterTypeValues
SymbolStructStruct of symbology settings
dataStringDesired data to encode

Example:

symbology
  .createFile(Symbol, '12345')
  .then(function(data) {
    console.log('Result: ', data);
  }, function(err) { 
    console.log('Error: ', err); 
  });

This creates a file in the specified fileName and returns:

{ 
  message: 'error: specified symbology is out of range',
  code: 2
}

Available settings (struct)

A Symbol is a regular JavaScript object with the following available properties:

TODO: make a table for this...

Error handling

Each function returns an object having property code, which is the status code of the function, and message, which contains an error/warning message (if any).

TODO: make a table for this...

Data input modes

TODO: make a table for this...

Symbology types

There are 53 different available symbology types. For an exhaustive list, please see the symbology readme.

Development (outdated info)

To compile the latest, ensure you have node-gyp installed. Then run:

node-gyp build

For running tests,

npm test

FAQs

Package last updated on 27 Jan 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc