GithubHelp home page GithubHelp logo

Comments (5)

metafloor avatar metafloor commented on September 26, 2024 1

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.

ibliskavka avatar ibliskavka commented on September 26, 2024

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

image

from bwip-js.

ibliskavka avatar ibliskavka commented on September 26, 2024

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.

metafloor avatar metafloor commented on September 26, 2024

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.

ibliskavka avatar ibliskavka commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.