ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Print functions
  • UPC and EAN bar codes: Size of bar codes
  • Size of bar codes
  • Printing a DataMatrix or PDF417 bar code
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Prints a bar code (inside a rectangle).
Remark: The print job is sent to the printer spooler. To actually print the page, use iEndPrinting.
Example
// Print bar codes
// Interleaved 2 of 5 bar code
iPrintBarCode("12345678905", BC_INTER2OF5, 10, 10, 23, 50)
// UPCA bar code
iPrintBarCode("12345678905+22", BC_UPCA, 10, 10, 23, 50)
MyQRCode is BarCode
MyQRCode.Content = "http://www.windev.com"
MyQRCode.ContentType = bcTypeText
MyQRCode.TypeBarCode = BC_QRCODE
iPrintBarCode(MyQRCode, 10, 20, 50, 60)
WINDEV
iDestination(iViewer)
MyCode is BarCode
MyCode.Content = "1234567"
MyCode.TypeBarCode = BC_EAN8
MyCode.Options = BC_Left + BC_NoText
iBorder(10, 20, 100, 60)
iPrintBarCode(MyCode, 10, 20, 100, 60)
 
iEndPrinting()
Syntax

Printing a bar code Hide the details

iPrintBarCode(<Value of bar code> , <Type> , <X1> , <Y1> , <X2> , <Y2> [, <Extended code>])
<Value of bar code>: Character string
Character string that will be represented as a bar code.
<Type>: Integer constant
Type of bar code to represent (the different types of bar codes supported by WINDEV are presented in Managing bar codes).
BC_AZTECAztec bar code.
BC_CODE128Code128 bar code.
BC_CODE39Code39 bar code.Bar code that can be used with <Extended code> corresponding to BC_Extended or BC_Check
The value of the bar code can contain the start and end characters ("*" character). In this case, these characters will be added to the drawing of the bar code and will be printed in the text displayed below the bar code.
If these characters are not found in the value of bar code, they will be automatically added to the drawing of bar code.
However, they will not be printed in the text displayed below the bar code.
BC_CODE93Code93 bar code.Bar code that can be used with <Extended code> corresponding to BC_Extended or BC_Check).
BC_CODE11Code11 bar code.This type of bar code is not available.
BC_INTER2OF5Interleaved 2 of 5 bar code.Bar code that can be used with <Extended code> corresponding to BC_Check.
BC_CODABARCodabar bar code.Bar code that can be used with <Extended code> corresponding to BC_Check.
BC_DATAMATRIXData Matrix bar code.
BC_EAN128EAN-128 bar code.This type of bar code is not available.
BC_EAN13EAN-13 bar code.Possible values for the bar code:
  • 12 characters,
  • 12 characters + 2 additional characters ("012345678912+22" for example)
  • 12 characters + 5 additional characters ("012345678912+22335" for example)
A control character is automatically inserted after the 12th character.
BC_EAN8EAN-8 bar code.Possible values for the bar code:
  • 7 characters,
  • 7 characters + 2 additional characters ("0123456+22" for example)
  • 12 characters + 5 additional characters ("012345678912+22335" for example)
A control character is automatically inserted after the 7th character.
CB_GS1_128GS1-128 bar code (new name for the EAN-128 bar code).
BC_MAXICODEMaxiCode bar code.
BC_MSIMSI bar code.This type of bar code is not available.
BC_PDF417PDF417 bar code.
BC_UPCAUPC-A bar code.Possible values for the bar code:
  • 11 characters,
  • 11 characters + 2 additional characters ("01234567891+22" for example)
  • 11 characters + 5 additional characters ("01234567891+22335" for example)
A control character is automatically inserted after the 11th character.
BC_UPCEUPC-E bar code.Possible values for the bar code:
  • 11 characters,
  • 11 characters + 2 additional characters ("01234567891+22" for example)
  • 11 characters + 5 additional characters ("01234567891+22335" for example)
A control character is automatically inserted after the 11th character.
<X1>: Real
Horizontal coordinate of the upper-left corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page width (returned by iPageWidth).
<Y1>: Real
Vertical coordinate of the upper-left corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page height (returned by iPageHeight).
<X2>: Real
Horizontal coordinate of the lower-right corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page width (returned by iPageWidth).
<Y2>: Real
Vertical coordinate of the lower-right corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page height (returned by iPageHeight).
<Extended code>: Optional Integer constant (or combination of constants)
Characteristics of bar code.
BC_90Prints the bar code vertically.
Affected bar codes: all
BC_180Prints the bar code while performing a rotation equal to 180 degrees.
Affected bar codes: all
BC_270Prints the bar code while performing a rotation equal to 270 degrees.
Affected bar codes: all
BC_BottomBar code located at the bottom of destination rectangle.
Affected bar codes: all
BC_CenterHBar code centered horizontally in the destination rectangle.
Affected bar codes: all
BC_CenterVBar code centered vertically in the destination rectangle.
Affected bar codes: all
BC_CharsetsBar code that uses one or more sets of characters in order to compress the bar code. This set of characters must be defined in the value of bar code.
For more details, see The different types of bar codes.
Affected bar codes: all
BC_CheckBar code with check characters.
Affected bar codes: BC_CODE39, BC_CODE93, BC_INTER2OF5 and BC_CODABAR bar codes.
BC_CheckDigitsBar codes containing check characters.
If this option is selected, the BC_ControlDigits and BC_Charsets constants are automatically taken into account.
Affected bar codes: BC_CODE128, BC_DATAMATRIX, BC_EAN128, BC_GS1_128 and BC_PDF417 bar codes.
BC_ControlDigitsBar codes containing control characters. By default, control characters are enclosed between "<" and ">". To avoid interpreting these characters as control characters, simply double the first "<":
  • "<C40>" = control character
  • "<<AB>" = <AB> to be encoded in the bar code.
For more details, see The different types of bar codes.
Affected bar codes: BC_CODE128, BC_DATAMATRIX, BC_EAN128, BC_GS1_128 and BC_PDF417 bar codes.
BC_ExtendedExtended bar code.
Affected bar codes: BC_CODE39 and BC_CODE93 bar codes.
BC_FormatTextFormats the text displayed: brackets are added around AIs in the printed text.
Affected bar codes: EAN 128 or GS1-128 bar codes.
BC_IgnoreFormattingIgnores the brackets found in a 128, EAN-128 or GS1-128 bar code.
The brackets allow the users to easily read the bar code but they are not drawn in the code.
Affected bar codes: CB_CODE128, CB_EAN128 and CB_GS1_128 bar codes.
BC_LeftBar code aligned to left in the destination rectangle.
Affected bar codes: all
BC_NoTextDisplays no text below the bar code.
Affected bar codes: BC_UPCA, Bc_UPCB, BC_EAN13 and BC_EAN8 bar codes.
BC_NotProportionalAdjusts the bar code to the size of destination rectangle.
Affected bar codes: all
BC_RightBar code aligned to right in the destination rectangle.
Affected bar codes: all
BC_TextDisplays the text below the bar code.
The text is normalized for the BC_UPCA, BC_UPCE, BC_EAN13 and BC_EAN8 bar codes.
For the other types of bar codes, the text can exceed the display border of bar code.
Affected bar codes: all
BC_TextCenterCenters the text below the bar code.
Affected bar codes: BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes.
Android This constant is not available.
BC_TextLeftAligns the text below the bar code to the left.
Affected bar codes: BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes.
Android This constant is not available.
BC_TextRightAligns the text below the bar code to the right.
Affected bar codes: BC_CODE128, BC_CODE93, BC_CODE11, BC_EAN128, BC_CODE39, BC_INTER2OF5, BC_CODABAR and BC_MSI bar codes.
Android This constant is not available.
BC_TopBar code located at the top of destination rectangle.
Affected bar codes: all
BC_VerticalPrints the bar code vertically.
Affected bar codes: all
Android This parameter is ignored.

Printing a bar code (BarCode variable) Hide the details

iPrintBarCode(<Bar code> , <X1> , <Y1> , <X2> , <Y2>)
<Bar code>: BarCode variable
Name of the BarCode variable containing the description of the bar code to print.
<X1>: Real
Horizontal coordinate of the upper-left corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page width (returned by iPageWidth).
<Y1>: Real
Vertical coordinate of the upper-left corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page height (returned by iPageHeight).
<X2>: Real
Horizontal coordinate of the lower-right corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page width (returned by iPageWidth).
<Y2>: Real
Vertical coordinate of the lower-right corner of the rectangle where the bar code will be drawn (in millimeters).
Value between 0 and the page height (returned by iPageHeight).
Remarks

UPC and EAN bar codes: Size of bar codes

The standard for the UPC and EAN codes defines the proportion between the height and width of bar codes. The drawings of these bar codes respect this standard by default. However, the BC_NotProportional constant allows you to draw "non-standard" bar codes.
Remark: The space used to draw the bar code cannot be occupied at 100%. Indeed, the size of each bar is calculated so that a bar code can always be read.

Size of bar codes

The actual width of the drawing of a bar code may be less than the specified width.
Indeed, the width of each bar is calculated from the with of the narrowest bar found in the bar code. The width of each bar must be a whole number of pixels.
Example for calculating the width of a bar code:
  • The drawing must be 130-pixel wide.
  • The drawing contains 10 narrow bars of width 1 and 5 large bars of width 2.
  • Calculating the width of a narrow bar = 110 / (10 + 5*2) = 5 pixels
  • Calculating the total width for the drawing = 5 * (10 + 5*2) = 100 pixels
Once the BC_CenterH constant has been used, the drawing will start at (110-100) /2 = 5 pixels from the left border and it will end at 5 pixels from the right border.

Printing a DataMatrix or PDF417 bar code

The following options are taken into account when a DataMatrix or PDF417 bar code is printed using iPrintBarCode:
Data Matrix
  • Matrix size calculated according to the length of string and optimized to get a squared matrix.
  • Set of characters: WINDEV optimizes the choice of character sets in order to write the bar code with the smallest possible characters.
PDF417
  • Matrix size calculated according to the string
  • Level of correction calculated according to the length (after compression) of the data to encode:
    • from 1 to 40 characters: level 2
    • from 41 to 160 characters: level 3
    • from 161 to 320 characters: level 4
    • from 321 characters: level 5
  • Row height: 4
  • Set of characters: WINDEV optimizes the choice of character sets in order to write the bar code with the smallest possible characters.
For more details, see The different types of bar codes.
Component: wd290prn.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help