TBarCode DLL 11 Developer Manual
TBarCode DLL 11 Developer Manual
V ers io n 1 1
Developer Manual
6 M arc h 20 1 5
T EC- IT D a te n v er arb e it un g G m bH
Ha ns -W agner - Str . 6
A- 44 0 0 S te yr , A us t ri a
t + + 43 ( 0)7 2 52 72 7 20
f + + 43 ( 0)7 2 52 72 7 20 77
of f ic e @ tec - i t.c om
ww w. tec - i t.c om
T Bar Cod e Lib r a r y – D ev e lop er M anu al
1 Content
1 Content 2
2 Disclaimer 3
3 Introduction 4
3.1 What is TBarCode SDK? 4
3.2 What is TBarCode Library? 4
3.3 Scope of this Document 4
3.4 Restrictions of the Demo Version 5
4 Installation 6
4.1 TBarCode for Windows 6
4.1.1 Requirements 6
4.1.2 Download and Setup 6
5 General 7
5.1 TBarCode Library 7
5.1.1 Additional Dependencies 7
5.1.2 64-bit Systems 7
5.1.3 C/C++ Header Files 7
5.1.4 Linking 7
6 Using TBarCode Library 8
6.1 Important Functions 8
6.2 Calling Order 9
6.3 ANSI and UNICODE 9
7 C/C++ Sample Code 10
8 Custom Drawing Functions for Special Devices 12
8.1 Why Custom Drawing Functions? 12
8.2 The General Concept 12
8.3 Linear Barcodes & PDF417 12
8.4 2D Matrix Codes (Data Matrix, QR-Code, Aztec Code, etc.) 13
8.4.1 About Drawing 13
8.5 Postal Codes with Bars of Different Height 13
8.5.1 Barcode with 2 different heights 14
8.5.2 Barcodes with 3 different heights 14
8.5.3 Barcodes with 4 different heights 14
8.5.4 About Drawing 14
8.6 Control Patterns 15
8.6.1 Protruding Bars for EAN and UPC Codes 15
8.6.2 Increment and Decrement the Bar Width for EAN and UPC Codes 16
9 How to License TBarCode 17
9.1 Demo Limitations 17
10 Redistributing TBarCode 18
10.1 Dependencies 18
10.2 Redistribution 18
11 Contact and Support Information 19
Page 2 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
2 Disclaimer
The actual version of this product (document) is available as is. TEC-IT declines all warranties
which go beyond applicable rights. The licensee (or reader) bears all risks that might take place
during the use of the system (the documentation). TEC-IT and its contractual partners cannot be
penalized for direct and indirect damages or losses (this includes non-restrictive, damages through
loss of revenues, constriction in the exercise of business, loss of business information or any kind of
commercial loss), which is caused by use or inability to use the product (documentation), although
the possibility of such damage was pointed out by TEC-IT.
We reserve all rights to this document and the information contained therein. Reproduction,
use or disclosure to third parties without express authority is strictly forbidden.
Für dieses Dokument und den darin dargestellten Gegenstand behalten wir uns alle Rechte
vor. Vervielfältigung, Bekanntgabe an Dritte oder Verwendung außerhalb des vereinbarten
Zweckes sind nicht gestattet.
© 1998-2015
TEC-IT Datenverarbeitung GmbH
Hans-Wagner-Str. 6
A-4400 Austria
t.: +43 (0)7252 72720
f.: +43 (0)7252 72720 77
http://www.tec-it.com
Page 3 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
3 Introduction
TBarCode SDK is available in several versions for different operating systems, applications and
programming environments.
TBarCode OCX A Microsoft® ActiveX® compliant barcode control. It can be used with
Microsoft® Office applications as well as by software developers.
TBarCode .NET A .NET barcode library for software developers. It includes barcode
controls for Windows Forms and ASP.NET 2.0.
TBarCode Library A dynamically linked library (DLL) for software developers.
TBarCode/X TBarCode software for Linux® and UNIX® platforms. TBarCode/X includes:
command-line tools,
filter scripts, and
TBarCode Library for UNIX®.
The TBarCode setup for Windows® includes TBarCode Library as dynamically linked library (DLL).
A static library is available on request.
Page 4 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
In the demo version the barcodes will be drawn with a demo-hint. That means that the word “Demo”
or the phrase “www.tec-it.com” is drawn partially over the barcode (see Figure 6). The demo-hint
does not influence the readability of the barcode in a negative way.
When barcodes are generated in PostScript® or PCL® format, an additional horizontal bar is drawn
across the barcode. Like the other demo-hint this bar usually does not influence the readability of
the barcode. Its sole purpose is to indicate that the barcodes were generated with a demo version
of TBarCode.
► In special cases (e.g. very small or high-resolution barcodes) you may want to test the pro-
duct without restrictions. To obtain a temporary license key contact [email protected].
► For enabling the full-featured version (without the demo hints) you can obtain a license key
from TEC-IT (http://www.tec-it.com/order/).
► For more information on licensing TBarCode, please refer to chapter 9, “How to License
TBarCode”.
Page 5 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
4 Installation
TBarCode OCX
A barcode ActiveX control for Microsoft Office users and for software developers. User
manual and API reference are included in the setup.
TBarCode Library
For software developers. Developer manual and API reference are included in the setup.
TBarCode .NET
For .NET developers. Developer manual and API reference are included in the setup.
Page 6 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
5 General
Please keep in mind that TBarCode Library is a software component. It is not an executable by its
own. Read this document and check out the accompanying sample applications to learn how to
embed TBarCode into your own application.
► Make sure that the TBarCode Library (TBarCode11.dll) is located in a path included in the
‘PATH’ environment variable (or in the same directory as your application).
TBarCode Library further uses the DLL zlib1.dll. This DLL file is optional: zlib1.dll is only required if
compression of barcode data is applied.
If zlib1.dll is missing at runtime the TBarCode Library is still working, but data compression is dis-
abled.
On 64-bit systems you TEC-IT recommends to install the 64-bit version of TBarCode SDK. The 64-
bit setup contains both, 32-bit and 64- library. The name of the 64-bit library is TBarCode11_x64.dll.
It is located in the directory C:\Program Files\Common Files\TEC-IT\TBarCode\11.0, whereas the
32-bit library can be found in C:\Program Files (x86)\Common Files\TEC-IT\TBarCode\11.0.
The DLL is delivered with C/C++ header files needed for embedding the DLL (the library) into your
own application. These files are located in the folder C:\Program Files\TEC-IT\TBarCode11\Include
(or in the folder you have chosen during setup).
Include the file tbarcode.h in your project in order to get full access to the DLL functions within
C/C++:
#include "tbarcode.h"
Header files for miscellaneous programming environments (for example Delphi) are included in the
appropriate source code samples. Several samples are installed with TBarCode; more samples are
available on the TEC-IT web page http://www.tec-it.com.
5.1.4 Linking
TEC-IT provides the file TBarCode11.lib, which contains the entry points to the DLL interface. Link
your application using this file. This file is located in the folder C:\Program Files\TEC-
IT\TBarCode11\Lib (or in the folder you have chosen during setup).
Page 7 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
The basic function calls to produce a barcode are as follows (in the appropriate order).
BCLicenseMe()
This function licenses TBarCode and removes the demo restrictions. Licensing must be
performed before you draw a barcode (e.g. after TBarCode has been loaded to memory).
BCAlloc()
This function sets up and initializes the internal barcode structure. You receive a handle that
is used for all other function calls (pBarCode). This function must be called before any other
function which expects a parameter pBarCode.
BCSetBCType()
Sets the type of the barcode (symbology); e. g. Code39, Code128, UPC, EAN, 2OF5, ...
BCSetText()
Sets the data to be encoded as barcode.
BCSetModWidth() (optional)
This function is used if an application requires a specific module width. Without this function
the module width is computed automatically by TBarCode. It adapts to the barcode
dimensions (specified via a bounding rectangle) and the current input data.
BCCheck() (optional)
This function checks if the data characters are valid for the selected barcode type. If invalid
data was encountered it returns an error-code. If escape-sequences are used, they are not
translated in this function. It must be called before BCCalcCD().
Note: This function call is optional; BCCreate() calls this function in any case automatically.
BCCalcCD() (optional)
This function computes the check-digit(s) for the given input data and the selected check-
digit method. The check digits are added to the barcode data automatically. On demand you
can retrieve the check digits with BCGetCheckDigits(). Please consider that symbology
internal check digits (like modulo 103 of Code-128) are not calculated with this function –
they are always part of the created barcode.
Note: This function call is optional; BCCreate() calls this function in any case automatically.
BCCreate()
This function prepares the barcode structure (pattern) to be drawn with BCDraw(). It returns
ErrOk if everything is ok. If not, it returns an error code (of type ERRCODE) that specifies
the error in more detail. After BCCreate() all parameters of the resulting barcode are
available (e.g. number of modules, dimensions, check-digits, meta-description).
Page 8 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
BCDraw()
This function draws the barcode into the given device context. The barcode dimensions are
set through passing the coordinates of a bounding rectangle. No special mapping is
performed.
Note: Only available in TBarCode Library for Windows!
BCPostscriptToFile(), BCPCLToFile()
These function save the barcode in PostScript or PCL output format.
BCFree()
This function de-initializes the barcode info-structure and frees allocated memory. It must be
called as last function.
► If any of the BCxxxx functions in the above described order returns an error code not equal
to zero then DO NOT call subsequent BCxxxx functions (except of BCFree()). An error code
<> 0 indicates an error condition - subsequent calls (except of BCFree()) may fail and
produce unexpected results.
► Please note: Since TBarCode 8 the following calling order must be maintained to guarantee
the correct conversion of the input data to the target character set:
1. First set all barcode properties (like barcode type, translation of escape sequences, etc.)
2. Then call BCSetBCText()
3. Finally call BCCreate()
Preprocessor defines are provided to be compatible to ANSI and UNICODE builds. These defines
do not have a suffix.
Example:
// ANSI function - pass an ANSI text
BCSetTextA(t_BarCode* pBarCode, LPCSTR szText, LONG nLen)
To use the compatibility defines for the function names (like BCSetText()) while creating a
UNICODE build, you have to define the preprocessor variable _UNICODE before including
tbarcode.h:
#define _UNICODE
#include "tbarcode.h"
Page 9 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
Below are the steps to create a barcode image in C/C++ (only for demonstrative purposes, not all
variables declared).
► Also check out the fully functional samples provided with the setup – or available as
separate download.
// Adjust symbology
BCSetBCType(pBC, eBC_Code128);
Page 10 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
// Clean up
// nothing to do for Windows (except when using TBarCode as static library)
Page 11 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
Custom drawing functions can be registered as so called call-back functions. When drawing a
barcode the TBarCode Library will call the custom drawing functions instead of using the internal
drawing routines.
► IMPORTANT: Custom drawing functions will only work if a valid TBarCode license is
provided! Temporary license keys are available on request – please contact support@tec-
it.com. Section 9, “How to License TBarCode”, describes how to apply a license.
For barcodes, which are using multiple widths for the bars (or spaces), multiple uppercase (or
lowercase) letters are passed to the call-back function:
The factors for the module width depend on the current print-ratio. In this example the print-ratio for
the bars is 1:2:3:4
The factor for the module widths depend on the current print-ratio. In this example the print-ratio for
the bars is 1:2:3:4
Page 12 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
X represents the module width. All actual widths of bars or spaces are usually multiples of the
module width.
Each barcode symbology uses a pre-defined print-ratio (and this ratio can be adjusted by the user).
For example Code39 uses the following print-ratio: 1:3:1:3
A ... 1 X
B ... 3 X
a ... 1 X
b ... 3 X
It is possible to query the used print-ratio for a specific barcode symbology – please check out the
relevant functions BCGetRatioString, BCGetRatioHint, BCGetCountBars, and BCGetCountSpaces.
The row pattern consists of uppercase and lowercase letters. Uppercase letters serve as
placeholders for black bars (or squares) – lowercase letters are placeholders for spaces (white
squares):
The example above shows Data Matrix, but QR-Code and Aztec Code work in the same manner.
The pattern itself contains no absolute sizes. The matrix dots (A and a) have the same width and
height X. This is called the module width. By adjusting the module width to the size of the device
dots (pixels) you can minimize the printing tolerances.
In contradiction to other linear barcodes many postal codes don’t use multiple widths for the bars
but multiple heights. Instead of letters, digits are passed to the call-back function.
A single digit is a placeholder for a sequence of one bar and one space. All bars and spaces have
the same width of 1X (=module width). The heights of the bars differ.
Page 13 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
Depending on the barcode type the pattern string may contain two, three, or four different digits
(=heights).
Barcodes with 2 different heights consist of long bars and short bars, both sharing the same base
line, growing bottom up.
Barcodes with 3 different heights consist of long bars and short bars either growing bottom up or to
down, and short bars.
Barcodes with 4 different heights consist of long bars, medium sized bars either growing bottom up
or to down, and short bars, drawn vertically centered.
The pattern itself contains no absolute sizes. Following table gives you detailed hints how to convert
a given pattern to a valid barcode.
Page 14 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
Size and position of a bar is defined by the bar’s height (in percent of a full height bar) and the bar’s
distance from the upper edge (also in percent of a full height bar).
Intelligent Mail® Height: 100% Height: 66,7% Height: 66,7% Height: 33,3%
Barcode, Distance: 0% Distance: 0% Distance: 33,3% Distance: 33,3%
DAFT,
Japanese Postal
Table 1: Drawing Barcodes with Multiple Heights
Apart from letters and digits the pattern string may contain control characters. In the following you
find a short overview.
The barcode types EAN 8/13 and UPC A/E contain protruding bars on the begin, in the middle, and
on the end of the barcode. With ASCII (254) the section with protruding bars starts, after ASCII
(255) it ends. Bars of “normal” length follow. Protruding bars are extended on the bottom side by
about the half height of the human readable text.
Add-on sections start with ASCII (253). They continue until the end of the code. Add-on bars leave
space for the text above the barcode and align at the bottom with the protruding bars.
Page 15 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
8.6.2 Increment and Decrement the Bar Width for EAN and UPC Codes
ASCII (252) ... Begin bar width increment
ASCII (251) ... End bar width increment
ASCII (250) ... Begin bar width decrement
ASCII (249) ... End bar width decrement
Based on the definition of EAN and UPC codes the width of some bars has to be increased
whereas the width of other bars has to be decreased. This is done by the control patterns shown
above.
Page 16 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
In order to enable the full-featured version, you need a valid license key from TEC-IT. A description
of the available license-types as well as all necessary information for ordering can be found at
http://www.tec-it.com/prices.
If you don't know the license type according to your application, please ask our sales team
([email protected]).
► For testing the call-back API or other evaluation purposes you can request a time-limited
license key from [email protected].
To remove the demo limitations call BCLicenseMe() with valid a license key. For example:
ERRCODE eCode = BCLicenseMe("John Smith", eLicKindSite, 1,
"01234567890ABCDEFGHIJKLMNOPQRSTU", eLicProd2D);
Page 17 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
10 Redistributing TBarCode
This chapter explains what is important when redistributing a custom application that uses the
TBarCode Library.
► Please note that in most cases you need a developer license for re-distribution of TBarCode
Library (except for in-house applications which are bound to one or more sites).
10.1 Dependencies
TBarCode11.dll
This is a native Win32 (x86) library that performs barcode generation. This file is
mandatory for 32-Bit applications.
TBarCode11_x64.dll
This is a native Win64 (x64) library that performs barcode generation. This file is
mandatory for 64-Bit applications.
zlib1.dll
This is a 3rd-party library that performs data compression. This file is optional. It is only
required, when data compression in barcodes is enabled.
These files are located in the folder C:\Program Files\Common Files\TEC-IT\TBarCode\11.0 (or in
the folder you have chosen during setup).
TBarCode Library further requires the Microsoft VC10 Common Runtime DLLs. See next section
how to distribute them with your application.
10.2 Redistribution
When redistributing a custom application the files described above need to be redistributed together
with the application. The DLLs should be located in the same folder as the executable. Other files
than those listed above must not be redistributed.
You may have to redistribute the Visual C++ 2010 SP1 runtime components (MS CRT10.0 DLLs)
with your application and ensure they are installed on the target computer.
You can install these components with the Microsoft Visual C++ 2010 SP1 Redistributable
Package available at
- 32 Bit (x86) version: http://www.microsoft.com/en-us/download/details.aspx?id=8328
- 64 Bit (x64) version: http://www.microsoft.com/en-us/download/details.aspx?id=13523
Page 18 of 19
T Bar Cod e Lib r a r y – D ev e lop er M anu al
Address: Hans-Wagnerstr. 6
AT-4400 Steyr
Austria/Europe
Phone: +43 / (0)7252 / 72 72 0
Fax: +43 / (0)7252 / 72 72 0 – 77
Email: [email protected]
Web: http://www.tec-it.com
FAQ: http://www.tec-it.com/support/faq/tbarcode/Default.aspx
All other products mentioned are trademarks or registered trademarks of their respective companies. If any trademark on our web site or in this
document is not marked as trademark (or registered trademark), we ask you to send us a short message ([email protected]).
Page 19 of 19