bwip-js
Barcode Writer in Pure JavaScript
README
bwip-js
bwip-js is a translation to native JavaScript of the amazing code provided in Barcode Writer in Pure PostScript. The translated code can run on any modern browser or JavaScript-based server framework.
The library has encoding modules for over 100 different barcode types and standards.
All linear and two-dimensional barcodes in common use (and many uncommon
ones) are available. An exhaustive list of supported barcode types can be
found at the end of this document. Barcodes are generated as PNG images (node-js and react-native)
or to a canvas (browser) or as SVG (all platforms).
As of version 4.5, bwip-js has been partitioned into four platform-specific packages plus the cross-platform main package. The sub-packages are currently experimental but are the solution to current build chains not properly supporting the exports map in package.json. Please use them and report any issues you find.
Status
Current bwip-js version is 4.5.0 (2024-07-03)
Current BWIPP version is 2024-06-18
Node.js compatibility: 6.0
Browser compatibility: Edge, Firefox, Chrome
Installation
The bwip-js package has been partitioned into four platform-specific packages plus the main cross-platform package. If you install the main package and cannot get its exports to work with your build stack, try installing a platform-specific package. The platform-specific packages are ES modules only, so you will need a modern build environment. The exception is the node package, which also contains a require() compatible export.
You can download the main package using:
- ```
- npm install bwip-js
- ```
Or one of the platform-specific packages using:
- ```
- npm install @bwip-js/node
- npm install @bwip-js/browser
- npm install @bwip-js/react-native
- npm install @bwip-js/generic
- ```
The node, browser and react-native packages include both an image rending interface (toCanvas() on the browser, toBuffer() on node, toDataURL() on react-native), plus the SVG and custom drawing context interfaces.
The generic package contains only exports that run on any platform, namely the SVG and custom drawing context interfaces.
The latest code can be obtained from github:
https://github.com/metafloor/bwip-js
The bwip-js branches and the npm versions are automatically sync'd with each release. The main package is located under the master branch; the platform-specific packages are maintained under their like-named branches.
Online Barcode Generator
demonstrates all of the features of bwip-js. The app is also available
in the root bwip-js directory.
Online Barcode API
A bwip-js barcode service is available online, ready to serve up barcode images
on demand.
You can generate barcodes from anywhere on the web. Embed the URLs in your
HTML documents or retrieve the barcode images directly from your non-JavaScript
server. (JavaScript-based servers should use the bwip-js code directly - it will
be a lot more performant.)
For details on how to use this service, see Online Barcode API.