ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Print functions
  • UPC and EAN barcodes: Size of barcodes
  • Size of bar codes
  • Printing a DataMatrix or PDF417 bar code
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Prints a bar code (inside a rectangle).
Remark: Print sent to printer spooler. To actually print the page, use iEndPrinting.
Example
// Impression de codes-barres
// Code-barres de type Interleaved 2 of 5
iPrintBarCode("12345678905", BC_INTER2OF5, 10, 10, 23, 50)
// Code-barres de type UPCA
iPrintBarCode("12345678905+22", BC_UPCA, 10, 10, 23, 50)
MonQRCode is BarCode
MonQRCode.Content = "http://www.pcsoft.fr"
MonQRCode.ContentType = bcTypeText
MonQRCode.TypeBarCode = BC_QRCODE
iPrintBarCode(MonQRCode, 10, 20, 50, 60)
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.
Barcodes concerned: all
BC_180Prints the bar code while performing a rotation equal to 180 degrees.
Barcodes concerned: all
BC_270Prints the bar code while performing a rotation equal to 270 degrees.
Barcodes concerned: all
BC_BottomBar code located at the bottom of destination rectangle.
Barcodes concerned: all
BC_CenterHBar code centered horizontally in the destination rectangle.
Barcodes concerned: all
BC_CenterVBar code centered vertically in the destination rectangle.
Barcodes concerned: all
BC_CharsetsBar code that uses one or more sets of characters to compress the bar code. This set of characters must be defined in the bar code value.
For more details, see The different types of bar codes.
Barcodes concerned: all
BC_CheckBar code with check characters.
Bar codes concerned: CB_CODE39, CB_CODE93, CB_INTER2OF5 and CB_CODABAR.
BC_CheckDigitsBar codes containing check characters.
If this option is selected, the BC_ControlDigits and BC_Charsets constants are automatically taken into account.
Relevant StrikeOut codes: CB_CODE128, CB_DATAMATRIX, CB_EAN128, CB_GS1_128, CB_PDF417.
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.
Relevant StrikeOut codes: CB_CODE128, CB_DATAMATRIX, CB_EAN128, CB_GS1_128, CB_PDF417.
BC_ExtendedExtended bar code.
Bar codes concerned: CB_CODE39 and CB_CODE93type bar codes.
BC_FormatTextFormats the text displayed: brackets are added around AIs in the printed text.
Bar codes concerned: EAN 128 or GS1-128type 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.
StrikeOut barcodes: CB_CODE128, CB_EAN128 and CB_GS1_128.
BC_LeftBar code aligned to left in the destination rectangle.
Barcodes concerned: all
BC_NoTextDisplays no text below the bar code.
StrikeOut barcodes concerned: CB_UPCA, CB_UPCB, CB_EAN13 and CB_EAN8.
BC_NotProportionalAdjusts the bar code to the size of destination rectangle.
Barcodes concerned: all
BC_RightBar code aligned to right in the destination rectangle.
Barcodes concerned: 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.
Barcodes concerned: all
BC_TextCenterCenters the text below the bar code.
Bar codes concerned: strikethrough type CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI.
Android This constant is not available.
BC_TextLeftAligns the text below the bar code to the left.
Bar codes concerned: strikethrough type CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI.
Android This constant is not available.
BC_TextRightAligns the text below the bar code to the right.
Bar codes concerned: strikethrough type CB_CODE128, CB_CODE93, CB_CODE11, CB_EAN128, CB_CODE39, CB_INTER2OF5, CB_CODABAR, CB_MSI.
Android This constant is not available.
BC_TopBar code located at the top of destination rectangle.
Barcodes concerned: all
BC_VerticalPrints the bar code vertically.
Barcodes concerned: 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 barcodes: Size of barcodes

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 given for drawing the barcode may not 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.
  • Character set: WINDEV optimizes the choice of character sets to write the smallest possible barcode.
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
    • 161 to 320 characters: level 4
    • from 321 characters: level 5
  • Line height: 4
  • Character set: WINDEV optimizes the choice of character sets to write the smallest possible barcode.
For more details, see The different types of bar codes.
Component: wd300prn.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/18/2024

Send a report | Local help