Softek Software Barcode Reading Toolkits
HOME PRODUCTS DEVELOPERS STORE ABOUT US
Developer Home
Downloads
Sample Code
Support

FAQ

The Softek Barcode Toolkit reads barcodes from images.

Which types of barcode work best on scanned images?

Which types of barcode work best on scanned images?

What are recommended settings for barcode width/height and image resolution?

What are recommended settings for barcode width/height and image resolution?

What system files are required for the DLL and OCX to work correctly?

What system files are required for the DLL and OCX to work correctly?

  What are the properties and methods of the Image Viewer Control?

What are the properties and methods of the Image Viewer Control?

How can I use the software in conjunction with LeadTools?

How can I use the software in conjunction with LeadTools?

Why do I get an extra character when I read a Code 39 barcode?

Why do I get an extra character when I read a Code 39 barcode?

I need to read more than one barcode from an image?

I need to read more than one barcode from an image?

How can I read a barcode from a PDF File?

How can I read a barcode from a PDF File?

Why can't I read Code 39 barcodes that have been created with a barcode font?

Why can't I read Code 39 barcodes that have been created with a barcode font?

How can I automate the reading of barcodes with Hylafax?

How can I automate the reading of barcodes with Hylafax?

How can I read barcodes from a bitmap in the Linux/Solaris/OSX etc version of the toolkit?

How can I read barcodes from a bitmap in the Linux/Solaris/OSX etc version of the toolkit?

Which types of barcode work best on scanned images?

Code 39 and Code 25 work best because they only have 2 widths of bar.

What are recommended settings for barcode width/height and image resolution?

The main requirement is for each black or white bar in a barcode to be clearly visible on the image. All barcodes have at least 2 sizes of bar and the image needs to be of high enough quality to show this. For example, a Code 39 barcode consists of 9 bars per character, of which 3 must be wide and 6 must be narrow. The wide bars should be around 2.5 times the size of the narrow bars - but for simplicity we will say 2 times the size. This means that each character needs at least 12 pixels in an image. This assumes that each pixel in the image lies either entirely in a black bar or entirely in a white bar. In practise, this isn't possible and so the resolution should allow around 36 pixels per character.

So, to encode a string of 10 characters (including the start and stop *) you will need at around 360 pixels. If the barcode is 1 inch wide on the paper then you will need to scan at a resolution of around 400 DPI. If the barcode is 2 inches wide then you will need to scan at a resolution of at least 200 DPI.

Some types of barcode have more than 2 widths of bar and a higher resolution still will be needed to ensure that the different widths can be distinguished on the image.

As for barcode height - if you have a very wide barcode then you need to ensure that it is high enough to cope with any skewing that takes place when the image is scanned.

In summary - the success of a project can depend on specifying the correct barcode size and image resolution.

Barcode Type Number of Characters Minimum Number of Pixels (approx)
Code 39 10 340
Code 2 of 5 (interleaved) 10 190
Code 128 (code set A) 10 280
Code 128 (code set B) 10 280
Code 128 (code set C) 10 170
EAN-13 13 190
EAN-8 8 140
UPC-A 12 190
UPC-E 8 120

What system files are required for the DLL and OCX to work correctly?

When packaging up the toolkit with your software you need to include the following files and install them into the windows system folder:

If you are using the standard windows DLL then you will need:

  • mfc42.dll
  • msvcrt.dll
  • SoftekBarcode.dll

If you are using the COM interface then you will also need SoftekATL.dll and msvcr70.dll 

If you are using the OCX/ActiveX interface then you will also need SoftekBarcode.ocx

If you are using the .Net component then you only need either the file SoftekBarcodeLib.dll or SoftekBarcodeLib2.dll

The only files that need to be registered are SoftekBarcode.ocx and SoftekATL.dll with a command such as:

regsvr32 C:\winnt\system32\SoftekBarcode.ocx

What are the properties and methods of the Image Viewer Control?

Properties:

  • integer ScaleType   0 = scale to width, 1 = scale to height, 2 = scale to zoom
  • integer PageNo   Page number in a TIF file.
  • integer PageCount   Number of pages in image (read only).
  • integer Orientation   0 = upright, 1 = 90 clockwise, 2 = 180 and 3 = 270.

Methods:

  • DisplayImage(filePath)   Display the specified file.
  • ZoomIn()   Enlarge image.
  • ZoomOut()   Reduce image size.

How can I use the software in conjunction with LeadTools?

The following code example shows how an image loaded with the LeadTools Main OCX can be scanned for barcodes with the Softek Barcode OCX. This code can be easily adapted for use with DLL functions:

m_LeadToolsMain.Load("s:\\tmp\\file.tif", 0, 0, -1) ;
long hdib = m_lead.GetDIB(0) ;
int n = m_SoftekBarcodeReader.ScanBarCodeFromDIB(hdib) ;

Download Simple VB6 Example

Why do I get an extra character when I read a Code 39 barcode?

Code 39 barcodes often include a checksum character, which is not usually printed under the barcode. There is no way for the toolkit to determine whether the last character is a checksum or just part of the barcode string - and so all the characters are included in the string returned to the calling application.

The checksum for Code 39 barcodes is usually a mod-43 checksum worked out as follows:

Each character in the symbol set has a value. 0 = 0, 1 = 1,...., 9 = 9, A = 10,......, Z = 35, - = 36, . = 37, space = 38, $ = 39, / = 40, + = 41, % = 42.

Sum the values of the characters and take the remainder on division by 43. This is the value of the checksum.

I need to read more than one barcode from an image?

By default the barcode toolkit returns as soon as it finds the first barcode in an image. To read more than one barcode from an image you need to set the MultipleRead property to True or to call the bardecode command with the -m option.

How do I read barcodes from a PDF File?

Windows developers can use the Softek Barcode Toolkit for Windows PDF Extension.

Linux developers can use Ghostscript to convert the PDF document to TIF before calling the Softek Barcode Toolkit to read the barcode:

gs -r300 -dNOPAUSE -q -sPAPERSIZE=a4 -sDEVICE=tiffg3 -sOutputFile=file.tif -- file.pdf
bardecode -t any -f file.tif

Why can't I read Code 39 barcodes that have been created with a barcode font?

Have you put the start and stop * characters around the barcode? If you want to create a Code 39 barcode for the string "ABCDE" then you need to type "*ABCDE*".

IMPORTANT: MS Word has a feature that automatically converts any text surrounded by * characters into bold. If this feature is enabled then your barcodes will not work. To disable this feature you will have to select Autoformat from the Tools menu and un-tick the "*Bold* and _Italic_ with real formatting" option on the "Autoformat as you type" tab.

How can I automate the reading of barcodes with Hylafax?

Hylafax calls a script called faxrcvd every time a fax is received. You can read the barcode from the image by inserting a line such as:

barcode=`/path_to_barcode_command/bardecode -t any -j 1 -f $qfile`
# Then do something with $barcode

For more information on the faxrcvd script please use the following link on the Hylafax web site: http://www.hylafax.org/man/faxrcvd.html


How can I read barcodes from a bitmap in the Linux/Solaris/OSX etc version of the toolkit?

The following function for reading barcodes from a memory bitmap is available in the bardecode.a library:

int STReadBarCodeFromBitmap(void *hBarcode, BITMAP *pBitmap, float resolution, char ***bc, char ***bc_type, short photometric)

Where:

hBarcode (in) is a handle to an instance of the barcode toolkit.
pBitmap (in) is a pointer to a BITMAP structure (see below)
Resolution (in) is the resolution of the bitmap.
Bc (out) is a pointer that receives a pointer to an array of barcodes found in the image.
Bc_type (out) is a pointer that receives a pointer to an array of barcode types found in the image (one for each barcode).
Photometric (in)specifies the value of a black pixel in a 1-bit image.

Return Value:

Number of barcode found in the image.

BITMAP Structure:

typedef struct tagBITMAP {
    int     bmType;
    int     bmWidth;
    int     bmHeight;
    int     bmWidthBytes;
    BYTE    bmPlanes;
    BYTE    bmBitsPixel;
    LPVOID  bmBits;
} BITMAP;



Where:

bmType should always be 0
bmWidth is the width of the bitmap in pixels
bmHeight is the height of the bitmap in pixels
bmWidthBytes is the width of a bitmap scan line in bytes (SEE NOTE BELOW).
bmPlanes should always be 1.
bmBitsPixel is the number of bits per pixel for the image and should be either 1, 8 or 24.


Important:


Please note that the end of all scan lines in the image are assumed to end on a 4 byte boundary. i.e. The number of bytes for each scan line of the bitmap should be divisible by 4.