Printing bar codes using a C/C++ applications

There are three steps to printing bar codes;

(1) Collect and format the data you wish to print as a bar code (data is always formatted as a string).
(2) Use a bar code function to calculate the bar code from your data (the bar code is also a string).
(3) Use a bar code font to print the bar code string (then you see the actual bar code symbol).

Each bar code function takes a string argument and returns a string result. The string argument is the data you want to encode in the bar code, and the returned string result can be used to print the bar code. The bar code is printed by printing the string result using a specific bar code font. 

See Bar code functions for a list of the new functions and Bar code font name and font size to use for a list of the fonts to use with each bar code function.

File ciaxcom.c contains standard bar code functions (you can easily add your own if you wish).

- Add file ciaxcom.c to your project.

Include the header file ciaxcom.h in source files that use any function from ciaxcom.c

Most of the functions are very simple, and very easy to use. The example below uses the CIA_CODE39( ) bar code function.

#include "ciaxcom.h"

void main(void) {

    MyData[80];
    MyBarcode[512];

    // Collect data
    strcpy(MyData, "12345");
    // Calculate bar code
    strcpy(MyBarcode, CIA_CODE39(MyData));

    // MyBarcode now contains the bar code string that represents MyData

    // Print MyBarcode using font 'CIA Code 39 Medium' produces the bar code symbol
}

To simplify the example code, all examples are console applications.

Note: All examples require file CIABAR32.DLL in a directory on the PATH, for example C:\Windows\System, or in the same directory as the executable file (*.exe).

Each example is in its own directory.

Example 1: Test program to calculate all type of bar code strings

This example program tests every bar code functions in ciaxcom.c

main.c creates a text file showing the strings returned from each function.

How to build;

(1) Create a console application project and add all files in the directory to the project.
(2) Add file ciaxcom.c and ciaxbar32.lib to the project.

Example 2: Create applications without linking to ciaxcom.lib

If you use the Windows LoadLibrary function to dynamically load our DLL, you can supply our DLL only to end-users that pay for bar code capabilities. You must purchase a license for each user that prints bar codes directly or indirectly.

main.c loads the DLL and calculates bar codes.

How to build;

(1) Create a console application project and add all files in the directory to the project.
(2) Add file ciaxcom.c to the project.

Example 3: Need to know how to print to a printer using fonts

This example shows how to print text or bar codes (i.e. how to print using fonts) and how to print on a printer.

print.c contains a function that prints text on any printer.

main.c prints test bar codes on the default Windows printers.

How to build;

(1) Create a console application project and add all files in the directory to the project.
(2) Add file ciaxcom.c and ciaxbar32.lib to the project.

 

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.