bwip-js
bwip-js copied to clipboard
Canvas support for usage in nodejs
Unfortunately it is now only possible to generate canvas images using a browser. I would like to generate SVGs with nodejs alone.
This works perfectly https://github.com/lindell/JsBarcode#nodejs but bwip-js supports more types of barcodes so it would be great is bwip-js gets this node canvas support too.
There is example code provided to render SVG output. Please have a look at https://github.com/metafloor/bwip-js/tree/master/examples:
$ cd /your/path/to/node_modules/bwip-js/examples
$ node svg code128 0123456789 includetext
<svg version="1.1" width="180" height="160" xmlns="http://www.w3.org/2000/svg">
<path stroke="#000000" stroke-width="4" d="M2 144L2 0M24 144L24 0M32 144L32 0M38 144L38 0M54 144L54 0M80 144L80 0M104 144L104 0M112 144L112 0M118 144L118 0M144 144L144 0M156 144L156 0M178 144L178 0" />
<path stroke="#000000" stroke-width="2" d="M7 144L7 0M67 144L67 0M89 144L89 0M99 144L99 0M133 144L133 0M149 144L149 0M173 144L173 0" />
<path stroke="#000000" stroke-width="6" d="M15 144L15 0M47 144L47 0M61 144L61 0M73 144L73 0M167 144L167 0" />
<path stroke="#000000" stroke-width="8" d="M126 144L126 0" />
<path d="M31.90 159.14L31.83 159.14Q30.76 159.12 29.96 158.79Q29.17 158.48 28.70 157.98Q28.23 157.45 27.96 156.64Q27.67 155.82 27.58 154.99Q27.49 154.17 27.49 153.06Q27.49 152.07 27.50 151.38Q27.54
... snip ...
fill="#000000" />
</svg>
Version 4 now supports SVG. Read about it here: https://github.com/metafloor/bwip-js/discussions/299.