B4A Library Barcode Generator

This library will allow you to generate barcodes and place them on an ImageView or download them as a file.


Requirements:

1- Internet connection

2- Copy the BarcodeGenerator.jar and BarcodeGenerator.xml to your additional libraries directory.


Usage:
B4X:
'Initialize the library
Dim bc As BarcodeGenerator

bc.Initialize

'If you just want to display the barcode do this:
bc.GenerateBarcode(ImageView1, "qrcode" , "1234567890", "", "")

'If you want to save the barcode as a picture then do this:
bc.SaveBarcode(File.DirDefaultExternal, "MyBarcode.png", "qrcode", "12345", "", "", False)

That's it.

This library supports the following formats:
QRCODE, DATAMATRIX, PDF417, POSTNET, UPC-A, UPC-E, EAN-8, EAN-13, CODE39, CODE93, CODE128, CODABAR and ISBN
 

Attachments

  • BarcodeGenerator_Lib_1.0.zip
    4.6 KB · Views: 1,361

luciano deri

Active Member
Licensed User
Longtime User
Hi all. I need read a ean 128 barcode with a scanner in emulator keyboard, but in the edittext.text i don't see the FNC1 char, so in decoder sub i can't divide this. Some one can help me? Thanks
 

morphe2011

Member
Licensed User
Longtime User
Hello All,
I've been using this very simple yet cool library for a couple of months without issue until yesterday. It is used to generate a QR Code and Code 128 within a simple shopping app. Nothing has changed withing the app and as far as know, nothing on my development box yet now, no matter what type of code I try and generate I get [java.lang.RuntimeException: Error loading bitmap.] The code is simple an example of which is 0/Store Name/$5.0. It is going into an image view which is visible on the screen . The line putting it into the image view is
bc.GenerateBarcode(ivBarcode, "CODE128" , lOfferId & "/" & gsStore & "/$" & dOffer ,"#FFFFFF", "#000000")

The app always has an internet connection. Any help or suggestions would be most apprecaited
 

morphe2011

Member
Licensed User
Longtime User
Remove the "$" sign.
Thank You for the reply. I am however no further ahead. I created a test project with only this library and the code loaded. The code on Activity_Create is
Dim bc As BarcodeGenerator
bc.Initialize()
Dim ivtest As ImageView
ivtest.Initialize("")
Activity.AddView(ivtest,10dip,200dip,100%x,100dip)
bc.GenerateBarcode(ivtest, "code128" , "10012315" ,"#FFFFFF", "#000000")

I don't use emulators. I've tried it on a number of Samsung products and my regular phone. All are on-line. The lowest API is 18(4.3), the highest is 21 (5.1)
What am I doing wrong?
 

morphe2011

Member
Licensed User
Longtime User
Ugh :( I'll have to write my own API which I've done in the past. It's all about available time. Thanks for your help.
 

rafaelcamara

Member
Licensed User
Longtime User
please, I'm trying to test the barcode generator that downloaded the forum but this returning an error that could not identify
java.lang.RuntimeException: Method: drawCode128 not found in: JHS.BarcodeGenerator.code128
this occurs when you run the method in module

Sub drawCode128 (date As String) as Bitmap
Return nativeMe.RunMethod ("drawCode128" As Object Array (date))
end Sub

what can this missing?
 

Johan Schoeman

Expert
Licensed User
Longtime User
please, I'm trying to test the barcode generator that downloaded the forum but this returning an error that could not identify
java.lang.RuntimeException: Method: drawCode128 not found in: JHS.BarcodeGenerator.code128
this occurs when you run the method in module

Sub drawCode128 (date As String) as Bitmap
Return nativeMe.RunMethod ("drawCode128" As Object Array (date))
end Sub

what can this missing?
It seems as if you are referring to this project:
https://www.b4x.com/android/forum/t...e-java-code-and-the-zxing-core-library.60831/
I have just downloaded the project that I have posted and it is working fine - it creates all the barcodes in the project without any error for code128. Do you have the code module for Code 128 in your project? It should be there unless you have removed / deleted it by accident. See the pic below.

CODE128.png
 

Tomasz Pezda

New Member
Licensed User
Longtime User
I've problem after added BarcodeGenerator lib.
During compilation reports problem with http.jar file
 

Attachments

  • barcodeErr.png
    barcodeErr.png
    31.7 KB · Views: 93

drgottjr

Expert
Licensed User
Longtime User
you've got 2 problems here:
1) we don't use http.jar anymore (long time since). it's okhttp.jar, and it's now part of b4a's core libraries. along with it is okhttputils2.b4xlib. anything you develop needs to use the new libraries.
2) the barcode generator library uses the old http.jar (it's an old library). i have a copy which i'm attaching. unzip the archive into your additional libraries folder. open your b4a project and select http.jar in the additional libraries tab. i think that should do it. (note: if your b4a project is already open when you unzip the archive, you need to refresh the ide so that the newly unzipped jar appears (put the mouse in the additional libraries tab and right click to refresh. http.jar will appear and you can select it.)
 

Attachments

  • oldhttpjar.zip
    16.3 KB · Views: 133
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
I've problem after added BarcodeGenerator lib.
During compilation reports problem with http.jar file
See post #25

 
Last edited:
Top