Comments (5)
Very timely issue as this usage has only been supported in releases from just a couple of weeks ago. Convert the buffer to 'binary'
string and set binarytext:true
on the options object you pass in:
bwipjs.toCanvas(`canvas`, {
bcid: 'datamatrix',
text: buffer.toString('binary'),
binarytext: true,
});
You must use version 3.4.5 or 4.0.0+.
from bwip-js.
Thank you for the quick response. I installed the latest package and tried as you suggested.
I am still getting the exact same Datamatrix as before with latin1
from bwip-js.
There may be a bug somewhere. I used binary encoding on a buffer, with binarytext
. I then read the generated Datamatrix using the online tool listed below. The data read by the tool was different than what was submitted to bwip-js.
it('compare binary encoding input with output', () => {
const data = Buffer.from(
'0200254fb2031144757374696e204a616d6573204275636b',
'hex'
);
const binaryEncoded = data.toString('binary');
// Generate a data matrix using bwip-js@4 with binarytext=true
// Read generated barcode using: https://online-barcode-reader.inliteresearch.com/
// Generated Datamatrix has a extra `c2` at position 8
const bwip = Buffer.from(
'0200254fc2b2031144757374696e204a616d6573204275636b',
'hex'
);
console.log({
expected: binaryEncoded,
dataMatrix: bwip.toString('binary'),
});
});
Result
{
expected: '\x02\x00%O²\x03\x11Dustin James Buck',
dataMatrix: '\x02\x00%O²\x03\x11Dustin James Buck'
}
I should be able to extract the original text from the Datamatrix.
from bwip-js.
Found the issue. Mistakenly marked binarytext as a bwip-js option but it is needed by the BWIPP wrapper code. Fixed in 4.0.1.
from bwip-js.
Thank you very much for the quick response! I confirmed the output is as expected, you may close this issue.
❤️
from bwip-js.
Related Issues (20)
- Property 'toCanvas' does not exist on type 'typeof BwipJs' HOT 18
- nodejs 20.10.0 generate a different barcode compare when I use nodejs 20.9.0 HOT 3
- Datamatrix generation fo binary data after 3.4.0 has extra bytes HOT 3
- 4.2.0 will not generate the same barcode as 3.0.1 HOT 3
- please tag when doing a npm publish HOT 1
- Uncaught ReferenceError: BwipJs is not defined - Runtime error HOT 2
- New option showbearer via BWIP 2023-07-2 HOT 4
- backgroundcolor with # doesn't work or throw an error HOT 1
- extra `1px` @ bottom and/or left within `code128` [toSVG] HOT 6
- Height problem HOT 1
- Updated from v3.4 to v4.3.2 Bugs HOT 3
- Bwip-js and Cloudflare Workers - suggestion to include additional information to documentation HOT 1
- TypeError: (0 , _bwipJs.qrcode) is not a function HOT 10
- generate QRCode with Chinese character is not right HOT 23
- Can we show 2 strings one on top and other on bottom? HOT 1
- RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. HOT 1
- Does this library support react-native? HOT 4
- `cvx exec` eliminated from BWIPP
- Generating ISBN & ISSN barcodes using the `addontextfont` flag to change fonts (via zCommand Line) HOT 3
- unsafe asynchronous execution HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bwip-js.