PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • Printing a bar code from a report
  • Printing a bar code in WLanguage
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
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to print bar codes. You can use:
  • a "Bar code" control in a report.
  • iPrintBarCode in a print performed in WLanguage.
Printing a bar code from a report
The report editor proposes a "Bar code" control. The Bar Code control can be directly bound to an item in the data source of the report.
Bar Code controls can be configured in the description window ("Description" option on the context menu).
Different characteristics can be set according to the type of bar code:
  • bar codes with check: the last character of the bar code corresponds to a control character.
  • extended bar code: the value of the bar code can contain the 128 characters found in the ASCII code.
  • displaying (or not) the value of the bar code.
  • management of formatting.
  • management of control characters and management of character set.
Regardless of the type of bar code, you can also:
  • configure the size of the bar code.
  • configure the characteristics of the border.
  • manage the orientation of the bar code.
To print the bar code, assign the value of the bar code to the Bar Code control.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPad Special case: QR Code: the types proposed by default
In a report, you can print a QR Code. Then, this QR will be decoded by an application that will propose a specific action according to the type of the QR Code.
The assignment mode of the Bar Code control depends on its type.
By default, the description window of the control in the report editor proposes 4 simple types:
  • a Text QR Code: This type of QR Code is used to associate a text with the bar code. To initialize this type of QR Code, all you have to do is assign it with a character string. For example:
    BAC_QRCode = "I am a simple text"
  • a Web Link QR Code: This type of QR Code is used to directly open a site. To initialize this type of QR Code, all you have to do is assign it with a site address. For example:
    BAC_QRCode = "http://www.windev.com"
  • a Phone Number QR Code: This type of QR Code is used to directly call a phone number. To initialize this type of QR Code, all you have to do is assign it with a phone number. For example:
    BAC_QRCode = "010203040506"
  • an Email Address QR Code: This type of QR Code is used to get the email address of a contact. To initialize this type of QR Code, simply assign an email address to it. For example:
    BAC_QRCode = "doc@pcsoft.fr"
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPad Special case: QR Code: the specific types
You can also print QR codes (SMS, contact, geographic position, etc.). In this case, the data must be assigned to the Bar Code control using the BarCode type.
You must:
  1. Define a variable of type BarCode:
    MyBarCode is BarCode
  2. In the BarCode variable, specify the type of content of the QR Code (for example, for an SMS barcode):
    MyBarCode.TypeBarCode = BC_QRCODE
    MyBarCode.ContentType = bcTypeSMS
  3. Depending on the type of bar code, fill the corresponding element (see table below):
    Type of contentType of value (Content property)Remark
    bcTypeTextCharacter stringExample: "WINDEV is great!"
    bcTypePhoneCharacter stringExample: "0612345678"
    bcTypeSMSCharacter string in the following format:
    <Number> + CR + <Message>
    If they are specified, the members of the SMS structure (SMS.Message and SMS.Number) will be automatically taken into account.
    Example: "0612345678<CR>Text to send"
    bcTypeURLCharacter stringExample: "http://www.google.com"
    bcTypeEmailCharacter stringExample: "name@email.com"
    bcTypeContactEmpty. The members of the mContact structure will be automatically taken into account.
    bcTypeLocationgeoPosition variable.
    The Latitude and Longitude properties of the variable will be automatically taken into account.
Printing a bar code in WLanguage
To print a bar code in WLanguage, you must use iPrintBarCode.
iPrintBarCode proposes two syntaxes:
  • syntax used to print a bar code directly (this syntax does not support QR Codes):
    iPrintBarCode(<Value>, <Type>, <Coordinates of rectangle>, <Characteristics>)

    The parameters are as follows:
    • the value of the bar code. This value can be printed below the bar code.
    • the type of the bar code to print.
    • the coordinates (in pixels) of the rectangle in which the bar code will be printed.
    • the characteristics of the bar code (if necessary).
  • syntax used to print a bar code in a variable of type BarCode (this syntax supports QR Codes):
    iPrintBarCode(<BarCodes Variable>, <Coordinates of rectangle>)

    All the parameters of the bar code to print are specified in the BarCode variable.
Regardless of the syntax used:
  • The bar code is printed in an invisible rectangle. This rectangle is used to specify the position and size of the bar code to print.
  • "EAN" and "UPC" bar codes have proportional width and height. To enlarge these bar codes, it is necessary to increase both height and width.
  • iEndPrinting must be used to start the actual print. This function must be the last print function used.
The following example presents the click code of a button used to print a EAN 13 bar code. The value of the bar code is retrieved in the edit control named "EDT_EditBC".
iPrintWord("EAN 13 bar code:")
iPrintBarCode(EDT_EditBC, BC_EAN13, 10, 10, 50, 100)
iEndPrinting()
The following example allows you to print a QR Code:
MyQRCode is BarCode
MyQRCode.Content = "http://www.windev.com"
MyQRCode.ContentType = bcTypeText
MyQRCode.TypeBarCode = BC_QRCODE
iPrintBarCode(MyQRCode, 10, 20, 50, 60)
iEndPrinting()
Related Examples:
The Bar Code control Unit examples (WINDEV): The Bar Code control
[ + ] Using a Bar Code control
WD Reports Training (WINDEV): WD Reports
[ + ] This example presents the different methods for creating a report:

- prints based on different data sources (queries, variables, ...)
- prints based on controls (Table, Spreadsheet, PVT, ...)
- printing composite reports
- specific prints (portrait/landscape, report with watermark, report with bar code, ...)
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment