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,024

FabioG

Active Member
Licensed User
Longtime User
you are a great
This is exactly what I was looking for!

Thank you so much :)
 

sorex

Expert
Licensed User
Longtime User
might come in handy indeed.

just wondering...

why does it need an internet connection?

the library just posts to an online barcode image generator and shows the returned image?
 

GMan

Well-Known Member
Licensed User
Longtime User
Hoi NJDude,

Thx for that lib, works fine.
When playing around with the last 2 parameters (Back- & ForeColour) i noticed hat not all colours take effect ?
Like this
B4X:
bc.GenerateBarcode(BarcodeView, "qrcode" , "1234567890", Colors.Blue , Colors.Yellow )
it shows the code green on light blue.

Or are the colours "mixed" like complimentary colours ? ;)
 

NJDude

Expert
Licensed User
Longtime User
might come in handy indeed.

just wondering...

why does it need an internet connection?

the library just posts to an online barcode image generator and shows the returned image?
The library is using an external API.
 

NJDude

Expert
Licensed User
Longtime User
Hoi NJDude,

Thx for that lib, works fine.
When playing around with the last 2 parameters (Back- & ForeColour) i noticed hat not all colours take effect ?
Like this
B4X:
bc.GenerateBarcode(BarcodeView, "qrcode" , "1234567890", Colors.Blue , Colors.Yellow )
it shows the code green on light blue.

Or are the colours "mixed" like complimentary colours ? ;)

You have to enter the colors like this: B4AB4A or FCAB12
 

GMan

Well-Known Member
Licensed User
Longtime User
Thx for your reply - works fine now :)
 

Mahares

Expert
Licensed User
Longtime User
Using NJDude masterful new library, I was trying to generate multiple barcodes from a SQLite table column by iterating through all data in that field. However, it only creates a barcode for the last record in the table. Please see my attached project for complete code.
 

Attachments

  • BarCodeCreateMahares.zip
    8.2 KB · Views: 386

NJDude

Expert
Licensed User
Longtime User
The lib as of right now is not designed for batch processing, I will have to modify it to do so.
 
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Always good practice to share which external API you use, this because of rate limits and warranty issues when deployed in an app.
 

Mahares

Expert
Licensed User
Longtime User
I made another attached complete project where I create barcode files in a batch mode that does the following:
1. Cycle through all SQLite table records and create a batch of barcode files whose names are the selected column data.
2. Optionally zip all the files into one zip file to reduce memory usage.
3. Optionally delete all barcode png files and only leave the zipped file to free disk space.
It works for a small table, but I am not sure it is suitable for a large table because of the intensive file creation. In the event USADude (formerly NJDude) has time to rebuild his library, his method will certainly be superior.
 

Attachments

  • BarCodeCreateBatch.zip
    10.1 KB · Views: 370

Shay

Well-Known Member
Licensed User
Longtime User
Can I get indication if failed or success to create barcode
and if failed not present it (currently if failed, I get error on screen)
 

NJDude

Expert
Licensed User
Longtime User
The API returns a PNG either if it fails or not, there's no way to "read" what the PNG contains. You will have to validate the data before sending it to process.
 

GMan

Well-Known Member
Licensed User
Longtime User
Best seems BARCOO, the ZING Scanner (for me) is not as good as the other one.
 

NJDude

Expert
Licensed User
Longtime User
You should create your own thread, your code is not relevant to this thread.
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Hi All,
Is there a possibility to use this for B4J.

Please help need Datamatrix for a project.
 
Top