B4A Library [B4X] [B4XPages] Dynamsoft Barcode Reader - Cross-Platform Barcode/QR Code Scanning Library

Dynamsoft Barcode Reader is a barcode reading SDK written in C++ and has Java/Objective-C packages, so it is possible to wrap it as a B4X library using JavaObject and NativeObject.

It is a commercial SDK that has good performance and customizability.

The current version is very basic. I only wrapped the basic decode method and a TextResult class (storing the barcode content and localization results).

The library is made for B4A, B4i and B4J.

How to use:

1. Initialize

B4X:
Sub Class_Globals
    Private reader As DBR
End Sub
Private Sub init
    reader.Initialize
    'request your license here: https://www.dynamsoft.com/customer/license/trialLicense?ver=latest
    #if b4j
    reader.initLicenseFromKey("<license key>")
    #else
    reader.initLicenseFromLTS("200001")
    #End If
End Sub

2. Read barcodes from an image

B4X:
Private Sub Decode(bm as B4XBitmap)
    Dim results As List=reader.decodeImage(bm)
    Dim sb As StringBuilder
    sb.Initialize
    For Each result As TextResult In results
        sb.Append("Text: ").Append(result.Text).Append(CRLF)
    Next
    Log(sb.ToString)
End Sub


Additional libraries are required:

1. Download the jar/aar/framework files from its website.
2. Use AdditionalLib/AdditionalJar to reference dependant libraries.

For B4A:

B4X:
#AdditionalJar: DynamsoftBarcodeReaderAndroid.aar

For B4i:

B4X:
#AdditionalLib: DynamsoftBarcodeReader.framework.3
#AdditionalLib: libc++.tbd

For B4J:

B4X:
#AdditionalJar: dynamsoft-barcodereader-8.2


I've created a demo using B4XPages and packaged a b4xlib.

b4j.jpg


v1.0 2021/05/14
Released
 

Attachments

  • demo_BarcodeReader.zip
    15.5 KB · Views: 204
  • DynamsoftBarcodeReader.b4xlib
    6.5 KB · Views: 197
Last edited:

xulihang

Active Member
Licensed User
Longtime User
Screenshot_2021-05-14-15-18-34-1.png


A live barcode scanner is made based on this example: [B4X] [B4XPages] Barcode Reader. LLCamera is used in iOS to provide camera preview.

Update (2021/05/14): Added the B4J version which uses B4JVlc to utilize Web Cameras

desktop.jpg
 

Attachments

  • Barcode_Scanner.zip
    175.8 KB · Views: 187
  • Barcode_Scanner (include B4J).zip
    179.6 KB · Views: 204
Last edited:

xulihang

Active Member
Licensed User
Longtime User
Is it easy to add PDF417? Because there is currently no possibility in B4I.

Here is the supported symbologies list from the website. PDF417 is supported.

Linear Barcodes (1D):
  • Code 11
  • Code 39 (including Code 39 Extended)
  • Code 93
  • Code 128
  • Codabar
  • Interleaved 2 of 5
  • EAN-8
  • EAN-13
  • UPC-A
  • UPC-E
  • Industrial 2 of 5
  • MSI
  • PharmaCode
2D Barcodes:
  • QR Code (including Micro QR Code and Model 1)
  • Data Matrix
  • PDF417 (including Micro PDF417)
  • Aztec Code
  • MaxiCode (mode 2-5)
  • DotCode
Patch Code
GS1 Composite Code
GS1 DataBar
Postal Codes
 
Last edited:

AnandGupta

Well-Known Member
Licensed User
Longtime User
Thanks @xulihang for the tutorial.

Your tutorial further gave me understanding of creating wrapper from Java code for B4X. 👍
 
Top