Library: How to differentiate the type of the scanned code?

Created on 30 Jun 2020  路  3Comments  路  Source: zxing-js/library

Hello there,

It's amazing that this library deals with many different types of code, it really does what I was looking for.

I was wondering if someone could share a way to tell which code is being scanned.

I'm using the multi reader class.

Should I consider that the property 'format' gives me this info?
format: 11 - > Qrcode
format: 7 - > Bar code

question

All 3 comments

You are right, ZXing.BarcodeFormat provides the list of all formats. You can cycle through the properties to find the right one... They are a Typescript ENUM so you cannot be certain that format 11 will always be QR_CODE... If you need to test to see if it is a specific type, simply test using result.format === ZXing.BarcodeFormat.QR_CODE

I just realized, result.format is a private property. It would be safer to use result.getBarcodeFormat()

Thanks @Salketer

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helloo0-0oword picture helloo0-0oword  路  8Comments

jsid72 picture jsid72  路  6Comments

michael-pearson picture michael-pearson  路  6Comments

mattmahn picture mattmahn  路  7Comments

boruchsiper picture boruchsiper  路  7Comments