Upload
ngotram
View
256
Download
0
Embed Size (px)
Citation preview
dLSoft dBarcode.NET Components Contents iii
Contents
dBarcode.NET Components 1
Introduction ............................................................................................................................... 1 The 1D components ..................................................................................................... 1 The 2D components ..................................................................................................... 2
Using dBarcode.NET Components in Visual Studio ................................................................. 2 Adding a dBarcode.NET Component to the ToolBox ................................................. 2 Adding a dBarcode.NET component to a project. ....................................................... 3 Setting the initial properties in a WinForms project .................................................... 4 Setting and retrieving property values programmatically ............................................ 4 Setting properties through the Barcode properties dialog box ..................................... 5 Displaying a barcode on a form ................................................................................... 6 Printing a barcode image ............................................................................................. 7 Saving a barcode image ............................................................................................... 7
Licensing the component ........................................................................................................... 8 1D Components Reference ........................................................................................................ 9
Summary of Properties and Methods .......................................................................... 9 Required properties ................................................................................................... 10 Information properties ............................................................................................... 19 Methods ..................................................................................................................... 20
ASP.NET ................................................................................................................................. 24 2D Components Reference ...................................................................................................... 27 dBarcode.NET 2D Component Properties ............................................................................... 27
Summary of Properties and Methods ........................................................................ 27 Required properties ................................................................................................... 28 Information properties ............................................................................................... 38 Methods ..................................................................................................................... 39
Deutschepost and PostMatrix .................................................................................................. 43 GS1 Encoding .......................................................................................................................... 44 Using 8-bit byte data ................................................................................................................ 44 2D Pattern strings .................................................................................................................... 45
Aztec .......................................................................................................................... 45 Codablock F and Code 49 ......................................................................................... 45 DataMatrix................................................................................................................. 45 MaxiCode .................................................................................................................. 45 MicroPDF417 ............................................................................................................ 45 PDF417 & Truncated PDF417 .................................................................................. 45 QR Code .................................................................................................................... 45 Databar ...................................................................................................................... 46
The GS1-Composite Component ............................................................................................. 46 Composite data .......................................................................................................... 46 CodeType .................................................................................................................. 46 Barcode size .............................................................................................................. 47
dBarcode.NET Dual component .............................................................................................. 49 Dual component Properties ....................................................................................... 49 Dual component CodeTypeValues ............................................................................ 51
dBarcode.Net Controls............................................................................................................. 53
iv Contents dLSoft dBarcode.NET Components
The 1D controls ......................................................................................................... 53 The 2D controls ......................................................................................................... 53
Using dBarcode.NET Controls in Visual Studio ..................................................................... 54 Adding a dBarcode.NET Control to the ToolBox ..................................................... 54 Adding a dBarcode.Net Control to a Form. ............................................................... 54 dBarcode Control methods ........................................................................................ 57 dBarcode Control events ........................................................................................... 60
Index 63
dLSoft dBarcode.NET Components dBarcode.NET Components 1
dBarcode.NET Components
Introduction
dBarcode.NET Components are managed code components that allows barcode images to be created within the user’s
own .NET application. A barcode image may be displayed on screen or printed on a printer, and the image may be
passed to any other image-handling component. The components are fully serializeable.
Single computer versions of the components are useable only on a single computer. Developer versions permit
applications built with the dBarcode.NET components to be distributed up to a maximum distribution of 10,000 copies.
Developer versions require the developer’s serial number to be passed to the component using the Serial property.
dBarcode.NET Components are designed to work with Visual Studio 2005 and later and require the .NET run-time
(version 2.0 or later) to be installed on any computer using the components. Example code is provided with each
component for users of Visual Basic .NET and C# in Visual Studio 2005 – 2010 targeting the .Net Framework v 2, and
for Visual Studio 2012 targeting the Framework v 4. The target framework in each case may be changed by editing the
project properties.
The 1D components
There are several 1D components in the dBarcode.NET Components family, one for each of the most popular barcode
types, and one which handle a wide range of different barcode types. The 1D components are:
dBarcode.NET Standard Component Abcnet39Lib.dll – for Code 39, Extended Code 39, Code 93, Extended 93, Code 128, Interleaved 2 of 5, and Matrix 2 of
5 barcodes
dBarcode.NET GS1 Component AbcnetEANLib.dll – for Linear Databar (Omnidirectional, Truncated, Limited and Expanded), EAN-13, EAN-14,
EAN-8, GS1-128, ITF-14, SSCC, UPC-A, UPC-E barcodes
dBarcode.NET 1D- Universal Component AbcnetLib.dll – for most common barcode types (over 50 types supported; see the list provided under CodeType).
With the exception of the CodeType property (which specifies the type of barcode to be generated) all components share
the same component properties, and in this manual all components are discussed using the name of the dBarcode.NET
Component. The allowed values for the CodeType property for the individual components is described under Properties
in the 1D Components Reference section.
2 dBarcode.NET Components dLSoft dBarcode.NET Components
The 2D components
There are several 2D components in the dBarcode.NET Components family, one for each of the most popular barcode
types, and one which handle a wide range of different barcode types. The components are:
dBarcode.NET Aztec Component AbcnetAztLib.dll – for Aztec barcodes
dBarcode.NET DataMatrix Component AbcnetDmtLib.dll – for DataMatrix barcodes
dBarcode.NET PDF417 Component AbcnetPdfLib.dll – for PDF417 and Micro PDF barcodes
dBarcode.NET QR Code Component AbcnetQRLib.dll – for QR Code barcodes
dBarcode.NET Databar Component AbcnetRssLib.dll – for Databar (formerly RSS) barcodes, Linear and Stacked.
dBarcode.NET 2D Universal Component Abcnet2dLib.dll – for Aztec, DataMatrix, Maxicode, PDF417, Micro PDF417, QR Code and Databar barcodes.
dBarcode.NET GS1 Composite Component AbcnetcompLib.dll – for ITF-14, SSCC stand-alone symbols and Databar, EAN-13, EAN-8, GS1-128, UPC-A & UPC-
E with or without CC-A, CC-B, CC-C composite codes. See the section entitled “The GS1 Composite Component”
dBarcode.NET Dual Universal component AbcnetDualLib.dll – for all of the 1D, 2D and GS1-Composite symbols listed above.
See the Section entitled “dBarcode.NET Dual Component”.
With the exception of the CodeType property (which specifies the type of barcode to be generated) all 2D components
share the similar component properties, and in this manual all 2D components are discussed using the name of the
dBarcode-PDF417.NET Component, with specific details of properties for other components being described where
appropriate. The allowed values for the CodeType property for the individual components is described under Properties
in the 2D Reference Components section.
Using dBarcode.NET Components in Visual Studio
Adding a dBarcode.NET Component to the ToolBox
To add a dBarcode Component to the Visual Studio ToolBox, display the ToolBox and select the Components tab. Right
click on the Components pane and select Choose Items from the pop-up menu displayed. A dialog box is displayed
listing the currently installed components. Ensure that the .NET Framework Components page is displayed.
Push the Browse button and navigate to the location where you have installed or copied your dBarcode.NET component
and select the DLL (e.g. AbcnetLib.dll).
Then push the Open button.
The list of installed components is now displayed, including your dBarcode.NET component. Ensure that the checkbox
alongside the component name is checked. Now push the OK button.
The component appears as an icon on the ToolBox Components pane, with one of the following class names alongside:
Component .NET name DLL
dLSoft dBarcode.NET Components dBarcode.NET Components 3
1D-Universal Abcnet AbcnetLib.dll
Standard Abcnet39 Abcnet39Lib.dll
GS1 Abcnetean AbcnetEanLib.dll
Aztec Abcnetazt AbcnetAztLib.dll
Databar Abcnetrss AbcnetRssLib.dll
Datamatrix Abcnetdmt AbcnetDmtLib.dll
PDF417 Abcnetpdf AbcnetPdfLib.dll
QR Code Abcnetqr AbcnetQrLib.dll
2D-Universal Abcnet2d Abcnet2dLib.dll
GS1-Composites Abcnetcomp AbcnetCompLib.dll
Dual-Universal AbcnetDual AbcnetDualLib.dll
Adding a dBarcode.NET component to a project.
There are two ways to add a component to your project:
1) Adding the component from the Toolbox
With a project's form open in design mode drag the dBarcode.NET component icon from the toolbox onto the form.
The component icon appears on the panel below the form – it does NOT appear on the form itself. The instance of the
component will be given a default name (eg Abcnet1) which appears in the properties panel when the component is
selected. A single Form may contain any number of dBarcode.NET Components. The first to be added will be called
Abcnet1, the second Abcnet2, and so on; the names may be changed by the user by modifying the Name property within
the Properties box.
The properties panel also displays all other settable properties for the component, and these values will be used as
defaults unless properties are changed programmatically within your project.
This method is used if the component is associated with a form.
2) Adding the component directly to the project files
Copy the component DLL to the directory containing you project source files. In the Solution Explorer add the DLL to
the project file list. Then in source file that uses the component declare an instance of the component. For example, in a
Windows Form project declare an instance of the component in the Public Class Form1 source file with
Dim Abcnet1 As New AbcnetLib.Abcnet() ‘ in VB
Or
private AbcnetLib.Abcnet abcnet1=new AbcnetLib.Abcnet(); // in C#
This method is suitable if you do not need to have the component associated with a form.
4 dBarcode.NET Components dLSoft dBarcode.NET Components
Setting the initial properties in a WinForms project
When a component has been added to a form the initial properties of the barcode component may be set at design time in
any of four ways:
1. Selecting the component icon below the form and double clicking on it;
2. Right-clicking on the component icon and choosing “Show barcode properties dialog” from the pop-up menu;
3. Selecting “Show barcode properties dialog” at the base of the properties window in Visual Studio.
In each case the Barcode properties dialog is displayed and values may be set.
Setting and retrieving property values programmatically
The dBarcode.NET Components may be operated entirely by setting or retrieving Property values programmatically.
Clicking on the dBarcode Component icon under the form when Visual Studio's Properties box is displayed will show
the current settings for component's available properties. Most of these properties may have their values set from within
the user's program by statements of the kind
dLSoft dBarcode.NET Components dBarcode.NET Components 5
Abcnet1.Caption="12345" Visual Basic
Abcnet1.Caption="1234"; C#
dBarcode Component properties that are set AFTER a barcode has been created may be retrieved within user's
programs by statements of the kind:
x=Abcnet1.Error Visual Basic
x=Abcnet1.Error; C#
Setting properties through the Barcode properties dialog box
Using the method AbcProperties() within your program causes the Barcode properties dialog to be displayed. This
displays all settable properties in a convenient form and enables run-time changes to be made by selecting from drop-
down lists or entering values into edit boxes, or summoning standard Windows dialogs for the selection of colors or
fonts.
1D Component Properties dialog
6 dBarcode.NET Components dLSoft dBarcode.NET Components
2D Component Properties dialog
Displaying a barcode on a form
To display a barcode on a form a PictureBox is used to hold the image.
Place a PictureBox Windows Forms control on the form and add some code to your program to take the barcode image
from the dBarcode.NET component and use it as the Image for the PictureBox
For example:
private void DoBarcode() Visual Basic
{
Dim g As Graphics = PictureBox1.CreateGraphics()
Abcnet1.Caption="1234"
PictureBox1.Image=Abcnet1.Barcode(g)
g.Dispose()
}
private void DoBarcode() C#
{
Graphics g=pictureBox1.CreateGraphics();
abcnet391.Caption="1234";
pictureBox1.Image=abcnet391.Barcode(g);
g.Dispose();
dLSoft dBarcode.NET Components dBarcode.NET Components 7
}
Printing a barcode image
Printing the image returned by the Barcode() call may be accomplished by any of the printing techniques available for
Visual Studio project. However, probably the most useful approach is to use the DrawImage() method in a PrintPage
handler as illustrated below, and in the examples provided with the components:
Visual Basic
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.PageUnit = GraphicsUnit.Document '
e.Graphics.DrawImage(Abcnet1.Barcode(e.Graphics), 300.0F, 300.0F)
e.HasMorePages = False
End Sub
C#
private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.PageUnit = GraphicsUnit.Document;
e.Graphics.DrawImage(abcnet1.Barcode(e.Graphics), 500F,500F);
e.HasMorePages = false;
}
While the PageUnit setting can be any of the allowed values, we have found that the most accurately sized barcodes are
produced when the highest resolution setting (Document, equivalent to 300 units per inch) is used.
Saving a barcode image
Barcode images should NOT be saved by attempting to save the image directly from a PictureBox. This will result in the
image being saved with screen resolution – which is rarely suitable for barcodes.
To save an image for subsequent printing the developer should use sBarcode(hDpi,vDpi,filename) – in which case hDpi
and vDpi are the target horizontal and vertical resolutions of the target printer and filename is the full pathname of the
file to be created.
For example, to save an image for printing on a 600 dpi printer:
Private Sub saveBarcode(string graphicfilename)
Dim filename As String = “C:\fread.png”
Dim I,hres,vres As Integer
Abcnet1.Caption = Data.Text
hres = 600
vres = 600
Abcnet1.sBarcode(i, i, filename)
8 dBarcode.NET Components dLSoft dBarcode.NET Components
End Sub
Note that when printing images saved in this way the printer’s PageUnit should be set to GraphicsUnit.Pixel, or the
image size scaled appropriately.
Images may be saved in BMP, EPS, GIF, JPG, PNG, TIF or WMF formats.
Licensing the component dBarcode.NET components will behave as Testware versions (generating deface barcode and truncated pattern strings)
unless correctly licensed.
Single computer versions of the components are licensed for use only on a single computer. Developer versions permit
applications built with the dBarcode.NET components to be distributed up to a maximum distribution of 10,000 copies.
Developer versions require the developer’s serial number to be passed to the component using the Serial property before
the Barcode() method is called. The Serial property should be set to the serial number provided for your product, e.g.
Abcnet1.SerialNo="12345" for VB
abcnet1.SerialNo="12345"; for C#
Single computer version should NOT use the Serial property.
dLSoft dBarcode.NET Components dBarcode.NET Components 9
1D Components Reference
Summary of Properties and Methods
dBarcode.NET Component properties fall into two categories - those that are required to specify characteristics of the
barcode image, and those that provide information about the barcode.
The most important properties and methods are outlined below, and followed by sections in which the properties and
methods are defined in detail.
Component properties.
The properties that can be set to generate an image
Abcnet1.AutoCheckdigit specifies whether any check digits are calculated automatically
Abcnet1.BackColor the colour behind the bars
Abcnet1.BarRatio specifies the ratio of wide/narrow bar for some barcode types
Abcnet1.BarcodeHeight required target height of barcode image (in units determined by the setting of the Unit
property)
Abcnet1.BarcodeWidth required target width of barcode image (in units determined by the setting of the Unit
property)
Abcnet1.BearerSize specifies the thickness of bearer bars for those barcodes that may have bearer bars
Abcnet1.BorderWidth specifies the thickness of any border around the image
Abcnet1.BothBearers determines whether both upper and lower bearer bars are displayed
Abcnet1.Caption specifies the characters that make up the code
Abcnet1.CodeType specifies the barcode type required
Abcnet1.ExtendBearers Allows bearer bars to extend into light margins.
Abcnet1.ForeColor the colour of the bars and any text under the bars
Abcnet1.Font The font used to render any text under the barcode
Abcnet1.Indicators specifies whether light margin indicators should be displayed for those barcode types that support
these. Not that the prefix and suffix digits of UPC barcodes and the prefix digit of EAN-13 and EAN-8 barcodes are
regarded as light margin indicators for this purpose.
Abcnet1.MarginSize specifies the size of the light margins
Abcnet1.Orientation specifies the orientation angle of the barcode image
Abcnet1.Mirror specifies that a mirror image of the symbol is created
Abcnet1. Reduction specifies the percentage reduction in bar thickness (useful for allowing for ink spread in wet-
ink printing processes.
Abcnet1.ShowText specifies that the text content of the barcode should be displayed under the bars
Axbarcode.ShowCheckdigit specifies whether any automatic check digit is displayed (for those barcode type which
permit this)
Abcnet1.TextAlign specifies the text justification for human readable text under the barcode
Abcnet1.Xunit specifies the thickness of each barcode element in mils (1/1000 inches)
10 dBarcode.NET Components dLSoft dBarcode.NET Components
Many of these properties have default values (see the reference section), so do not require changing if you can make do
with the default values. The properties that must be set for you to obtain a barcode are
Abcnet1.CodeType specifies the barcode type required
Abcnet1.Caption specifies the characters that make up the code
A typical example of setting these properties is:
Abcnet1.CodeType=Code_39
Abcnet1.Caption="123456"
The following Information properties are available after calls to the Barcode() method.
Abcnet1.Error an error code which is non zero if an error has occurred in generating the barcode image.
Abcnet1.ImageHeight the height of barcode picture generated (in units determined by the setting of the PageUnit
property of the Graphics object passed into the component)
Abcnet1.ImageWidth the width of barcode picture generated (in units determined by the setting of the PageUnit
property of the Graphics object passed into the component)
Abcnet1.Pattern a pattern string containing 1s and 0s representing the bars and spaces respectively for the barcode
symbol (see Pattern details for clocked code variants).
Abcnet1.Status a string interpreting the error code produced when generating the barcode image.
Abcnet1.String2 the barcode content in text form (including any automatically calculated check digit).
Component methods
Abcnetxx(SerializationInfo info, StreamingContext context) for creating an instance of the component using
BinaryFormatter.Deserialize() method.
Barcode(Graphics g) causes a barcode image to be created using the Graphics properties of g
cBarcode(Graphics g, int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on
a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
doBarcode() checks that a barcode can be created using the current property settings, returning 0 if the current settings
are valid, or an error code. This method also fills the Pattern string for valid barcodes.
GetObjectData(SerializationInfo info, StreamingContext context) for serializing the component using the
BinaryFormatter.Serialize() method.
Properties() Displays the Barcode properties dialog for the component.
sBarcode(Graphics g, int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
Required properties
The following properties are required - although all are provided with default values.
dLSoft dBarcode.NET Components dBarcode.NET Components 11
AutoCheckdigit
Type: BOOL
Default: FALSE
Allowed values: FALSE (check digit characters not calculated)
TRUE (check digit characters calculated and appended to code for appropriate code types)
This property is ignored for Code 128, GS1-128, Planet and Postnet codes where the check digit is mandatory and not
available in human readable form.
BackColor
Type: Color
Default: Color.White
Allowed values: any allowed Color value.
Sets the colour of the image background.
BarcodeHeight
Type: float
Default: 16.0 mm
Sets the required target height of barcode image (in units determined by the setting of the Unit property)
BarcodeWidth
Type: float
Default: 30.0 mm
Sets the required target width of barcode image (in units determined by the setting of the Unit property).
Note: this value is ignored if a non-zero value is provided from the Xunit property.
BarRatio
Type: float
Default 2.5
Allowed values: 2.0 – 3.0
This setting allows some barcode types to have the Wide bar/Narrow bar ratio modified.
Applies mainly to Code 39 and Interleaved 2 of 5 barcodes.
BearerSize
Type: float
Default: 0
Allowed values: 0 - 10000
Allows the thickness of bearer bars for those barcodes which support bearers to be set (in units determined by the setting
of the PageUnit property of the Graphics object passed into the component).
12 dBarcode.NET Components dLSoft dBarcode.NET Components
Note that for most barcode types the number of bearer bars displayed depends on the setting of the BothBearers property.
If BothBearers is True the bars are displayed above and below the barcode. If BothBearers is False then only a single
bearer bar is displayed above the barcode.
BorderWidth
Type: float
Default: 0.0 (no border)
Allowed values: any
Specifies the size (in units determined by the setting of the PageUnit property of the Graphics object passed into the
component) of a border placed around the barcode. The border area is created using the background color set by the
BackColor property.
BothBearers
Type: BOOL
Default: FALSE
Allowed values: TRUE or FALSE
When TRUE causes bearer bars to be draw above and below the barcode. When FALSE no bearer bars are drawn if the
BearerSize property is zero. Otherwise a FALSE setting causing only a single bearer bar to be displayed above the
barcode.
Caption
Type: string
Default: "12345"
Allowed values: Any text string.
Note: only text strings recognised as valid barcodes will result in a barcode picture. An Illegal character in the text string
will cause an Error value to be set.
CodeType
Type: bCode enumeration member
For dBarcode.NET Component Universal
Default: Code_39 (GS1_128 for the GS1 component)
Allowed values: The ranges of values defined for the individual components are shown in the barcode type tables
below.
The barcode type can be set using either the CodeType property or the CodeTypeValue property
CodeTypeValue
Type: integer
Default: 0 (7 for the GS1 component)
Allowed values: The ranges of values defined for the individual components are shown in the barcode type tables
below.
The barcode type can be set using either the CodeType property or the CodeTypeValue property
For dBarcode.NET Universal
dLSoft dBarcode.NET Components dBarcode.NET Components 13
Barcode CodeType CodeTypeValue
Code 39 Code_39 0
Extended Code 39 Extended_39 1
Codabar Codabar 2
2 of 5 Standard_2_of_5 3
Interleaved 2 of 5 Interleaved_2_of_5 4
Matrix 2 of 5 Matrix_2_of_5 5
Code 93 Code_93 6
Extended Code 93 Extended_93 7
Code 128 Code_128 8
GS1-128 EAN_128 9
SSCC SSCC 10
EAN 14 EAN_14 11
EAN 13 EAN_13 12
EAN 13 + 2 digits EAN_13_plus_2 13
EAN 13 + 5 digits EAN_13_plus_5 14
EAN 8 EAN_8 15
EAN 8 + 2 digits EAN_8_plus_2 16
EAN 8 + 5 digits EAN_8_plus_5 17
UPC-A UPC_A 18
UPC-A + 2 digits UPC_A_plus_2 19
UPC-A + 5 digits UPC_A_plus_5 20
UPC-E UPC_E 21
MSI/Plessey MSI_Plessey 22
Plessey Plessey 23
DeutschenPost DeutschePost 24
PostNet PostNet 25
Planet 12 Planet_12 26
Planet 14 Planet_14 27
Royal Mail RM4SCC 28
4-State FourState 29
ISBN ISBN 30
ISSN ISSN 31
ISMN ISMN 32
TelePen Standard Telepen 33
TelePen ASCII TelePenA 34
TelePen Numeric TelepenN 35
Japan Postal code JapanPost 36
Code 11 Code_11 37
Code B Code_B 38
ITF-6 ITF_6 39
ITF-14 ITF_14 40
IATA 2 of 5 IATA_2_of_5 41
China Postal Code China_Post 42
OneCode ONE_Code 43
Code 128 Subtype A Code_128A 44
Code 128 Subtype B Code_128B 45
UPC E0 UPC_E0 46
UPC E1 UPC_E1 47
Korean Postal Authority KoreanPA 48
Italian Postal 2/5 ItaliaP25 49
Italian Postal 3/9 ItaliaP39 50
Australia Post AUS 51
14 dBarcode.NET Components dLSoft dBarcode.NET Components
InfoMail Barcode A InfoMail_A 52
PZN PZN 53
Databar Omnidirectional Databar_Omni 54
Databar Truncated Databar_Trunc 55
Databar Limited Databar_Lim 56
Databar Expanded Databar_Exp 57
HIBC LIC Code 128 HIBC_128 58
HIBC LIC Code 39 HIBC_39 59
IMTM Package Barcode IM_Package_Barcode 60
For dBarcode.NET Standard
Barcode CodeType CodeTypeValue
Code 39 Code_39 0
Extended Code 39 Extended_39 1
Code 93 Code_93 2
Extended Code 93 Extended_93 3
Code 128 Code_128 4
Code 128 Type A Code_128_A 5
Code 128 Type B Code_128_B 6
Interleaved 2 of 5 Interleaved_2_of_5 7
Matrix 2 of 5 Matrix_2_of_5 8
For dBarcode.NET GS1
Barcode CodeType CodeTypeValue
EAN 13 EAN_13 0
EAN 13 + 2 digits EAN_13_plus_2 1
EAN 13 + 5 digits EAN_13_plus_5 2
EAN 14 EAN_14 3
EAN 8 EAN_8 4
EAN 8 + 2 digits EAN_8_plus_2 5
EAN 8 + 5 digits EAN_8_plus_5 6
GS1-128 GS1_128 7
ITF-14 ITF_14 8
SSCC SSCC 9
UPC-A UPC_A 10
UPC-A + 2 digits UPC_A_plus_2 11
UPC-A + 5 digits UPC_A_plus_5 12
UPC-E UPC_E 13
UPC-E0 UPC_E0 14
UPC-E1 UPC_E1 15
Databar
Omnidirectional
Databar_Omni 16
Databar Truncated Databar_Trunc 17
Databar Limited Databar_Lim 18
Databar Expanded Databar_Exp 19
dLSoft dBarcode.NET Components dBarcode.NET Components 15
Controls
Type: String
Default: “ÅÆÇÈÉÊËÌÍÎÏД
Encoding schemes based on Code 128 may include control characters, such as fnc1. These may be inserted by the user
into barcode data and are handled in specific ways during the encoding process. (Each character may be created on a
western keyboard by holding down the Alt key and type 0xyz on the numeric keypad, where xyz is one of the three digit
codes listed below. The table also shows the function initiated by each character while in each of the Code 128 modes.)
xyz character Code A Code B Code C
197 Å DEL
198 Æ func. 3 func. 3
199 Ç func. 2 func. 2
200 È shift shift
201 É code C code C
202 Ê code B func. 4 code B
203 Ë func. 4 code A code A
204 Ì func. 1 func. 1 func. 1
205 Í Start A Start A Start A
206 Î Start B Start B Start B
207 Ï Start C Start C Start C
208 Ð NUL
The Controls property is a string containing the 12 allowed control codes. The programmer has the option to change any
or all of these characters for alternative characters by setting the Control property to another string of 12 characters.
The facility to specify control codes is particularly useful for schemes such as GS1-128 where the func 1 character is
essential for terminating variable length AIs.
EPScorrection
Type Integer
Default: 1
When vector EPS images are created bars may be rendered one device pixel wider and taller than required – making
black rectangles larger than white rectangles. dBarcode.NET components will reduce the width and height of bars by and
amount equal to
EPScorrection * pixel size of target device
The pixel size of the target device is determined from the hDpi and vDpi values provided in the call that generates an
EPS image (eg. sBarcode()).
If this correction is not required the value of EPScorrection may be set to 0.
EPSpreview
Type Integer
16 dBarcode.NET Components dLSoft dBarcode.NET Components
Default: 0
When set to 1 this property causes a low resolution bitmap preview to be incorporated into any EPS files/streams. When
0 no preview image is created.
ExtendBearers
Type: BOOL
Default: FALSE
When TRUE allows bearer bars to extend into light margins. When FALSE bearer bars cover the bars only.
Extra1
Type: BOOL
Default FALSE
These additional properties are not normally used. However, they do provide additional functions for a limited number of
specific barcode types. See Barcodes section for details.
Extra2
Type: BOOL
Default FALSE
These additional properties are not normally used. However, they do provide additional functions for a limited number of
specific barcode types. See Barcodes section for details.
Font
Type: FONT
Default: Arial 10 point
Allowed values: Any accessible TrueType font.
ForeColor
Type: Color
Default: Color.Black
Allowed values: any valid Color
Sets the colour of the image foreground, i.e. the bars and text colour.
Indicators
Type: BOOL
Default: FALSE
A value of TRUE causes the light margin indicators to be displayed. For some EAN barcodes there are recommended
ways for the margin indicators to be shown on the image, and the Prefix code and checkdigit for UPC-A and UPC-E
codetype to be displayed in the light margins. A value of FALSE prevents the display of the light margin indicators.
dLSoft dBarcode.NET Components dBarcode.NET Components 17
MarginSize
Type: FLOAT
Default: 0.0
Allowed values: any
The MarginSize property sets the Light Margin space on either side of a barcode image. The units are the units specified
by the current ScaleMode. (in units determined by the setting of the PageUnit property of the Graphics object passed into
the component)
Mirror
Type: BOOL
Default: False
A value of True will cause the barcode image to be created as a mirror image. This facility is designed for use with
printing technologies that require a mirror image. Mirror image barcodes may not be scannable unless printed correctly.
Orientation
Type: integer
Default: 0 The value of this parameter determines the orientation of the barcode image created.
Allowed values: 0 - 360 degrees
Note that the rotation of text is only supported by TrueType and other rotatable fonts. Note also that some applications
do not correctly handle metafiles that contain rotated text.
Reduction
Type: float
Default: 0 the thickness of each line drawn on the barcode image is reduced by this percentage amount. This
property may be used to compensate for ink spreading during wet-ink printing.
Allowed values: 0 - 50 (%)
A positive reduces the thickness of bars by the calculated amount of the thinnest bar. A negative value reduces the
thickness of bars by the percentage applied to the bar thickness (so a bar three units wide is reduced by an absolute
amount that is three times greater than that which would apply to a one unit bar)
ShowCheckdigit
Type: BOOL
Default: FALSE
When set to TRUE this property causes the any automatically calculated check digit to be included in the any text
displayed along with the barcode. When set to FALSE the check digit is not displayed.
Note that this property has no effect on those codetypes for which the checkdigit display is mandatory (including EAN
and UPC codes), or for which the check digit is never displayed (Code 128 and GS1-128).
18 dBarcode.NET Components dLSoft dBarcode.NET Components
ShowText
Type: BOOL
Default: TRUE
When FALSE text version of the code is NOT included in the barcode image. When TRUE text version of the code IS
included in the barcode image.
This property is ignored for clocked codes which have no text version.
TextAlign
Type: StringAlignment
Default: Center
Allowed values: Near, Center, Far
TextAlign sets the alignment of any text displayed under the barcode. A value of Center centers the text, Near gives left
justification and Far gives right justification. Justification is to the edge of the barcode – NOT the edge of the light
margins.
Unit
Type GraphicsUnit
Default: Millimeter
The scaling mode applied to values of the following size-related properties:
BarcodeHeight
BarcodeWidth
BearerSize
BorderWidth
MarginSize
Allowed values:
Document
Display
Pixel
Point
Millimeter
Inch
Xunit
Type: float
Default: 0.0
Allowed range: 8.0 – 255.0
The Xunit property may be used to specify the width (in Mils) of the smallest element in the barcode.
Note that setting this property to a value other than 0 causes the image to resize itself to a width calculated from the
number of X units in the barcodes – so the value of the BarcodeWidth property is ignored.
Using values smaller than 8 will produce a barcode image, but that image will not meet standard specifications and may
not scan.
dLSoft dBarcode.NET Components dBarcode.NET Components 19
Information properties
Note that the barcode symbol is determined only when this Barcode() method is called, so the information properties are
not available until this method has been called.
Error
Type: integer
Returns a value representing the error code if a valid barcode image cannot be created. Otherwise returns 0.
Read only. Do not set this property.
The error codes and corresponding Status property values are shown below:
Status
Type: string
Returns a string interpreting the value of the Error property.
The error codes and corresponding Status property values are shown below:
Error Status
0 OK
1 Illegal character in data
2 Wrong data length
3 Error in barcode data
9 Graphics drawing error
Read only. Do not set this property.
ImageHeight
Type: FLOAT
Return the actual height of the image generated, in units of the current Graphics object – NOT the units specified by the
Unit property.
The value returned includes the size of any border, margin and text.
Read only. Do not set this property.
ImageWidth
Type: FLOAT
Return the actual width of the image generated, in units of the current Graphics object – NOT the units specified by the
Unit property.
The value returned includes the size of any border, margin and text.
Read only. Do not set this property.
20 dBarcode.NET Components dLSoft dBarcode.NET Components
Pattern
Type: String
Returns: A string containing a pattern of 0s and 1s, where 0 represents a space of minimum width and a 1
represents a bar of minimum width. The 1s may be used to indicate that a bar (filled rectangle) must be drawn.
Read only. Do not set this property.
String2
Type: string
Returns the Caption property plus any additional characters generated as check digits.
Read only. Do not set this property.
Methods
Barcode(Graphics g) Return Type: Metafile
This method causes a barcode image to be created using the Graphics properties of g (including the PageUnit property
which determines that absolute size information embedded in the image).
Barcode(Graphics g, bool bPixelAlign): This method is redundant now that the above methods return vector metafiles. It
is included only for backward compatibility
Barcode(Graphics g, bool bPixelAlign, int Xres, Yres) is similar, except that the image is scaled to the values required by
the target device reolutions Xres and Yres if these are non-zero, rather than the resolution of the Graphics g.
Barcode(Graphics g, float fScale, bool bPixelAlign, int Xres, int Yres int iUseMetaProps): This method is redundant
now that the above methods return vector metafiles. It is included only for backward compatibility
Note that the barcode symbol is determined only when one of these methods is called, so the ImageHeight and
ImageWidth properties are not available until one of these methods has been called.
cBarcode()
Return Type: Integer
cBarcode(int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on a device
with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
cBarcode(Graphics g, int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on
a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively using the properties of
Graphics g.
This method is useful for generating an image that is to be copied to another application for later printing, e.g. for
copying an image that will be subsequently pasted into Word and printed on a 600 dpi printer:
Abcnet1.cBarcode(g,600,600)
If hDpi and vDpi are zero the properties of the Graphics g will be used.
Returns 0 if successful, or an error code if the barcode cannot be created, or -1 if the clipboard is not available.
doBarcode()
dLSoft dBarcode.NET Components dBarcode.NET Components 21
Return Type: int
This method may be used to check that a barcode can be created using the current property settings, returning 0 if the
current settings are valid, or an error code (see the Error property), along with setting the Status property. This method
also fills the Pattern and String2 properties for valid barcodes. It does not create a barcode image.
This method is called when Barcode(g) is called.
Properties() Return Type: BOOL
Displays the Barcode properties dialog for the component.
Returns TRUE if the user exits the dialog by pushing the OK button and sets all component properties to those specified
in the dialog.
Returns FALSE if the user exits the dialog by pushing the Cancel button.
sBarcode()
sBarcode(int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with horizontal and
vertical resolutions of hDpi and vDpi dots per inch respectively.
Return Type: Metafile
sBarcode(Graphics g, int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively using the properties of Graphics g. If
hDpi and vDpi are zero the properties of the Graphics g will be used.
22 dBarcode.NET Components dLSoft dBarcode.NET Components
Return Type: Metafile
sBarcode(int hDpi, int vDpi, ImageFormat im) generates an memory stream image with the format specified by
im, scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch
respectively and with the bars pixel aligned. If ImageFormat im is null or ImageFormat.Icon a vector EPS stream is
returned.
sBarcode(int hDpi, int vDpi, ImageFormat im, int iPixAlign) If iPixAlign is 1 and the image format specifies a bitmap
format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 does the bitmap is created without
pixel alignment. If ImageFormat im is null or ImageFormat.Icon a vector EPS stream is returned – and iPixAlign is
ignored..
Return Type: MemoryStream. Returns a MemoryStream of Length 0 if an error occurs.
sBarcode(int hDpi, int vDpi, string filename) saves an image into the file specified by filename with the format
specified by filename extension, scaled to be suitable for printing on a device with horizontal and vertical resolutions of
hDpi and vDpi dots per inch respectively and with the bars pixel aligned.
Images may be saved in BMP, EPS, GIF, JPG, PNG, TIF or WMF formats.
sBarcode(int hDpi, int vDpi, string filename, int iPixAlign) If iPixAlign is 1 and the graphics file name specifies a
bitmap format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 the bitmap is created without
pixel alignment.
Return Type: Int. Returns 0 if successful or 1 if an error occurs.
Note that the vector formats EPS and WMF produce images that are not dependent on the hDpi and vDpi resolutions.
These methods are useful for generating an image that is to be saved for later printing, e.g. for saving an image that will
be subsequently printed on a 600 dpi printer:
Filename=”c:\fred.png”
Abcnet1.sBarcode(600,600, filename)
Saves the file as a PNG graphic and the following print handler prints the image
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim newImage As Image = Image.FromFile(filename)
Dim r As Rectangle
r.X = 600
r.Y = 600
r.Width = newImage.Width
r.Height = newImage.Height
e.Graphics.PageUnit = GraphicsUnit.Pixel '
e.Graphics.DrawImage(newImage, r)
' Indicate that this is the last page to print.
e.HasMorePages = False
End Sub
When creating EPS images the EPScorrection property may be used to correct the bar size produced by PostScript
engines that render rectangles 1 pixel wider than required.
The MemoryStream method is designed primarily for use with ASP.NET (see below)
sBarcode1()
sBarcode1(int hDpi, int vDpi, string filename) saves a monochrome ( 1 bit per pixel) image into the file specified
by filename with the format specified by filename extension, scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively and with the bars pixel aligned.
dLSoft dBarcode.NET Components dBarcode.NET Components 23
This method operates only for BMP, PNG and TIF files and the filename provided must have one of those extensions.
Return Type: Int. Returns 0 if successful or 1 if an error occurs.
sBarcode1(int hDpi, int vDpi, ImageFormat im) generates a monochrome (1 bit per pixel) memory stream image
with the format specified by im, scaled to be suitable for printing on a device with horizontal and vertical resolutions of
hDpi and vDpi dots per inch respectively and with the bars pixel aligned.
This method operates only for BMP, PNG and TIF formats and the image format provided must be one of
ImageFormat.Bmp, ImageFormat.Png or ImageFormat.Tif.
Return Type: MemoryStream. Returns a MemoryStream of Length 0 if an error occurs.
SetParam()
The SetParam method allows a named property to be set to a specific data value using the format:
SetParam(“Xunit”,”16”)
where both the property name and the data are passed as strings. This approach is useful for creating servlets within IIS
that can return a barcode image to a remote application (such as Crystal Reports). A simple servlet example is included
within the distribution.
The property names used in SetParam are, with a few exceptions, the same as the component properties names described
earlier. The following exceptions should be noted:
The barcode data string is passed using the name “Data” and not Caption.
The barcode code type is passed using the name “CodeType” but the data value must be one of the number strings listed
under CodeTypeValue (eg. “0”).
The Unit data string is passed using the name “Units”, but the data values can be only “IN” (for inches) or “MM” (for
millimetres).
If details of a font are to be passed this must be done using the parameter names “FontName”, “FontSize”, “FontBold”,
and “FontItalic”.
If the TextAlign property is used the allowed values are “0” (centred), “1” (near alignment), and “2” (far alignment).
A property name “Resolution” may be passed to specify the resolution (in pixels per inch) of the barcode image that will
subsequently be returned using the Pic() method.
Where a property requires a Boolean value for data, “0” is interpreted as false, any other value is interpreted as true.
The method type is void; there is no returned value.
The use of SetParam() and Pic() is discussed in the ASP.NET section.
Pic()
The Pic() method returns a memory stream containing a graphics image. The image type is determined using two
parameters:
Ms=m_barcode.Pic(imType as String, colType as Integer)
Where imType may be one of “bmp”, “eps”, “gif”, “jpg”, “png”, “tif” or “wmf” to specify the graphics format, and
colType may be 0 (for normal 24 bbp images) or 1 (for monochrome 1 bpp images).
Note that monochrome images may be generated only for bmp, png and tif images.
The Pic() method if provided only for convenience in creating servlets and is not recommended for other purposes.
The use of SetParam() and Pic() is discussed in the ASP.NET section.
24 dBarcode.NET Components dLSoft dBarcode.NET Components
ASP.NET There are many possible approaches to generating barcode images for ASP.NET pages, while avoiding the limitations of
the display resolution. One method, suitable for use when the barcode is to be data-dependent, is to use two aspx files,
one which creates the a moderate resolution memorystream barcode image and calls the second file as the SRC for and
IMG tag to display the page at the correct size, eg
<script language="vb" runat="server">
sub Page_Load(Sender As Object, E As EventArgs)
…………………..
m_barcode.Unit = GraphicsUnit.Pixel
m_barcode.XUnit = 0
m_barcode.Font=m_Font
m_barcode.Orientation=0
m_barcode.AutoCheckdigit=TRUE
m_barcode.BarcodeHeight = ht
m_barcode.BarcodeWidth = wd
m_barcode.CodeTypeValue = 8
m_barcode.caption = Session("xx")
Session("ms")=m_barcode.sBarcode(300,300,System.Drawing.Imaging.ImageFormat.Png)
if Session("ms").Length>0 then
Session("ht")=m_barcode.ImageHeight
Session("wd")=m_barcode.ImageWidth
end if
</script>
</head>
<BODY>
<H1>dLSoft dBarcode.NET - on ASP.NET</H1>
<IMG SRC="page2.aspx" HEIGHT=" <% =Session("ht") %> " WIDTH=" <% =Session("wd") %> ">
<p> dBarcode.NET components can generate barcode images in BMP, GIF, PNG, JPG, TIF and WMF formats, and for
more than 50 barcode types.
</BODY>
</HTML>
The Session variables ht and wd contain the actual sizes at which the image is to be drawn on the web page. These are
calculated when the page is loaded and used when the IMG SRC calls the second page.
The second file (page2.aspx) serves up the image at the correct size, eg.
<%@ LANGUAGE="VB"%>
<%
Response.ContentType="image/png"
Response.BinaryWrite(Session("ms").GetBuffer())
%>
A working sample is included with component distribution.
dLSoft dBarcode.NET Components dBarcode.NET Components 25
Servlets
The method described above is the preferred method of generating barcode images in ASP.NET, but it can be more
convenient in some cases to use a servlet that returns an image in response to a single HTTP GET call.
The SetParam() and Pic() methods are available within the dBarcode.NET components to facilitate this approach. The
following ASP.NET file (barcode.aspx) illustrates this:
<%@ Page Language="VB" aspcompat=true %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Web" %>
<%@ import Namespace="System.Web.SessionState" %>
<script language="vb" runat="server">
sub Page_Load(Sender As Object, E As EventArgs)
Dim loop1, loop2,res As Integer
Dim values as ArrayList= new ArrayList()
Dim coll As NameValueCollection
Dim arr1(), arr2() As String
Dim m_barcode = New AbcnetLib.Abcnet()
'm_barcode.SerialNo="12345"
coll=Request.QueryString
arr1 = coll.AllKeys
if Not IsPostBack Then
'These are the default values for the barcode parameters
'and may be changed if required
Dim m_Font As New Font("Arial", 10, FontStyle.Regular)
m_barcode.Font=m_font
m_barcode.DefResolution=96
m_barcode.CodeTypeValue = 9 ' code 128
m_barcode.Unit = GraphicsUnit.Millimeter
m_barcode.XUnit = 0
m_barcode.BarcodeHeight = 16
m_barcode.BarcodeWidth = 30
m_barcode.Indicators=FALSE
For loop1 = 0 To arr1.GetUpperBound(0)
arr2 = coll.GetValues(loop1)
m_barcode.setParam(arr1(loop1),arr2(0))
next loop1
Session("ms")=m_barcode.Pic("png",0)
end if
try
Response.ContentType="image/x-Png"
Response.BinaryWrite(Session("ms").GetBuffer())
catch
end try
26 dBarcode.NET Components dLSoft dBarcode.NET Components
end sub
</script>
This file may be called from an application or a web page using a link of the form:
http:// server/barcode.aspx?CodeType=9&Unit=in&BarcodeHeight=0.5&Xunit=12 &Data=1234567890
and the call returns the memory stream barcode image.
Note that properties that are likely to remain constant for many barcodes are best set in the body of the servlet, leaving
only those properties that will change to be passed in the http call. The values passed in the http call overwrite those set
in the servlet body.
dLSoft dBarcode.NET Components dBarcode.NET Components 27
2D Components Reference
dBarcode.NET 2D Component Properties
Summary of Properties and Methods
dBarcode.NET 2D Component properties fall into two categories - those that are required to specify characteristics of the
barcode image, and those that provide information about the barcode.
The most important properties and methods are outlined below, and followed by sections in which the properties and
methods are defined in detail.
Component properties.
The properties that can be set to generate an image
Abcnet1.BackColor the colour behind the bars
Abcnet1.BarRatio specifies the ratio of wide/narrow bar for some barcode types
Abcnet1.BorderWidth specifies the thickness of any border around the image
Abcnet1.Caption specifies the characters that make up the code
Abcnet1.CodeType specifies the barcode type required
Abcnet1.ForeColor the colour of the bars and any text under the bars
Abcnet1.Orientation specifies the orientation angle of the barcode image
Abcnet1. Reduction specifies the percentage reduction in bar thickness (useful for allowing for ink spread in wet-
ink printing processes.
Abcnet1.StartMode the starting mode for the 2D barcode
Abcnet1.Xunit specifies the thickness of each barcode element in mils (1/1000 inches)
Some barcode types have the following additional properties:
Abcnet1.Columns the target number of columns for Datamatrix, PDF417 or Databar symbols
Abcnet1.SecurityLevel the security or level of the barcode (generally related the the fraction of the barcode devoted
to error correction elements
Abcnet1.Ymultiplier the height of a barcode element specified in Xunits
Many of these properties have default values (see the reference section), so do not require changing if you can make do
with the default values. The properties that must be set for you to obtain a barcode are
Abcnet1.CodeType specifies the barcode type required
Abcnet1.Caption specifies the characters that make up the code
A typical example of setting these properties is:
Abcnet1.CodeType=PDF417
Abcnet1.Caption="1234567890"
28 dBarcode.NET Components dLSoft dBarcode.NET Components
The following Information properties are available after calls to the Barcode() method.
Abcnet1.Error an error code which is non zero if an error has occurred in generating the barcode image.
Abcnet1.ImageHeight the height of barcode picture generated (in units determined by the setting of the PageUnit
property of the Graphics object passed into the component)
Abcnet1.ImageWidth the width of barcode picture generated (in units determined by the setting of the PageUnit
property of the Graphics object passed into the component)
Abcnet1.Pattern a pattern string containing 1s and 0s representing the bars and spaces respectively for the barcode
symbol (see Pattern details for clocked code variants).
Abcnet1.Status a string interpretting the error code produced when generating the barcode image.
Component methods
Abcnetxx(SerializationInfo info, StreamingContext context) for creating an instance of the component using
BinaryFormatter.Deserialize() method.
Barcode(Graphics g) causes a barcode image to be created using the Graphics properties of g
cBarcode(Graphics g, int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on
a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
doBarcode() checks that a barcode can be created using the current property settings, returning 0 if the current settings
are valid, or an error code.
GetObjectData(SerializationInfo info, StreamingContext context) for serializing the component using the
BinaryFormatter.Serialize() method.
Properties() Displays the Barcode properties dialog for the component.
sBarcode(Graphics g, int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
Required properties
The following properties are required - although all are provided with default values.
AspectFlag
Type: int
Default: 0
Allowed values 0,1
Determines the interpretation of the Columns property for PDF417 barcode symbols. A value of 1 inteprets the Columns
number as the number of Rows required in the symbol.
AzFlag
Type: bool
Default: false
dLSoft dBarcode.NET Components dBarcode.NET Components 29
dBarcode.NET Aztec and 2D Universal only. Sets the Aztec flag on or off.
AzMenu
Type: bool
Default: false
dBarcode.NET Aztec only. Sets the Menu flag on or off.
AzRvideo
Type: bool
Default: false
dBarcode.NET Aztec only. Sets the Reverse Vidoe flag on or off.
BackColor
Type: Color
Default: Color.White
Allowed values: any allowed Color value.
Sets the colour of the image background.
BorderWidth
Type: float
Default: 0.0 (no border)
Allowed values: any
Specifies the size (in units determined by the setting of the PageUnit property of the Graphics object passed into the
component) of a border placed around the barcode. The border area is created using the background color set by the
BackColor property.
ByteNumber
[Aztec, DataMatrix, PDF417 and QR Code only]
Type: integer
Default: 0
Allowed values: 0 – barcode byte capacity
This property should normally be set at 0 when the Caption property is derived from a string of characters.
When ByteValue is greater than 0 the Caption string (which is a Unicode string) is unpacked into 8-bit bytes before the
data is used to generate the barcode.
If ByteNumber is set to a value other than zero it MUST be set after the Caption property has been set.
See Using 8-bit byte data for further information.
Caption
Type: string
30 dBarcode.NET Components dLSoft dBarcode.NET Components
Default: "dBarcode.NET"
Allowed values: Any text string.
Note: only text strings recognised as valid barcodes will result in a barcode picture. An Illegal character in the text string
will cause an Error value to be set.
CodeType
Type: bCode enumeration member
For dBarcode.NET 2D Universal Component
Default: Aztec
Allowed values:
Aztec
Datamatrix
Maxicode
PDF417
Micro_PDF
Databar
QR Code
Truncated (PDF417)
MicroQR
For dBarcode.NET PDF417 Component
Default: PDF417
Allowed values: PDF417 or Micro_PDF.
For dBarcode.NET QR Code Component
Default: QRCode
Allowed values: QRCode or MicroQR.
The barcode type can be set using either the CodeType property or the CodeTypeValue property
For all other components the only allowed value is the default value corresponding to a CodeTypeValue of 0
CodeTypeValue
Type: integer
Default: 0
Allowed values: The ranges of values defined for the individual components are shown in the barcode type tables
below.
The barcode type can be set using either the CodeType property or the CodeTypeValue property
The possible values for CodeType and CodeTypeValue are shown below (for the GS1 Composite component see the
Composite section; for the Dual Universal component see the Dual Universal component section).
Component CodeType CodeTypeValue
dBarcode-Aztec.NET Aztec 0
dBarcode-49.NET Code 49 0
dLSoft dBarcode.NET Components dBarcode.NET Components 31
dBarcode-49.NET Codablock F 1
dBarcode-DataMatrix.NET DataMatrix 0
dBarcode-PDF417.NET PDF417 0
dBarcode-PDF417.NET Micro_PDF 1
dBarcode-PDF417.NET Truncated PDF417 2
dBarcode-QR.NET QR Code 0
dBarcode-QR.NET MicroQR Code 1
dBarcode-RSS.NET Databar 0
32 dBarcode.NET Components dLSoft dBarcode.NET Components
For dBarcode-2D.NET
CodeType CodeTypeValue
Aztec 0
Datamatrix 1
Maxicode 2
PDF417 3
Micro_PDF 4
Databar 5
QR Code 6
Truncated PDF417 7
Micro QR Code 8
Columns
Type: integer
Default: 0
Allowed values: 0 – maximum size of symbol
Applies to PDF417, MicroPDF, QR Code, Micro QR Code, Datamatrix, Databar (expanded stacked) and Codablock
barcodes only
For PDF417, MicroPDF, Databar and Codablock “Columns” refers to the number of datawords in a row – NOT the
number of bars. Note that requirements of the symbology mean that not all values are possible. For example, PDF417
requires a minimu of 3 rows irrespective of the number of columns.
For Datamatrix and QR Code symbols “Columns” refers to the number of square elements in a row. Only specific
symbol sizes are permitted in these symbols. If an invalid number of columns is specified the next valid number will be
used. Columns should be set to zero if you wish the symbol size to be determined by the security level setting.
DeutschePost
Type: Boolean
Default: False
Applies to Datamatrix barcode type only.
When set to true, forces Damatrix symbols to be created using Base256 encoding as required in some DeutschePost
applications.
EPScorrection
Type Integer
Default: 1
When vector EPS images are created bars may be rendered one device pixel wider and taller than required – making
black rectangles larger than white rectangles. dBarcode.NET components will reduce the width and height of bars by and
amount equal to
EPScorrection * pixel size of target device
dLSoft dBarcode.NET Components dBarcode.NET Components 33
The pixel size of the target device is determined from the hDpi and vDpi values provided in the call that generates an
EPS image (eg. sBarcode()).
If this correction is not required the value of EPScorrection may be set to 0.
EPSpreview
Type Integer
Default: 0
When set to 1 this property causes a low resolution bitmap preview to be incorporated into any EPS files/streams. When
0 no preview image is created.
Esc
Type: string
Default: null
If the Esc string is set to a value then the first character of that string is used as an escape character, which allows
specific strings to be inserted into a SetParam() data string using an escape sequence.
For example if the Esc string is set to “^”, then the string “ABC^tDEF” is changed so that ^t is replaced by a Tab
character.
The escape sequences available are:
^t horizontal tab
^n newline
^r carriage return
^p carriage return + linefeed
In each case the ^ character may be any character as set by the Esc property.
Note: this facility is provided to allow concatenation of fields to generate barcodes using the Pic() method. Escape
sequences are NOT converted during any other calls.
Flag
Type: Boolean
Default: false
Allowed values: true or false
dBarcode.NET Aztec, Datamatrix, PDF417 and QR Code only.
When set to true the Caption data is converted from Unicode to a byte stream enabling any Unicode characters to be
encoded as a byte sequences. If the property is false (the default) then the interpretation of the data depends on the value
of ByteNumber property; if cnumber is 0 then Unicode is converted to single bytes for the ASCII character and double
bytes for other characters. If ByteNumber is greater than 0 then the data is unpacked into 8-bit ASCII characters before
the data is used to generate the barcode (and may include ASCII 0).
Note that if the Flag is true the any value in ByteNumber is ignored; furthermore the Flag should only be used in the
barcodes byte/binary mode (including Kanji mode for QR symbols).
34 dBarcode.NET Components dLSoft dBarcode.NET Components
ForeColor
Type: Color
Default: Color.Black
Allowed values: any valid Color
Sets the colour of the image foreground, i.e. the bars and text colour.
GS1_Flag
Type: bool
Default: false
dBarcode.NET Datamatrix and 2D Universal only. Sets the GS1 encoding flag on or off.
Mirror
Type: BOOL
Default: False
A value of True will cause the barcode image to be created as a mirror image. This facility is designed for use with
printing technologies that require a mirror image. Mirror image barcodes may not be scannable unless printed correctly.
Orientation
Type: integer
Default: 0 The value of this parameter determines the orientation of the barcode image created.
Allowed values: 0 - 360 degrees
Note that the rotation of text is only supported by TrueType and other rotatable fonts. Note also that some applications
do not correctly handle metafiles that contain rotated text.
PairsPerRow
Type: float
Default: 1.0
Allowed values: 0.1 – 10.0
Applies to Databar Expanded-Stacked barcodes only
For Databar Expanded Stacked symbols the value specifies the number of segment pairs in the first row. Fractional
values are rounded to the nearest integer. The final row of an Expanded Stacked symbol may contain a smaller number
of segments.
PostFlag
Type: bool
Default: false
dLSoft dBarcode.NET Components dBarcode.NET Components 35
Applies to Datamatrix barcode type only.
When set true the symbol is created as a Deutsche Post PostMatrix symbol, with two additional vertical bars.
Reduction
Type: float
Default: 0 the thickness of each line drawn on the barcode image is reduced by this percentage amount. This
property may be used to compensate for ink spreading during wet-ink printing.
Allowed values: 0 - 50 (%)
A positive reduces the thickness of bars by the calculated amount of the thinnest bar. A negative value reduces the
thickness of bars by the percentage applied to the bar thickness (so a bar three units wide is reduced by an absolute
amount that is three times greater than that which would apply to a one unit bar)
SecurityLevel
Type: integer
Default: 0
This parameter specifies the security level - i.e. the amount of redundancy built in to the barcode image to allow for
errors to be corrected. The greater the security level the larger the barcode image. See 2D-Barcodes Help for details.
Allowed values are 0 - 8 for PDF417.
Allowed values for Aztec codes depend on the mode, and are 0-99 for Normal mode, 1-4 for Compact mode, and 1-32
for Full range mode (the value is ignored for Runes). Note that for Compact and Full range the security level is actually
the required number of Aztec layers in the symbol.
For Datamatrix symbols the allowed values are 0 – 23 for Square symbols, or 0 – 6 for Rectangular symbols.
For QR Codes the allowed security levels are 0 – 3. For Micro QR Code the values are 0 – 2.
For other barcode types this parameter should be 0.
StartMode
Type: integer
Default: 0
Some 2D barcode types support different modes of encoding data. This parameter allows the initial mode to be specified,
according to the tables below. For other barcode types the mode is determined automatically and the StartMode
parameter must be 0.
Allowed values:
PDF417 (see 2D Barcodes Help for details)
StartMode parameter Mode
0 EXC Alpha
1 EXC Lower
2 EXC Mixed
3 EXC Punctuation.
4 Binary/ASCII Plus
36 dBarcode.NET Components dLSoft dBarcode.NET Components
5 Numeric mode
For most applications this parameter should be 0 for PDF417, the algorithm within the DLL will adjust to the most
appropriate mode.
Aztec (see 2D Barcodes Help for details)
StartMode parameter Mode
0 Normal
1 Compact
2 Full range
3 Rune
For most applications a value of 0 is recommended, along with a security level of 0 which provides the default value of
23% + 3 codewords.
For DataMatrix
StartMode value DataMatrix type
0 Auto Square
1 Auto Rectangular
2 ASCII Square
3 ASCII Rectangular
4 C40 Square
5 C40 Rectangular
6 Text Square
7 Text Rectangular
8 X12 Square
9 X12 Rectangular
10 EDIFACT Square
11 EDIFACT Rectangular
12 Base 256 Square
13 Base 256 Rectangular
MaxiCode (see 2D Barcodes Help for details)
StartMode Value MaxiCode Mode
0 obsolete, not supported
1 obsolete, not supported
2 Mode 2 (Structured Carrier Message –
Numeric Postal Code)
3 Mode 3 (Structured Carrier Message – Alphanumeric Postal Code)
dLSoft dBarcode.NET Components dBarcode.NET Components 37
4 Mode 4 – Standard Symbol (SEC)
5 Mode 5 – Full EEC Symbol
6 Mode 6 – Reader Program (SEC)
Databar codes.
StartMode value Databar version
0 Omnidirection
1 Truncated
2 Limited
3 Stacked
4 Stacked Omnidirectional
5 Expanded
6 Expanded Stacked
QR Code & Micro QR Code
StartMode value QR mode
0 Automatic
1 Alphanumeric
2 Byte
3 Kanji*
*Set the Flag property when using Kanji mode.
Unit
Type GraphicsUnit
Default: Millimeter
The scaling mode applied to values of the following size-related properties:
BorderWidth
Allowed values:
Document
Display
Pixel
Point
Millimeter
Inch
Xunit
Type: float
38 dBarcode.NET Components dLSoft dBarcode.NET Components
Default: 15.0
Allowed range: 8.0 – 255.0
The Xunit property may be used to specify the width (in Mils) of the smallest element in the barcode.
Note that setting this property causes the image to resize itself to a size calculated from the number of X units in the
barcode
Using values smaller than 8 will produce a barcode image, but that image will not meet standard specifications and may
not scan.
For Maxicodes this property is used to specify the L dimension (the height of the image in mm) and defaults to 25.50
mm.
Ymultiplier
Type: float
Default: 3.0
Allowed range: 2.0 – 5.0 for PDF417, 1.0 – 255.0 for Codablock F, Code 49, and Databar
The Ymultiplier property may be used to specify the height (in Xunits) of the elements in the barcode.
Note that setting this property causes the image to resize itself to a size calculated from the number of X units in the
barcode
Using values outside the allowed range will generate a barcode that may not scan. Some Databar barcode types have
standard values for this property and will ignore the setting of this property.
This property is available only for Codablock F, Code 49, PDF417 and Databar components.
Information properties
Note that the barcode symbol is determined only when this Barcode() method is called, so the information properties are
not available until this method has been called.
Error
Type: integer
Returns a value representing the error code if a valid barcode image cannot be created. Otherwise returns 0.
Read only. Do not set this property.
The error codes and corresponding Status property values are shown below:
Status
Type: string
Returns a string interpretting the value of the Error property.
The error codes and corresponding Status property values are shown below:
Error Status
0 OK
1 Illegal character in data
dLSoft dBarcode.NET Components dBarcode.NET Components 39
2 Wrong data length
3 Error in barcode data
4 Cannot generate barcode
9 Graphics drawing error
Read only. Do not set this property.
ImageHeight
Type: FLOAT
Return the actual height of the image generated, in units of the current Graphics object – NOT the units specified by the
Unit property.
The value returned includes the size of any border, margin and text.
Read only. Do not set this property.
ImageWidth
Type: FLOAT
Return the actual width of the image generated, in units of the current Graphics object – NOT the units specified by the
Unit property.
The value returned includes the size of any border, margin and text.
Read only. Do not set this property.
Pattern
Type: String
Returns: A string containing a pattern of digit characters which represent the bars and spaces in the barcode
symbol. See the Pattern String section for details.
Read only. Do not set this property.
The Maxicode component does note generate a Pattern string.
Methods
Barcode(Graphics g)
Return Type: Metafile
This method causes a barcode image to be created using the Graphics properties of g (including the PageUnit property
which determines that absolute size information embedded in the image).
Barcode(Graphics g, float fScale, int iUseMetaProps) is the fundamental metafile-creation method which is called by all
other methods that generate an image and is not normally called directly. fScale provides the absolute scaling factor for
the metafile image created. If iUseMetaProps is greater than zero the metafile is based on a 96 dpi resolution no matter
what the true resolution of the graphics device – and should be used, for example, when creating an image on a web
40 dBarcode.NET Components dLSoft dBarcode.NET Components
server based on a dummy bitmap file. If iUseMetaProps =0 then the metafile created is based on the resolution of the
graphics g.
Note that the barcode symbol is determined only when this method is called, so the information properties are not set
until this method has been called.
cBarcode()
Return Type: Integer
cBarcode(int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on a device
with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively.
cBarcode(Graphics g, int hDpi, int vDpi) copies to the clipboard a bitmap image scaled to be suitable for printing on
a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively using the properties of
Graphics g.
This method is useful for generating an image that is to be copied to another application for later printing, e.g. for
copying an image that will be subsequently pasted into Word and printed on a 600 dpi printer:
Abcnet1.cBarcode(g,600,600)
If hDpi and vDpi are zero the properties of the Graphics g will be used.
Returns 0 if successful, or an error code if the barcode cannot be created, or -1 if the clipboard is not available.
doBarcode()
Return Type: int
This method may be used to check that a barcode can be created using the current property settings, returning 0 if the
current settings are valid, or an error code (see the Error property), along with setting the Status property. It does not
create a barcode image.
This method is called when Barcode(g) is called.
Properties()
Return Type: BOOL
Displays the Barcode properties dialog for the component.
Returns TRUE if the user exits the dialog by pushing the OK button and sets all component properties to those specified
in the dialog.
Returns FALSE if the user exits the dialog by pushing the Cancel button.
dLSoft dBarcode.NET Components dBarcode.NET Components 41
sBarcode()
sBarcode(int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with horizontal and
vertical resolutions of hDpi and vDpi dots per inch respectively.
Return Type: Metafile
sBarcode(Graphics g, int hDpi, int vDpi) generates an image scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively using the properties of Graphics g. If
hDpi and vDpi are zero the properties of the Graphics g will be used.
Return Type: Metafile
sBarcode(int hDpi, int vDpi, ImageFormat im) generates an memory stream image with the format specified by
im, scaled to be suitable for printing on a device with horizontal and vertical resolutions of hDpi and vDpi dots per inch
respectively with the bars pixel aligned. If ImageFormat im is null or ImageFormat.Icon a vector EPS stream is returned.
sBarcode(int hDpi, int vDpi, ImageFormat im, int iPixAlign) If iPixAlign is 1 and the image format specifies a bitmap
format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 does the bitmap is created without
pixel alignment. If ImageFormat im is null or ImageFormat.Icon a vector EPS stream is returned and iPixAlign is
ignored.
Return Type: MemoryStream. Returns a MemoryStream of Length 0 if an error occurs.
sBarcode(int hDpi, int vDpi, string filename) saves an image into the file specified by filename with the format
specified by filename extension, scaled to be suitable for printing on a device with horizontal and vertical resolutions of
hDpi and vDpi dots per inch respectively with the bars pixel aligned.
Images may be saved in BMP, EPS, GIF, JPG, PNG, TIF or WMF formats.
42 dBarcode.NET Components dLSoft dBarcode.NET Components
sBarcode(int hDpi, int vDpi, string filename, int iPixAlign) If iPixAlign is 1 and the graphics file name specifies a
bitmap format, then the image is resized so that the bars are pixel aligned. If iPixAlign is 0 does the bitmap is created
without pixel alignment.
Return Type: Int. Returns 0 if successful or 1 if an error occurs.
These methods are useful for generating an image that is to be saved for later printing, e.g. for saving an image that will
be subsequently printed on a 600 dpi printer:
Filename=”c:\fred.png”
Abcnet1.sBarcode(600,600, filename)
Saves the file and the following print handler print the image
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim newImage As Image = Image.FromFile(graphicfilename)
Dim r As Rectangle
r.X = 600
r.Y = 600
r.Width = newImage.Width
r.Height = newImage.Height
e.Graphics.PageUnit = GraphicsUnit.Pixel '
e.Graphics.DrawImage(newImage, r)
' Indicate that this is the last page to print.
e.HasMorePages = False
End Sub
If hDpi and vDpi are zero the properties of the Graphics g will be used.
When creating EPS images the EPScorrection property may be used to correct the bar size produced by PostScript
engines that render rectangles 1 pixel wider than required.
sBarcode1()
sBarcode1(int hDpi, int vDpi, string filename) saves a monochrome ( 1 bit per pixel) image into the file specified
by filename with the format specified by filename extension, scaled to be suitable for printing on a device with
horizontal and vertical resolutions of hDpi and vDpi dots per inch respectively and with the bars pixel aligned.
This method operates only for BMP, PNG and TIF files and the filename provided must have one of those extensions.
Return Type: Int. Returns 0 if successful or 1 if an error occurs.
sBarcode1(int hDpi, int vDpi, ImageFormat im) generates a monochrome (1 bit per pixel) memory stream image
with the format specified by im, scaled to be suitable for printing on a device with horizontal and vertical resolutions of
hDpi and vDpi dots per inch respectively and with the bars pixel aligned.
This method operates only for BMP, PNG and TIF formats and the image format provided must be one of
ImageFormat.Bmp, ImageFormat.Png or ImageFormat.Tif.
Return Type: MemoryStream. Returns a MemoryStream of Length 0 if an error occurs.
SetBytes()
The SetBytes method allows byte data (including byte values of 0) to be transferred to the component for generating a
barcode. Applies only to barcode types that have a byte or binary mode (Aztec, Datamatrix, PDF417 and QR Code).
The byte data is passed as a byte array of specified length, eg.
In C#
dLSoft dBarcode.NET Components dBarcode.NET Components 43
I=abcnet1.SetBytes(byte[] Bytes, int ArrayLength);
In VB
I=Abcnet1.SetBytes(Bytes,n)
Where Bytes is an array of bytes and n is the number of bytes containing the required data.
The method returns the number of bytes passed in, or 0 if an error occurs.
See Using 8-bit byte data for more information.
SetParam()
The SetParam method allows a named property to be set to a specific data value using the format:
SetParam(“Xunit”,”16”)
where both the property name and the data are passed as strings. This approach is useful for creating servlets within IIS
that can return a barcode image to a remote application (such as Crystal Reports). A simple servlet example is included
within the distribution.
The property names used in SetParam are, with a few exceptions, the same as the component properties names described
earlier. The following exceptions should be noted:
The barcode data string is passed using the name “Data” and not Caption.
The barcode code type is passed using the name “CodeType” but the data value must be one of the number strings listed
under CodeTypeValue (eg. “0”).
The Unit data string is passed using the name “Units”, but the data values can be only “IN” (for inches) or “MM” (for
millimetres).
A property name “Resolution” may be passed to specify the resolution (in pixels per inch) of the barcode image that will
subsequently be returned using the Pic() method.
Where a property requires a Boolean value for data, “0” is interpreted as false, any other value is interpreted as true.
The method type is void; there is no returned value.
The use of SetParam() and Pic() is discussed in the ASP.NET section.
Pic()
The Pic() method returns a memory stream containing a graphics image. The image type is determined using two
parameters:
Ms=m_barcode.Pic(imType as String, colType as Integer)
Where imType may be one of “bmp”, “eps”, “gif”, “jpg”, “png”, “tif” or “wmf” to specify the graphics format, and
colType may be 0 (for normal 24 bbp images) or 1 (for monochrome 1 bpp images).
Note that monochrome images may be generated only for bmp, png and tif images.
The Pic() method if provided only for convenience in creating servlets and is not recommended for other purposes.
The use of SetParam() and Pic() is discussed in the ASP.NET section.
Deutschepost and PostMatrix dBarcode.NET 2D Universal, Dual and Datamatrix only
44 dBarcode.NET Components dLSoft dBarcode.NET Components
Deutschepost Damatrix symbols for some applications are required to use Base256 encoding rather than the standard
ECC200. The DeutschePost property may be set to True force Datamatrix symbols to be encoded in this mode.
The PostMatrix variant of Datamatrix may be generated by setting the PostFlag property to True.
GS1 Encoding dBarcode.NET 2D Universal, Dual and Datamatrix only
If the Caption string begins with an FNC1 character - ASCII 232 (è) - or the GS1_Flag is on, the Caption is scanned for
GS1 Application Identifiers and encoded according to the GS1 Datamatrix specification.
GS1 encoding requires the Application Identifiers to be provided within brackets, eg. (80)12345678(10)123456 so that
the AIs can be identified.
Variable length AIs will have FNC1 characters inserted to terminate the AI and all brackets are removed from the
encoded data.
During scanning FNC1 characters are replaced by ASCII values of 29.
Using 8-bit byte data .NET software is designed to work with Unicode characters. Most barcodes are designed for ASCII. While the two
happily co-exist for ASCII characters up to 127, problems arise with the “higher ASCII” characters 128-255. Graphic
images and encrypted data needs to use data byte values greater than 127 and may include 0.
The dBarcode.NET components that support byte data can convert the use the SetByte method to pass the byte values
required.
The developer can take 8-bit data, place it in a byte array and then use the SetBytes() method to pass the data to the
component rather than using the Caption property.
A simple example for encoding the ASCII values 0 - 255 is illustrated below:
Dim i, j, k As Integer
Dim ByteArray() As Byte = New Byte(2048) {}
x = ""
j = 0
k = 0
For i = 0 To 255
ByteArray(k) = i
k = k + 1
Next i
Abcnet1.SetBytes(ByteArray, k)
Only Aztec, Datamatrix, PDF417 and QR Code can encode data containing all byte values 0 – 255.
dLSoft dBarcode.NET Components dBarcode.NET Components 45
2D Pattern strings For many reasons a developer may prefer to draw the bars to generate the barcode, rather than use the metafile image
returned by the dBarcode-2D.NET library.
To do this use the “pattern” string returned from the DLL.
The choice of size for the drawn bars is a matter for the developer. However, some features of the drawn image should
be considered in relation to the notes below for the different barcode types supported. In particular note that some
stacked barcode types require separator lines to be drawn between each row. In general separator lines are drawn with
the thickness of a single unit (the same as the thinnest bar in the symbol).
Aztec
The pattern string returned for an Aztec barcode consists of the sequence of characters used to create the symbol,
arranged by row, with a ‘1’ for a black square and a ‘0’ for a white square. Each row is separated by a newline (\n or
CHR(10)) characters.
Codablock F and Code 49
The pattern string returned for these barcodes consists of a sequence of 0s and 1s, where 0 represents a space and 1
represents a bar. Each line is terminated by a newline character (\n ASCII 10). The horizontal row lines are not included.
DataMatrix
The pattern string return for a DataMatrix barcode consists of the sequence of characters used to create the symbol,
arranged by row, with a ‘1’ for a black square and a ‘0’ for a white square. Each row is separated by a newline (\n or
CHR(10)) characters.
MaxiCode
Owing to the nature of MaxiCode, no pattern string is produced for this barcode type.
MicroPDF417
The pattern string returned for MicroPDF417 has the same properties as that for normal PDF417.
PDF417 & Truncated PDF417
The pattern strings returned for PDF417 and Truncated PDF417 barcodes consist of a stream of digit characters, with
alternate characters in each row representing first bars, then spaces. So the pattern 82131 represents an 8 unit bar
followed by a 2 unit space, a 1 unit bar, a 3 unit space and a 1 unit bar.
Each row of the barcode symbol is terminated by a newline character (\n or CHR$(10)) in the pattern string.
PDF417 symbols do not contain row separators.
QR Code
The pattern string return for a QR Code barcode consists of the sequence of characters used to create the symbol,
arranged by row, with a ‘1’ for a black square and a ‘0’ for a white square. Each row is separated by a newline (\n or
CHR(10)) characters.
46 dBarcode.NET Components dLSoft dBarcode.NET Components
Databar
The Pattern string for a linear Databar symbol consists of a stream of digit characters, with alternate characters
representing first bars, then spaces. So the pattern 12131 represents an 1 unit bar followed by a 2 unit space, a 1 unit bar,
a 3 unit space and a 1 unit bar, etc.
The Pattern strings for Stacked Databar symbols are a little more complex. The string consists a stream of digit
characters, with each row of the symbol (including the separator patterns) being separated by a newline (\n or CHR(10))
character. For the stacked symbols each row start with a space of the specified width. So the row pattern 2112131
represents a 2 unit space followed by a 1 unit bar followed by a 2 unit space, a 1 unit bar, a 3 unit space and a 1 unit bar,
etc. If the initial digit in a row is 0 then this means there is no starting space.
The row heights are given in the Databar barcode section. Users requiring further information on the allowed sizes for
Databar codes should refer to the Databar standard specification..
The GS1-Composite Component
Composite data
The GS1-Composite component shares may of the properties and methods of the other components, but there are some
differences. For a start there are two data sources, one for the linear component and one for the composite.
The component provides two alternative mechanisms for introducing the data. The Caption property may be use to
provide both sets of data with the linear component’s data provided first, followed by the composite component’s data,
the two being separated by a tab, newline or carriage return character (ASCII 9,10 or 13). This method allows the
Caption property to be set from a single string field.
Alternatively the Caption property may be set to null string and the linear component’s data provided to the LinData
property and the composite’s component’s data to the CCData property. Note that if the Caption property is not null the
LinData and CCData properties are ignored.
If no data is provided for CCData but valid data is provided for LinData, the component will generate the normal linear
barcode without a composite. Similarly if data is provided in the Caption property without a separator character then this
data is assumed to be for the linear component and no composiste component is generated.
Control codes (eg the func 1 code used in both GS1-128 and Databar) may be set through the Control property.
CodeType
The CodeType property determines the type of linear barcode to be generated. With one exception (GS1-128 barcodes
with CC-C composites) the choice between CC-A and CC-B composite components is made on the basis of the amount
of composite data and is not user-selectable. The following values for the CodeType and CodeTypeValue properties are
supported:
Barcode CodeType CodeTypeValue
EAN 14 EAN_14 0
SSCC SSCC 1
EAN 13 EAN_13 2
EAN 13 plus 2 digits EAN_13_plus_2 3
dLSoft dBarcode.NET Components dBarcode.NET Components 47
EAN 13 plus 5 digits EAN_13_plus_5 4
UPC-A UPC_A 5
UPC-A plus 2 digits UPC_A_plus_2 6
UPC-A plus 5 digits UPC_A_plus_5 7
EAN 8 EAN_8 8
EAN 8 plus 2 digits EAN_8_plus_2 9
EAN 8 plus 5 digits EAN_8_plus_5 10
UPC-E UPC_E 11
GS1-128 (CC-C) GS1_128_C 12
GS1-128 (CC-A/B) GS1_128 13
ITF-14* ITF 14
Databar Omnidirectional Omnidir 15
Databar Truncated Truncated 16
Databar Stacked Stacked 17
Databar Stacked
Omnidirectional
Omni_Stacked 18
Databar Limited Limited 19
Databar Expanded Expanded 20
Databar Expanded-
Stacked
Expanded_Stacked 21
EAN 14, ITF-14 and SSCC barcodes do not support composites
Barcode size
The size of barcodes generated by the GS1-Composite component is determined entirely by the properties Xunit,
Ymultiplier and LinearHeight. The properties BarcodeWidth and BarcodeHeight used in other components are NOT
provided in the GS1-Composite component.
The Xunit property is specified in Mils (thousandths of an inch) and determines the minimum bar width for both the
linear and composite component. Typically this will be in the range 12-20 for most barcodes, although 40 is the standard
size for ITF-14 symbols.
The Ymultiplier property specifies the bar height for the composite component as a multiple of the Xunit property, and
should be in the range 2 – 5.
The LinearHeight property specifies the height of the bars for the linear component in units specified by the Units
property. For Stacked and Expanded-Stacked Databar types this is the height of each row of bars.
The following properties of other dBarcode.NET components are NOT supported by the GS1-Composite component:
AspectFlag
BarcodeHeight
BarcodeWidth
BorderWidth
ByteNumber
MarginSize
dLSoft dBarcode.NET Components dBarcode.NET Components 49
dBarcode.NET Dual component
Dual component Properties
The dBarcode.NET Dual Universal component combines many of the features of the 1D and 2D Universal components
and the GS1-Composite component. It implements all the properties and methods of the 1D and 2D Universal
components, differing primarily in the Properties dialog – which appears in different forms depending on whether the
current barcode type is a 1D, 2D or Composite barcode:
dBarcode.NET Dual – Properties dialog for 1D barcodes
50 dBarcode.NET Components dLSoft dBarcode.NET Components
dBarcode.NET Dual – Properties dialog for 2D barcodes.
dBarcode.NET Dual – Properties dialog for GS1-Composite barcodes.
dLSoft dBarcode.NET Components dBarcode.NET Components 51
Dual component CodeTypeValues
The allowed values for the CodeTypeValue property for 1D barcodes are those listed for the 1D Universal component
(see table above), while those for the 2D barcodes and GS1-Composite symbols are shown below:
Symbol CodeType Value
Aztec Aztec 80
Datamatrix Datamatrix 81
Maxicode Maxicode 82
PDF417 PDF417 83
Micro PDF 417 Micro_PDF 84
Databar (RSS) Databar 85
QR Code QRCode 86
Truncated PDF417 Truncated 87
Micro QR Code MicroQR 88
Composites:
GS1-13 (EAN-13) zc_EAN_13 100
GS1-13 plus 2 zc_EAN_13_2 101
GS1-13 plus 5 zc_EAN_13_5 102
UPC-A zc_UPC_A 103
UPC-A plus 2 zc_UPC_A_2 104
UPC-A plus 5 zc_UPC_A_5 105
EAN-8 zc_EAN_8 106
EAN-8 plus 2 zc_EAN_8_2 107
EAN-8 plus 5 zc_EAN_8_5 108
UPC-E zc_UPC_E 109
GS1-128 CC comp zc_GS1_128_CC 110
GS1-128 A/B comp zc_GS1_128_AB 111
Databar Omnidirectional zc_Databar_Omni 112
Databar Truncated zc_Databar_Trunc 113
Databar Stacked zc_Databar_Stacked 114
Databar Omnidir. Stacked zc_Databr_Omni_Stacked 115
Databar Limited zc_Databar_Limited 116
Databar Expanded zc_Databar_Expanded 117
Databar Expanded Stacked zc_Databar_Exp_Stacked 118
Note that Databar barcodes may be produced as 2D barcodes (in which case the variant is determined by the Mode
property) or the Linear variants may be produced using the CodeTypes:
Databar_Exp (Databar Expanded)
Databar_Lim (Daabar Limited)
Databar_Omni (Databar Omnidirectional)
Databar_Trunc (Truncated)
52 dBarcode.NET Components dLSoft dBarcode.NET Components
In these cases the barcodes are generated as 1D barcodes, complete with the option of including human readable text
under the bars.
The dBarcode.NET Dual Universal component contains two additional properties: LinData and CCData, which may be
used to pass the data for the linear portion of the symbol and the Composite portion respectively.
The Caption property may be use to provide both sets of data with the linear component’s data provided first, followed
by the composite component’s data, the two being separated by a tab, newline or carriage return character (ASCII 9,10 or
13). This method allows the Caption property to be set from a single string field.
Alternatively the Caption property may be set to null string and the linear component’s data provided to the LinData
property and the composite’s component’s data to the CCData property. Note that if the Caption property is not null and
does not contain one of the separator characters, then the Caption property is used for the LinData property.
If the Properties dialog is called and closed using the OK button while the Composite pane is displayed, then the LinData
and CCData properties contain the data from that dialog. The Caption property does NOT contain meaningful data.
dLSoft dBarcode.NET Components dBarcode.NET Components 53
dBarcode.Net Controls While the dBarcode.Net Components can be used on WinForm projects, many developers prefer to use a control that
displays a barcode immediately it is placed on a Form.
The dBarcode.Net Controls are managed code controls that can be loaded into the Visual Studio ToolBox and then
dragged onto a Windows Form – where they appear as a barcode image.
The 1D controls
There are several 1D controls in the dBarcode.NET family, one for each of the most popular barcode
types, and one which handle a wide range of different barcode types. The 1D controls are:
dBarcodeStd dBarcodeStd.dll – for Code 39, Extended Code 39, Code 93, Extended 93, Code 128, Interleaved 2
of 5, and Matrix 2 of 5 barcodes
dBarcode GS1 dBarcodeGS1.dll – for Linear Databar (Omnidirectional, Truncated, Limited and Expanded), EAN-
13, EAN-14, EAN-8, GS1-128, ITF-14, SSCC, UPC-A, UPC-E barcodes
dBarcode1D dBarcode1d.dll – for most common barcode types (over 50 types supported; see the list provided
under CodeType).
The 2D controls
There are several 2D controls in the dBarcode.NET family, one for each of the most popular barcode
types, and two which handle a wide range of different barcode types. The controls are:
dBarcodeAZ dBarcodeAZ.dll – for Aztec barcodes
dBarcodeDM dBarcodeDM.dll – for DataMatrix barcodes
dBarcodePDF dBarcodePDF.dll – for PDF417 and Micro PDF barcodes
dBarcodeQR dBarcodeQR.dll – for QR Code barcodes
dBarcodeRSS dBarcodeRSS.dll – for Databar (formerly RSS) barcodes, Linear and Stacked.
dBarcode2D dBarcode2D.dll – for Aztec, DataMatrix, Maxicode, PDF417, Micro PDF417, QR Code and Databar
barcodes.
dBarcodeComp dBarcodeComp.dll – for ITF-14, SSCC stand-alone symbols and Databar, EAN-13, EAN-8, GS1-
54 dBarcode.NET Components dLSoft dBarcode.NET Components
128, UPC-A & UPC-E with or without CC-A, CC-B, CC-C composite codes. See the section
entitled “The GS1 Composite Component”
dBarcode Dual dBarcodeDual.dll – for all of the 1D, 2D and GS1-Composite symbols listed above.
See the Section entitled “dBarcode.NET Dual Component”.
With the exception of the Font and Color properties (named as bcFont, bcForeColor and
bcBackColor) all controls share the same properties as the corresponding Components discussed
above. Full details of the functions and allowed values are given in the Components reference
section.
Using dBarcode.NET Controls in Visual Studio
Adding a dBarcode.NET Control to the ToolBox
To add a dBarcode Control to the Visual Studio ToolBox, with a Windows Form open in Design view, display the
ToolBox and select the Common Controls section tab. Right click on the item and select Choose Items from the pop-up
menu displayed. A dialog box is displayed listing the currently installed components. Ensure that the .NET Framework
Components page is displayed.
Push the Browse button and navigate to the location where you have installed or copied your dBarcode Control and
select the DLL (e.g. dBarcodeDual.dll).
Then push the Open button.
The list of installed components is now displayed, including your dBarcode Control. Ensure that the checkbox alongside
the component name is checked. Now push the OK button.
The control appears as an icon on the ToolBox Common Controls section, with one of the appropriate control name
alongside:
Adding a dBarcode.Net Control to a Form.
With a project's form open in design mode drag the dBarcode control icon from the toolbox onto the form.
The control appears on the form appearing as the default barcode for the control used. A single form may contain any
number of dBarcode controls.
dLSoft dBarcode.NET Components dBarcode.NET Components 55
If the Visual Studio Properties panel is open when the control is added or selected (and if Commands are enabled) then
the Properties panel includes the link to “Show barcode properties dialog”.
Alternatively, right clicking on the selected control will display a pop-up menu which includes the item to “Show
barcode properties dialog”.
56 dBarcode.NET Components dLSoft dBarcode.NET Components
In either case selecting the link will display the barcode properties dialog, allowing the default barcode properties to be
set a design time.
dLSoft dBarcode.NET Components dBarcode.NET Components 57
The Visual Studio properties panel also displays all other settable properties for the control in the Barcode data section,
and these values will be used as defaults unless properties are changed programmatically within your code.
Unless it is necessary for other properties to be changed within your program, the only property that is likely to be
changed programmatically is the barcode data content. This is easily accomplished by a single line of code such as
In VB: BarccDual1.Caption = TextBox1.Text BarccDual1.Refresh()
In C# barccDual1.Caption = textBox1.Text; barccDual1.Refresh();
dBarcode Control methods
The dBarcode controls provide four methods for doing things other than displaying themselves:
doProps()
Display the barcode properties dialog. Allows the properties of the barcode to be changed by the user at run-time.
Returns true if the user closes the dialog using the OK button; return false otherwise.
In VB:
58 dBarcode.NET Components dLSoft dBarcode.NET Components
BarccDual1.doProps()
In C#: barccDual1.doProps();
Refresh()
Forces the control to redraw itself.
In VB:
BarccDual1.Refresh()
In C#: barccDual1.Refresh();
copyBarcode()
Copies the barcode image currently displayed by the control to the Windows clipboard (in Bitmap format).
The method copyBarcode(hRes,vRes) creates a barcode image on the clipboard with the specified horizontal and vertical
resolutions (in ppi). The resolutions should be specified as integers.
Returns 0 if successful or an error code in the event of failure.
In VB: If (BarccDual1.copyBarcode(300, 300) > 0) Then statusbox.Text = "Error copying barcode image" Else statusbox.Text = "barcode image copied to clipboard" End If
In C#: if (barccDual1.copyBarcode(600, 600) > 0) statusbox.Text = "Error copying barcode image"; else statusbox.Text = "barcode image copied to clipboard";
saveBarcode()
Saves the barcode image in a graphics file with a specified resolution.
The method saveBarcode(hres,vRes,filename) save the current barcode image to a file name filename with the image
adjusted to the horizontal and vertical resolutions of hRes and vRes respectively. The resolution should be specified as
integers.
The graphics type is specified by the filename extension. The allowed types are:
BMP, EPS, GIF, JPG, PNG, TIF and WMF
The method returns 0 if successful or an error code in the vent of a failure.
In VB: res = 300 'resolution in dpi BarccDual1.saveBarcode(res, res, graphicfilename) statusbox.Text = BarccDual1.Status
In C# int res = 300; //resolution in dpi
dLSoft dBarcode.NET Components dBarcode.NET Components 59
barccDual1.saveBarcode(res, res, graphicfilename); statusbox.Text = barccDual1.Status;
Barcode()
The Barcode() method returns a Windows metafile image and is primarily used for drawing on a printer. The method has
a single parameter: the Graphics of the device for which the image is intended, eg. The printer.
So the following examples illustrate how to draw the image directly to the printer.
In VB: Private Sub PrintButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton1.Click Try AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage PrintDocument1.Print() Catch ex As Exception MessageBox.Show("An error occurred while printing", ex.ToString()) End Try End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage e.Graphics.PageUnit = GraphicsUnit.Document ' e.Graphics.DrawImage(BarccDual1.Barcode(e.Graphics), 300.0F, 450.0F) e.HasMorePages = False ' Indicate that this is the last page to print. End Sub
In C#: private void Printbutton1_Click(object sender, EventArgs e) { try { PrintDocument printDocument1 = new PrintDocument(); printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); printDocument1.Print(); } catch (Exception ex) { MessageBox.Show("An error occurred while printing", ex.ToString()); } } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.PageUnit = GraphicsUnit.Document; e.Graphics.DrawImage(barccDual1.Barcode(e.Graphics), 500F, 500F); // Indicate that this is the last page to print. e.HasMorePages = false; }
MemoryStream Barcode()
An alternative Barcode() method returns a MemoryStream graphic of the barcode at a specified resolution and in a
specified ImageFormat.
60 dBarcode.NET Components dLSoft dBarcode.NET Components
MemoryStream ms=Barcode(hres, vres, Im);
where hres and vres are the target resolutions, and Im is the ImageFormat required (eg. ImageFormat.Bmp, etc).
The image may be extracted using code such as
Image im = Image.FromStream(ms);
im.Save(graphicfilename);
etc.
dBarcode Control events
The dBarcode controls expose four events to the parent container:
OnClick
OnMouseDown
OnMouseUp
OnMouseClick
OnMouseMove
A form containing the control may have a handler added for any of these events along with a suitable implementation of
the handler. For example, the following example displays the control’s Properties dialog when the control is right-
clicked:
in VB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Barcon1.OnMouseClick, AddressOf Barcon1_OnMouseClick End Sub Private Sub Barcon1_OnMouseClick(sender As Object, e As MouseEventArgs) If (e.Button = Windows.Forms.MouseButtons.Right) Then Barcon1.doProps() Else Barcon1.Invalidate() End If End Sub
In C# public partial class Form1 : Form { public Form1() { InitializeComponent(); barcon1.OnMouseClick += barcon1_OnMouseClick; } private void barcon1_OnMouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { barcon1.doProps(); }
dLSoft dBarcode.NET Components Index 63
Index
1
1D Components Reference 9
2
2D Components Reference 27
2D Pattern strings 45
A
Adding a dBarcode.NET component to a project. 3
Adding a dBarcode.NET Component to the ToolBox 2
Adding a dBarcode.Net Control to a Form. 54
Adding a dBarcode.NET Control to the ToolBox 54
ASP.NET 24
AspectFlag 28
AutoCheckdigit 11
AzFlag 28
AzMenu 29
AzRvideo 29
Aztec 45
B
BackColor 11, 29
Barcode size 47
Barcode() 59
Barcode(Graphics g) 20, 39
BarcodeHeight 11
BarcodeWidth 11
BarRatio 11
BearerSize 11
BorderWidth 12, 29
BothBearers 12
ByteNumber 29
C
Caption 12, 29
cBarcode() 20, 40
Codablock F and Code 49 45
CodeType 12, 30, 46
CodeTypeValue 12, 30
Columns 32
Component methods 10, 28
Component properties. 9, 27
Composite data 46
Controls 15
copyBarcode() 58
D
Databar 46
DataMatrix 45
dBarcode Control events 60
dBarcode Control methods 57
dBarcode.NET 2D Component Properties 27
dBarcode.NET Components 1
dBarcode.Net Controls 53
dBarcode.NET Dual component 49
DeutschePost 32
Deutschepost and PostMatrix 43
Displaying a barcode on a form 6
doBarcode() 20, 40
doProps() 57
Dual component CodeTypeValues 51
Dual component Properties 49
E
EPScorrection 15, 32
EPSpreview 15, 33
Error 19, 38
Esc 33
ExtendBearers 16
Extra1 16
Extra2 16
F
Flag 33
Font 16
ForeColor 16, 34
G
GS1 Encoding 44
GS1_Flag 34
I
ImageHeight 19, 39
ImageWidth 19, 39
Indicators 16
Information properties 19, 38
Introduction 1
64 Index dLSoft dBarcode.NET Components
L
Licensing the component 8
M
MarginSize 17
MaxiCode 45
MemoryStream Barcode() 59
Methods 20, 39
MicroPDF417 45
Mirror 17, 34
O
Orientation 17, 34
P
PairsPerRow 34
Pattern 20, 39
PDF417 & Truncated PDF417 45
Pic() 23, 43
PostFlag 34
Printing a barcode image 7
Properties() 21, 40
Q
QR Code 45
R
Reduction 17, 35
Refresh() 58
Required properties 10, 28
S
saveBarcode() 58
Saving a barcode image 7
sBarcode() 21, 41
sBarcode1() 22, 42
SecurityLevel 35
Servlets 25
SetBytes() 42
SetParam() 23, 43
Setting and retrieving property values programmatically
4
Setting properties through the Barcode properties dialog
box 5
Setting the initial properties in a WinForms project 4
ShowCheckdigit 17
ShowText 18
StartMode 35
Status 19, 38
String2 20
Summary of Properties and Methods 9, 27
T
TextAlign 18
The 1D components 1
The 1D controls 53
The 2D components 2
The 2D controls 53
The GS1-Composite Component 46
U
Unit 18, 37
Using 8-bit byte data 44
Using dBarcode.NET Components in Visual Studio 2
Using dBarcode.NET Controls in Visual Studio 54
X
Xunit 18, 37
Y
Ymultiplier 38