metafloor / bwip-js Goto Github PK
View Code? Open in Web Editor NEWBarcode Writer in Pure JavaScript
License: Other
Barcode Writer in Pure JavaScript
License: Other
Its seems nice package for Aztec-Code generation!!
I need this feature for react-native app! Does anyone have idea that how can I use this for react-native!
Hello,
First of all, I would like to thank for this library and to the effort to make it better and better,
At the moment, I'm struggling with have more than one check digit module available, from what I could understand the barcodes that have checkdigit, they only have the formula to do the mod10.
For example barcode 128 has available Module 10, Module 43 and Mod103.
Can you please let me know if I'm missing something or if this could be a future implementation?
Thank you in advance.
var code_str = "978-5-333434-00";
bwipjs({
url: encodeURIComponent("/?bcid=isbn&text=" + code_str
+ "&scale=3&includetext&monochrome")
}, {
writeHead: function() {},
end: function(png) {
fs.mkdir("temp/barcodes", function(err) {
fs.writeFile("temp/barcodes/" + id + ".png", png, "binary", function(err) {})
})
Creates empty png, I've tried EAN-13 and it was fine.
Hello, I'm trying to encode binary data in an Aztec 2D code. Currently my code looks like that:
data = fs.readFileSync('file.bin').toString('latin1')
bwipjs.toBuffer({
bcid: 'azteccode',
text: data
}, function (err, png) {
if (err) {
console.log(err);
} else {
fs.writeFileSync('code.png', png, 'binary')
}
});
which produces exactly the same result as encoding the bytes with ^NNN
and the parse
option. My problem is, that the decoded data is different from the original data:
$ hexdump file.bin
0000000 4430 2002 a642 6a4d 5340 28ca 12ca 0ef7
0000010 84c7 24c6 f781 4baf b66e 0b4b 8df9 2d50
0000020 cf99 b8f2 2002 0a34 ee56 7ba0 264d 4279
0000030 55fd d7a7 5bca 407a 276c 2080 b11d 3a92
0000040 1dbe e04a 510b
0000046
opposed to
$ hexdump file2.bin
0000000 4430 2002 c242 4da6 406a c353 288a 8ac3
0000010 c312 0eb7 87c3 84c2 86c3 c224 c381 c2b7
0000020 4baf c26e 4bb6 c30b c2b9 508d c22d c399
0000030 c38f c2b2 02b8 3420 560a aec3 a0c2 4d7b
0000040 7926 c342 55bd a7c2 97c3 8ac3 7a5b 6c40
0000050 c227 2080 c21d c2b1 3a92 bec2 4a1d a0c3
0000060 510b 000a
0000063
Apparently encoding it as latin1
changes the data, but I don't know how or whether I can "convert it back". Is there any better method of putting binary data in the code?
Thank you very much.
From where is the OCR fonts taken? I have searched for OCR fonts with open source licenses but unable to find them. I have found fonts to download online but without any explicit license stated.
Steps to reproduce:
Result: you'll find in the end of document.head injected script /bwipp/qrcode.js
twice.
I've fixed it on on my side changing canvas.js:
// Dynamically load the encoders.
BWIPJS.load = function(path) {
var script;
var src = BWIPJS.load.root + path;
var scriptInjected = Array.prototype.filter.call(document.scripts, function (script) {
return script.getAttribute('src') === src;
})[0];
if (scriptInjected) {
//Script has been injectd already in document
return false;
}
script = document.createElement('script');
script.type = 'text/javascript';
script.src = src;
document.head.appendChild(script);
};
Can you provide your script to convert original code in postscript to your javascript?
Thank you!
This isn't an issue, just merely a thank you, you cannot begin to comprehend how much work, time & effort you have just saved me by creating this brilliant library. The Node.js server example was _perfect_ for what I needed to achieve.
Thank you again from me, and from all my users that will benefit directly as a result of your hard work! 👍 👍 👍 👍 👍 👍
Good day,
I'm trying to use the API, but the site responds with an error "Error: array-marker-not-found".
I want to generate the following bar code: http://api-bwipjs.rhcloud.com/?bcid=gs1-128&text=61312350510&includetext&textsize=6&textyoffset=1&scaleX=2
I'm doing something wrong?
Thanks for the help.
To encode Chinese characters in barcode, I choose the popular QR barcode.
First I visit http://www.terryburton.co.uk/barcodewriter/generator/
I choose "QR Code" for "Barcode" option, input "中文" for "Contents", and leave "Options" as it is. Then I press "Make Barcode" button. After a while, a QR barcode appears, I scan it with my phone and it says "中文", which is correct.
Then I visit http://metafloor.github.io/bwip-js/demo/demo.html
I do the same thing as above, but when I click the button "Show Barcode", a message pops up saying "length: invalid: integertype".
I think the terryburton.co.uk site should be using postscript while the metafloor.github.io is using javascript. So there might be something wrong converting postscript into javascript.
For some reason browserify throws the following error when it tries to access the library:
Uncaught Error: Cannot find module '/node_modules/bwip-js/node-zlibPNG'
Looks like it might be trying to load it from the root directory? Perhaps switching to relative paths would be better? This could also simply be a problem with browserify. I really appreciate the work you put into this library and I want to be able to use it in browser if possible! Thanks!
Hi,
When i generate qrcode with this data :
"201601250031200000030042,戊二醛、苯扎溴铵溶液(水产用),兽药字(2013)170229276,金谷药业,07133387188"
It can not scan.
Thankz,
While running node js if bwip js is included, if there is a crash instead of the stack trace the contents of /private/var/www/konnect/node/node_modules/bwip-js/freetype.js are printed.
/private/var/www/konnect/node/node_modules/bwip-js/freetype.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(typeof Module==="undefined")Module={};if(!Module.expectedDataFileDownloads){Module.expectedDataFileDownloads=0;Module.finishedDataFileDownloads=0}Module.expectedDataFileDownloads++;((function(){var loadPackage=(function(metadata){function runWithFS(){var fileData0=[];fileData0.push.apply(fileData0,[79,84,84,79,0,13,0,128,0,3,0,80,67,70,70,32,137,224,82,238,0,0,7,132,0,0,45,223,70,70,84,77,101,130,23,249,0,0,55,12,0,0,0,28,71,68,69,70,0,160,0,4,0,0,53,100,0,0,0,32,71,80,79,83,184,255,184,254,0,0,54,220,0,0,0,48,71,83,85,66,234,147,151,221,0,0,53,132,0,0,1,88,79,83,47,50,131,156,137,79,0,0,1,64,0,0,0,96,99,109,97,112,146,230,183,142,0,0,5,184,0,0,1,170,104,101,97,100,251,7,171,9,0,0,0,220,0,0,0,54,104,104,101,97,7,42,2,2,0,0,1,20,0,0,0,36,104,109,116,120,33,252,29,155,0,0,55,40,0,0,0,234,109,97,120,112,0,115,80,0,0,0,1,Pravins-MacBook:node pravin$
Any idea what is leading to this? I have to remove the module to make debugging possible currently.
Using node 6.0.0 on OS X 10.11.6
Tried the defaults and searched the docs, any hints on how to do a GS1 barcode, and condense the height of each bar of the stack to make it smaller. Similar to the general barcode height options on other barcodes like UPCA/E?
Below are examples of when we applied "height=20" and left the defaults. Notice the padding around the GS1 when height is applied also the stretch of the gs1 as well.
Hi there!
When I use your code to generate barcode code128 it take about 300ms, but when i use 'bwip' module it take about 40ms. Can you make it generate faster?
Thankz for help!
Say I create a barcode like so: http://api-bwipjs.rhcloud.com/?bcid=ean8&text=0123456&includetext&guardwhitespace&scale=1&height=100
What the hell height is that supposed to be exactly? It doesn't seem to be inches, mm, cm or pixels... So what is it?!
First of all, thank you so much for awesome API!
This is amazing!
I have implemented img tag using API but generated Micro QR code doesn't scan if the text is 5 digits numeric.
For example, 50041 doesn't generate scannable Micro QR code but 500411 works fine.
I have tested with various numbers and it seems to have a problem with 5 digits numeric data.
I have compared with other online Micro QR code and the the last bottom line is slightly different from other Micro QR codes.
When the text does not fit in the provided size of the QR Code, then an empty image is returned. I'd expect an error message, which would be easier to handle.
The following unit test succeeds:
it('width / height test', function (done) {
let options = {
bcid: 'qrcode',
text: 'very-long-text-that-will-not-fit-in-10px-by-10px',
height: 10,
width: 10,
scale: 1
};
bwipjs.toBuffer(options, (err, result) => {
let width = result.readUInt32BE(16);
let height = result.readUInt32BE(20);
expect(width).toBe(0);
expect(height).toBe(0);
done();
});
});
Great library by the way, but I'm getting an error with the node.js version. I have used the javascript browser addition fine.
Request: http://example.com/?bcid=ean13&text=0024600010030&includetext
Error: bwipp.typeError: options not an object
This seems to work fine against your service URL.
Barcodes calling the API are not generating. I went to http://api-bwipjs.rhcloud.com/ and get a 503 Service Temporarily Unavailable
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "bwip-js"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! shasum check failed for C:\Users\mac\AppData\Local\Temp\npm-14248-087bfa03\vossbasmgdd2oss01.ad.infosys.com_4873\bwip-js-\bwip-js-0.15.1.tgz
npm ERR! Expected: dfdd79361f48429a5019228f1a726c845dd74d2b
npm ERR! Actual: c6423acfcc980c7b55d06e4377439109510b26f3
npm ERR! From: http://vossbasmgdd2oss01.ad.infosys.com:4873/bwip-js/-/bwip-js-0.15.1.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! D:\mac\GITRepo\project\npm-debug.log
I'm trying to render this text I01.00057-2+110316 using this url:
but reading the png datamatrix code the result is always I01.00057-2 110316
It seems to replace '+' character with white space.
Thank you for any help.
Federico
Hello , after the barcode has been generated successfully, we can show it by calling bw.bitmap().show('canvas', 'N');, is there anyway to get the binary string of the generated image without putting it into canvas first?
I don’t see any declared dependencies in the package.json.
I’m just globally including bwip.js
from an $ npm install
(as directed) and I get the undefined error.
Hi there,
I'm seeing an array underflow error occasionally when rendering code128 barcodes:
BWIP-JS ERROR: array: underflow
My barcode is a 9 digit number and after the error occurs, if I run the code again it success so the problem appears to not be related to the code I'm using. Bwip-js is version 0.14.2. The code is:
var bwipjs = require('bwip-js');
...
this.generateBarCode(390223713, function(buffer){ ...});
...
exports.generateBarCode = function(codeInt, callback) {
console.log("+ pdfController.generateBarCode(%d)", codeInt);
var codeString = (""+codeInt).trim();
bwipjs.toBuffer({
bcid: 'code128', // Barcode type
text: codeString, // Text to encode
scale: 2, // 3x scaling factor
height: 5, // Bar height, in millimeters
includetext: false, // Show human-readable text
}, function (err, buffer) {
if (err) {
handleErr(err);
callback(null);
} else {
callback(buffer);
}
});
}
Stack trace:
at /app/node_modules/bwip-js/node-bwipjs:151:4
at BWIPJS.call (bwip.js:416:4)
at Function.module.exports.toBuffer (/app/node_modules/bwip-js/node-bwipjs:149:5)
My server memory is running at about 60% availability so plenty of that.
http://api-bwipjs.rhcloud.com/ is returning a 503 Service Temporarily Unavailable error.
Hi there!
Can we generate barcode a little bit faster. Each barcode take about one second, how can we generate more barcode with less time.
Thankz!
Hi there,
Is any options that I can prevent change the size of text when I change width of code 128.
Thankz!
Could you please tag 0.13 on github so that it'll also be downloadable from tools like bower?
As not to show messages on the console when I call bwipjs.toBuffer()?
ex:
...
2
x1,y1,x2,y2=2,0,2,144
optmz,penx,peny=true,4,4
x1,y1,x2,y2=7,0,7,144
...
Hi
Doing some tests on this, and for instance with aztec codes, they can be rather long.. And when i'm trying one very long i get:
BWIP-JS ERROR: Error: dict: seq: --undefined--
Dear support team,
How are you?
Thanks for your module.
When i encrypt data which is "20150921" into DataMatrix, i scan barcode result " 09 ".
I don't know how to set the option.
Would you like to support me?
thanks
I plan to use bwip-js in my HTML page. So I put all bwip-js files in one library folder called barcode
and create my HTML files outside of barcode
folder.
My project structure looks like below:
mydemo.html
/barcode
/bwipp
code128.js
code39.js
qrcode.js
...
/lib
baropts.js
canvas.js
...
/proofs
bwip.js
demo.html
freetype.js
freetype.js.mem
Inconsolata.otf
mydemo.html
file is copied from demo.html
and I update all the src properties of script tags, adding barcode/
prefix. However, it does not work with error net::ERR_FILE_NOT_FOUND
in browser.
After some digging, I find that BWIPJS.load
is defined in canvas.js
. It writes script
in document.head
to load javascript files. BWIPJS.prototype.call
uses BWIPJS.load
as below
BWIPJS.load('bwipp/' + name + '.js');
and every barcode type uses it as below
if (!BWIPJS.bwipp["raiseerror"] && BWIPJS.increfs("auspost", "raiseerror")) {
BWIPJS.load("bwipp/raiseerror.js");
}
if (!BWIPJS.bwipp["renlinear"] && BWIPJS.increfs("auspost", "renlinear")) {
BWIPJS.load("bwipp/renlinear.js");
}
That means the HTML file must be under the same directory of the bwip
folder to work correctly, i.e. brother of demo.html
.
I add barcode/
prefix to BWIPJS.load
as below
BWIPJS.load = function(path) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'barcode/' + path;
document.head.appendChild(script);
};
and my demo shows barcode well.
But it looks weird to me because now my library folder must be called barcode
and my HTML's still have to be in the same directory of barcode
folder.
Do I have another choice or do I have to do it like this? And even I add barcode/
prefix, there is still error in browser console
Failed to load resource: the server responded with a status of 404 (File not found)
freetype.js:15 Uncaught could not load memory initializer freetype.js.mem
which is generated code I could not modify.
It looks like there is an issue generating upca barcode.
For example 04256212
code will be genarated like a valid upca barcode:
But 04256212 != 042100005622
. Am I not right?
The link to the barcode using online generator.
Good day,
I'm trying to use the API, but the site responds with an error 503 Service Temporarily Unavailable. The site will be enabled again ?.
Exaplme: http://api-bwipjs.rhcloud.com/?bcid=code128&text=1234567890
Thank you very much.
cut it out
With IE, the generated barcode print-out is blurry and not scannable. With firefox and chrome, it is working fine
So I'm using this library in a few different ways, but one of which, is as part of a PDF rendering library, which utilises PrawnPDF to create the PDF. Now, I've noticed that when I use your library to generate a PNG I get an error when trying to add it to the PDF (a Prawn error):
Pallete-based transparency in PNG is not currently supported. (Prawn::Errors::UnsupportedImageType)
Which is detailed here: prawnpdf/prawn#783
I was wondering if there was any way that I could change the output format of the PNG such that it is in a supported format? That would be hugely useful!
Im trying to use this in a phonegap app but I am having trouble understanding how it works. I would appreciate an example. Thank you.
Example:
https://api-bwipjs.rhcloud.com/?bcid=upca&text=01123456789&includetext
Renders the barcode, but not the text underneath
Hi there!
I use gs1-qrcode and it take about 500Mb of RAM when I gen about 100 barcodes.
Can you guys help me out, please!
Thanks.
I am having trouble getting my barcode to scan because it appears I am not using FNC1 characters correctly. When I use the bwip-js PNG generator to create a GS1-128, it works unless I have a variable length field. It works if I type the text into the online generator, but not when I use the API, so it must have to do with the text string I am feeding the encoder being missing something it needs.
If I have a variable length field that I would like to parse properly but there is nothing in the GS1-128 documentation (that I could find) that says what character(s) to use to indicate the end of the field. Assuming I have an (21) field with x number of characters like so: (21)523451234. How do I tell it to end the barcode after the 4? I saw some with ^FNC1 online but that did not work when I placed it at the beginning of the barcode, end of the barcode, beginning of the AI and end of the AI.
The documentation says the width and height parameters are in millimeters. How do I reliably convert that to pixels, for example when I want the barcode to be 100px high? Height 100 (mm) gives me a 566 high image (px). So I ended up dividing by 5.66 before calling bwip-js. However, that doesn't relate to 72 or 144 dpi nor to factor 25.4 to convert from mm to inch.
Thanks for providing insight why 566 is the magic number.
I was just thinking to myself about the Node.js server example and I realised that the server will be running entirely on one thread (as is the Node.js way). But I assume that the bwipjs(req, res);
involves a fair amount of processing?
So I feel like this example (& the real server that runs it) could be made potentially much more efficient by utilising the new cluster
module in Node.js (https://nodejs.org/api/cluster.html).
We could spawn a worker for each core that the server has and use these for the processing...? I'm still looking as to how we'd actually go about doing this, but it could lead to some pretty impressive performance gains, with minimal code addition.
Hi:
I need run bwip-js in embedded linux without browser and without node.js (too big). Is it possible to run bwip-js with duktape or mujs, the bwip-js and mujs are javascript interpreters?
I tried this:
http://api-bwipjs.rhcloud.com/?bcid=gs1-128&text=(019931265099999891SHW400000101000600206)&scaleX=1&scaleY=2
I also used my own nodejs in ubuntu server, got the same result.
I printed the barcode, the quality is poor in thermal printer, cannot be scanned, Is there anything to be configured?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.