FieldSoftware
Home

PrinterCE SDK
   General Info
   Download
   Purchase & Pricing

Developer Info
   eVC MFC
   eVC C/C++
   eVB

Special Features
   AsciiCE
   PrintDC
   BarcodeCE

Documentation
   PrinterCE SDK
   AsciiCE
   PrintDC
   BarcodeCE

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

.Net CF C# or VB.Net:
  PrinterCE.NetCF SDK

-----------------------------

Software Developers
  PrinterCE SDK
 
PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

 Arcade Games
  SockOut
  MazeCraze

Contact Info

BarcodeCE Developer's Guide
Library Name : BarcodeCE
DLL Name : PrEngineCE.dll
Control Name: PrEngineCE.BarcodeCE  

Download Word Doc copy of this Developer's Guide

The BarCodeCE control is closely linked to the PrinterCE control. PrinterCE is used for basic printing functions (such as SelectPrinter, EndPage, EndDoc, etc). BarCodeCE can be viewed as an extension to PrinterCE. BarcodeCE functions are available to eVB, MFC/CE and C++ applications.  

General information on BarcodeCE

A quick eVB program to draw a UPC barcode is:

 Set PrinterCE1 = CreateObject("PrEngineCE.PrinterCE")
 Set BarcodeCE1 = CreateObject("PrEngineCE.BarcodeCE")
 PrinterCE1.SelectPrinter
 
Dim Wid
 Wid = BarcodeCE1.DrawCode128("CODE 128",0,0,bcFontSize_DefaultSize,TYPE128_AUTO,bcTIGHT)
 PrinterCE1.EndDoc

 

 

General BarcodeCE parameters:

fit – Selects bar code bar and space widths:

Barcode "fit" Constants

Setting

Description

bcLOOSE

2

Loosest fit (widest)

bcMEDIUM

1

Medium fit (middle size)

bcTIGHT

0

Tight

bcTIGHTminus1

3

Narrowest fit

Barcode Height Resize: You can reduce the default height of a barcode (except for Postnet) by ORing one of the following resize percentages with the "fit" setting. For example, to print a barcode with the medium fit but print height of the barcode only 75% of default height, pass "bcMEDIUM | bcVResize_75" to fit.

Barcode Height Resize Constants

Setting

Description

bcVResize_95

0x5F00

Set barcode ht at 95% of default

bcVResize_90

0x5A00

Set barcode ht at 90% of default

bcVResize_85

0x5500

Set barcode ht at 85% of default

bcVResize_80

0x5000

Set barcode ht at 80% of default

bcVResize_75

0x4B00

Set barcode ht at 75% of default

bcVResize_70

0x4600

Set barcode ht at 70% of default

bcVResize_65

0x4100

Set barcode ht at 65% of default

bcVResize_60

0x3C00

Set barcode ht at 60% of default

bcVResize_55

0x3700

Set barcode ht at 55% of default

bcVResize_50

0x3200

Set barcode ht at 50% of default

WithText - Selects if barcode text will be printed with the barcode. Each barcode has a default font size (selected by "bcFontSize_DefaultSize") which will be adequate for most applications. However, the developer can override the default font by selecting between 4 and 16 point fonts:

With Text Constants

Setting

Description

bcFontSize_NoText

0

Do not include text with barcode

bcFontSize_DefaultSize

1

Use default point size for text

bcFontSize_04

4

Use 4 point font

bcFontSize_05

5

Use 5 point font

bcFontSize_06

6

Use 6 point font

bcFontSize_07

7

Use 7 point font

bcFontSize_08

8

Use 8 point font

bcFontSize_09

9

Use 9 point font

bcFontSize_10

10

Use 10 point font

bcFontSize_11

11

Use 11 point font

bcFontSize_12

12

Use 12 point font

bcFontSize_13

13

Use 13 point font

bcFontSize_14

14

Use 14 point font

bcFontSize_15

15

Use 15 point font

bcFontSize_16

16

Use 16 point font

As an example, using our earlier eVB demo (see top), let's modify it to print tighter/narrower (bcTIGHTminus1), at 75% of the height (bcVResize_75) and with 6 point font (bcFontSize_06):

BarcodeCE1.DrawCode128 "CODE 128",0,0,bcFontSize_06,TYPE128_AUTO,bcTIGHTminus1 Or bcVResize_75

 

BarCodeCE Methods and Properties

BarCodeHeight

This property returns the height of the selected bar code type. The height is in ScaleMode units (see PrinterCE docs).

MFC Syntax: float ht =BarcodeCE1.GetBarCodeHeight(long BarcodeType, long WithText);

C++ Syntax:   BarcodeCE1.get_BarCodeHeight(long BarcodeType, long WithText,float* ht);

eVB Syntax:  ht= BarcodeCE1. BarCodeHeight(BarcodeType,WithText)

Parameters

BarcodeType – Selected bar code type (see table below)

Constant

Setting

BC_UPCEAN

0

BC_MSI

1

BC_Code93

2

BC_Code128

3

BC_Codabar

4

BC_Code39

5

BC_Code2of5

6

BC_Postnet

7

WithText – See WithText definitions in "General BarcodeCE parameters" section at top.

Returns

ht – height (in ScaleMode units)


Draw2of5

Draws bar code of type interleaved 2 of 5 – Numeric characters only – any number. If an odd # of characters, than a 0 is pre-appended to front.

MFC Syntax:   float wid=BarcodeCE1.Draw2of5(BSTR bcstr,float x,float y,long WithText,long type2of5,long fit);

C++ Syntax:    BarcodeCE1.Draw2of5(BSTR bcstr,float x,float y,long WithText,long type2of5,long fit,float *wid);

eVB Syntax:   wid = BarcodeCE1.Draw2of5(bcstr, x, y, WithText, type2of5, fit)

Parameters

bcstr – string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
type2of5 – Sub-type of Code 2 of 5 to draw:

Constant

Setting

Description

TYPE2of5_BASE

0

 

TYPE2of5_CHECKSUM

1

Add optional modulus 10 checksum

fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawCode39

Draws bar code of type Code39 (also known as Code 3 of 9) - Any length alpha-numeric string. If “extended”=FALSE, character set is 0-9, A-Z, and following punctuation [- . SPACE * $ / + %]. If extended=TRUE, supports full 128 ASCII character set using bar code pairs per character.

MFC Syntax:   float wid=BarcodeCE1.DrawCode39(BSTR bcstr,float x,float y,long WithText,long type39,long fit, long extended);

C++ Syntax:  BarcodeCE1.DrawCode39(BSTR bcstr,float x,float y,long WithText,long type39,long fit, long extended, float *wid);

eVB Syntax:  wid = BarcodeCE1.DrawCode39(bcstr, x, y, WithText, type39, fit, extended)

Syntax

width = object.DrawCode39 barstring x y WithText,Type39 fit,extended

Parameters

bcstr – string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
Type39 – Sub-type of Code 39 to draw:

Constant

Setting

Description

TYPE39_NORMAL

0

 

TYPE39_CHECKSUM

1

Add modulo 43 checksum to bar code

TYPE39_HIBC

2

Preappends a “+” at the start of the barcode and appends modulo 43 check character at the end as adopted by HIBCC

fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

extended – If True, allows for full ASCII character set (128 chars) to be encoded. This requires 2 Code39 characters to be printed per character. If False, the basic (non-extended) Code39 character set is limited to 0-9,A-Z and 8 punctuation characters.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawCode128

Draws bar code of type Code 128. Any length alpha-numeric string, supporting full 128 ASCII character set. Allows numeric data to be compacted by special “2 numeric digits per character” encoding. If type128=TYPE128_UCC128, supports UCC-128 standard – restricted to exactly 19 numeric digits in the string

MFC Syntax: float wid=BarcodeCE1.DrawCode128(BSTR bcstr,float x,float y,long WithText,long type128,long fit);

C++ Syntax:     BarcodeCE1.DrawCode128(BSTR bcstr,float x,float y,long WithText,long type128,long fit,float *wid);

eVB Syntax:   wid = BarcodeCE1.DrawCode128(bcstr, x, y, WithText, type128, fit)

Parameters

bcstr– string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
type128 – Sub-type of Code 2 of 5 to draw:

Constant

Setting

Description

TYPE128_AUTO

0

Base type starts with one of 3 start chars (A, B, or C) and adds mod 103 check char followed by stop code at end.

TYPE128_UCC128

1

Fixed length 19 data digits. Adds “Start Code C” & “FNC 1” characters at start plus Mod 10 and mod 103 check characters at end, followed by stop code.

fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawCode93

Draws bar code of type 93 - Any length string, consisting of characters 0-9, A-Z and punctuation {- . SPACE $ / + %]. If extended=True, supports full 128 ASCII character set.

MFC Syntax: float wid=BarcodeCE1.DrawCode93(BSTR bcstr,float x,float y,long WithText,long fit,long extended);

C++ Syntax:     BarcodeCE1.DrawCode93(BSTR bcstr,float x,float y,long WithText,long fit,long extended,float *wid);

eVB Syntax:   wid = BarcodeCE1.DrawCode93(bcstr, x, y, WithText, fit, extended)

Parameters

bcstr – string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
fit –
See "fit" definitions in "General BarcodeCE parameters" section at top.
extended – If True: encodes full ASCII char set (128 chars). If False, encodes 0-9, A-Z + 11 punctuation chars.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawCodabar

Draws bar code of type Codabar - Any length string, consisting of characters 0-9 and punctuation - $ : / , +]. Also A, B, C, D are supported as special start/stop characters.

MFC Syntax: float wid=BarcodeCE1.DrawCodabar(BSTR bcstr,float x,float y,long WithText,long typecbar,long fit);

C++ Syntax:   BarcodeCE1.DrawCodabar(BSTR bcstr,float x,float y,long WithText,long typecbar,long fit,float *wid);

eVB Syntax:  wid = BarcodeCE1.DrawCodabar(bcstr, x, y, WithText, typecbar, fit)

Parameters

bcstr – string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
typecbar – Sub-type of Codabar to draw:

Constant

Setting

Description

TYPECodabar_BASE

0

 

TYPECodabar_CHECKSUM16

1

Add Checksum to bar code

fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawMSI

Draws bar code of type MSI-Plessey - Any length string up to 15 numeric characters 

MFC Syntax: float wid=BarcodeCE1.DrawMSI(BSTR bcstr,float x,float y,long WithText,long typeMSI,long fit);

C++ Syntax:                        BarcodeCE1.DrawMSI(BSTR bcstr,float x,float y,long WithText,long typeMSI,long fit,float *wid);

eVB Syntax:                            wid = BarcodeCE1.DrawMSI(bcstr, x, y, WithText, typeMSI, fit)

Parameters

bcstr – string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.
typeMSI – Sub-type of MSI to draw:

Constant

Setting

Description

TYPEMSI_Mod10

0

Adds 1 mod 10 checksum

TYPEMSI_Mod1010

1

Adds 2 mod 10 checksums

TYPEMSI_Mod1110

2

Adds on mod 11 checksum followed by one mod 10 checksum

fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawPostnet

Draws Zip+4 Postnet postal code - Numeric string 5 or 9 characters long (9 if using +4 digits). Allows for a dash “-“ to separate the first 5 and last 4 digits (ie: 95709-1234).

MFC Syntax: float wid=BarcodeCE1.DrawPostnet(BSTR bcstr,float x,float y,long WithText);

C++ Syntax:    BarcodeCE1.DrawPostnet(BSTR bcstr,float x,float y,long WithText ,float *wid);

eVB Syntax:   wid = BarcodeCE1.DrawPostnet(bcstr, x, y, WithText)

Parameters

bcstr– string to be “bar coded”.
x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).
WithText – See WithText definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

DrawUPC

Draws bar code of types: UPC-A, UPC-E, EAN-13/UPC-13 and EAN-8 plus UPC system designation.

MFC Syntax: float wid=BarcodeCE1.DrawUPC(BSTR leftstring,BSTR rightstring,BSTR xtrastring,float x,float y, long WithText,long typeUPC,long typeUPCsystem,long fit);

C++ Syntax:   BarcodeCE1.DrawUPC(BSTR leftstring, BSTR rightstring, BSTR xtrastring,float x,float y, long WithText,long typeUPC,long typeUPCsystem,long fit,float *wid);

eVB Syntax:  wid = BarcodeCE1.DrawUPC(leftstring, rightstring, xtrastring, x, y, WithText, typeUPC, typeUPCsystem, fit)

Parameters

leftstring, rightstring, xtrastring – strings to be “bar coded” in UPC/EAN format. If a string is not used in a particular UPC format, send “” empty string. UPC versions A and E can include a 2 or 5 digit supplemental string (xtrastring).

x,y – coordinates on page where the bar code will be drawn (in ScaleMode units).

WithText – See WithText definitions in "General BarcodeCE parameters" section at top.

typeUPC – Sub-type of UPC to draw:

Constant

Setting

Description

TYPE_UPC_A

0

Encodes 2 five-digit numbers. Preappends the UPC system number and adds checksum at end.

TYPE_UPC_E

1

Encodes 1 five-digit number

TYPE_UPC_EAN8

2

Encodes 7 digits plus a checksum character (first 2 digits are EAN/JAN flag chars)

TYPE_UPC_EAN13
 

3

The “typeUPCsystem” digit is added to the first digit of leftstring to form a 2-digit country flag code. The remaining 5 digits of lefstring and the 5 digits of rightstring form the data values. A checksum character is automatically added at the end. (See example below).

typeUPCsystem – selects UPC system used (0-9). Added to front of bar code.
fit – See "fit" definitions in "General BarcodeCE parameters" section at top.

Returns

wid – Width of the bar code in ScaleMode units. If the bar code string is not a valid format, returns –1.

Remarks

If x or y is a negative value then no bar code is actually drawn but the “width” returned is the actual width of this bar code. Use this when you need to know the width of the bar code to properly draw your page.

Bar codes use the PrinterCE “Justify” properties (JustifyHoriz and JustifyVert) to allow for Left/Center/Right horizontal and Top/Center/Bottom vertical justification. For example, if the justify properties are both set to vbCenter then the x,y coordinates will specify the page position where the center of the bar code will be drawn.

The xtrastring supplemental code is used primarily for paperback books and periodicals.

UPC Bar Code String Formats -Numeric strings with following formats:

TYPE_UPC_A : leftstring=5 digits & rightstring=5 digits. Xtrastring is optional with 2 or 5 digit supplemental code. The “typeUPCsystem” digit is preappended and a checksum is added at the end.

TYPE_UPC_E : leftstring=6 digits & rightstring=0 digits. Xtrastring is optional with 2 or 5 digit supplemental code.

TYPE_UPC_EAN8 : leftstring=7 digits & rightstring=0 digits. The first 2 digits are country flag codes, followed by 5 data characters. A checksum character is automatically added at the end.

TYPE_UPC_EAN13 : leftstring=6 digits & rightstring=5 digits. The “typeUPCsystem” digit is added to the first digit of leftstring to form a 2-digit country flag code. The remaining 5 digits of lefstring and the 5 digits of rightstring form the data values. A checksum character is automatically added at the end.

For example, the 13-digit UPC code 5060033952504 would be encoded as leading digit (5) to "typeUPCsystem", next 6 digits (060033) as "leftstring", next 5 digits (95250) as "rightstring" and the final digit (4) would be automatically calculated by BarcodeCE - so call might look like:

spB->DrawUPC(CComBSTR("060033"),CComBSTR("95250"),NULL, x, y, TRUE, TYPE_UPC_EAN13, 5, bcMEDIUM,&wid);