Anda di halaman 1dari 16

Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

IDAutomation.com, Inc.
Your Source for Quality Symbology
[IDAutomation.com Home Page]

Home: Products: Barcode Components: Windows® .NET Form Controls: Manual and Tutorial

IDAutomation.com Dotnet Barcode Windows® Forms Control Manual & Tutorial

A license is required for each computer this software is installed on;


this software may only be used according to the License Agreement.

Our .NET Forms Barcode Controls support several linear barcode symbologies including RSS, Code 39, Extended Code 39,
Code 128, UCC/EAN-128, Interleaved 2 of 5, LOGMARS, Codabar, UPC-A, UPC-E, MSI, EAN-8, EAN-13, Code 11, Code 93,
Industrial 2 of 5, Telepen, Planet and POSTNET. The 2D version supports all linear symbologies plus MICR, PDF417,
DataMatrix and Maxicode. The controls have been tested and are compatible with Microsoft C# .NET, VB .NET, Borland C#
Builder and Borland Delphi for Microsoft.NET. This package also includes the linear version of the Compact Framework
Control for PocketPC.

INDEX:

● Step 1 - download and unzip the control


● Step 2 - registering and using the control in your application
❍ Registering the Control in Microsoft® Visual Basic .NET and C# .NET

❍ Registering the Control in Borland C# Builder and Delphi.NET

❍ Sizing the control

❍ Printing from the control

❍ Dynamically placing the control on a form

❍ Using the control as a DLL or in a Web Service Application

❍ Creating JPEG, TIFF, BMP, PNG or other graphic files

❍ Copying bar-codes to the clipboard

❍ Using CF Linear Barcode Control for the .NET Compact Framework

❍ Using DLL in Microsoft Reporting Services

● Step 3 - adjusting the properties of the control


● RSS, Composite & MicroPDF417 specific properties (available only in the RSS version)
● PDF417 specific properties (available only in the 2D version)
● Data Matrix specific properties (available only in the 2D version)
● MaxiCode specific properties (available only in the 2D version)
● MICR specific properties (available only in the 2D version and in the MICR control)
● Symbology Specific Notes
● Using the Property Page DLLs
❍ Using individual property page tabs

● Technical Issues and Support


● It is important to have the ability to test the barcodes you print with a barcode scanner. If you do not already have a
barcode scanner, we also sell high quality complete barcode scanner kits.
● This control has the unique ability to print accurate barcodes to low resolution printers such as the dedicated barcode
printers we sell.

http://www.idautomation.com/formscontrols/FormsControlManual.html (1 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Forms Control Tutorial


Using our controls is a simple 3 step process:

Step 1 - download and unzip the control package

Download and unzip the package. We suggest you place the DLL in a local directory such as C:\IDAutomation that is easy to
remember.

Step 2 - register the control in your application

After you have installed the control on your PC, you have to tell your application where it is. We have examples below that
should help you with different methods of using and printing the images.

Registering the Control in Microsoft® Visual Basic .NET and Microsoft® C# .NET:

1. Open your solution or project and display the form that you want to add the barcode to. Choose View - Toolbox to
display the Toolbox. Right-click on the Toolbox and choose Customize Toolbox. Choose the .NET Framework
Components folder. Choose Browse and select the IDAutomation Linear Barcode Control.

2. After the control appears in the Toolbox, add it to your form.

3. You can also choose Project - Add Reference if you do not wish to add it to the form.

Registering the Control in a Borland Delphi for Microsoft® .NET or C# Builder:

1. Open the project. Choose Component - Installed .NET Components from the menu. The Installed .NET Components
dialog will appear.
2. Ensure that the Installed .NET Components tab is selected and then click on the Select an Assembly button.
3. Navigate to the location where the IDAutomation.com Forms Control was installed.
4. Click Open and select the control.
5. Click OK on the Installed .NET Components dialog.
6. The barcode control will be in the General section of the Tools Palette.

Sizing the control:

http://www.idautomation.com/formscontrols/FormsControlManual.html (2 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

The control cannot be sized manually because it must meet specific requirements, such as a precise X dimension (narrow bar
width) and barcode height specified in the properties of the control. To increase the width, increase the XDimensionCM or
XDimensionMILS property. To increase the height, increase the BarHeightCM property.

Printing from the control:

● To print the barcode or copy it to an image control, you may look at the examples provided in the ZIP file or view the
sample code below.
● NOTE: If you are printing with the Picture method, be sure to call RefreshPrinterDPI() if you switch printers in your
application. It is recommended that you call RefreshPrinterDPI() before each print job. We do not recommend calling
RefreshPrinterDPI() every time the barcode itself is printed though, because it takes about .5 seconds to execute.
● Before you can use PrintDocument, you need to import System.Drawing.Printing as in the following VB.NET example:

● This is a simple example of printing a barcode to a user-specified printer and creating the barcode based on the resolution
of the selected printer in VB.NET:
Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click

Dim pd as new System.Windows.Forms.PrintDialog()


pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings()
If DialogResult.OK = pd.ShowDialog(Me) Then 'Show print dialog box
Dim prndoc As System.Drawing.Printing.PrintDocument = New System.Drawing.Printing.PrintDocument()
prndoc.PrinterSettings.PrinterName = pd.PrinterSettings.PrinterName
Barcode1.ResolutionPrinterToUse = pd.PrinterSettings.PrinterName 'Tell the barcode control which printer to reference
for resolution
prndoc.DocumentName = "Printing a Barcode"
AddHandler prndoc.PrintPage, New System.Drawing.Printing.PrintPageEventHandler(AddressOf PrintDocumentOnPrintPage)
prndoc.Print()
End If

End Sub

Private Sub PrintDocumentOnPrintPage(ByVal sender As Object, ByVal ppea As System.Drawing.Printing.PrintPageEventArgs)

Dim grfx As System.Drawing.Graphics = ppea.Graphics


Dim myImage As System.Drawing.Imaging.Metafile
grfx.PageUnit = GraphicsUnit.Millimeter
grfx.PageScale = 1.0F
grfx.DrawString(Me.Text, Me.Font, Brushes.Black, 0, 0)
myImage = Barcode1.Picture
grfx.DrawImage(myImage, 0, 20)

End Sub

● This is a simple example of how we can send the barcode metafile to a PictureBox in VB .NET:
Private Sub cmdDisplayMetafile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
cmdDisplayMetafile.Click

http://www.idautomation.com/formscontrols/FormsControlManual.html (3 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Dim myImage As System.Drawing.Imaging.Metafile


myImage = Barcode1.Picture
Dim grfx As System.Drawing.Graphics = PictureBox1.CreateGraphics()
grfx.DrawImage(myImage, 0, 0)
grfx.Dispose()
myImage = Nothing
grfx = Nothing
End Sub

● This is a simple example of how we can print the barcode using C#.NET:
private void cmdPrint_Click(object sender, System.EventArgs e)
{
PrintDocument prndoc = new PrintDocument();
prndoc.DocumentName = "Printing a Barcode";
prndoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintDocumentOnPrintPage );
prndoc.Print();
}
private void PrintDocumentOnPrintPage(object sender, PrintPageEventArgs ppea )
{
Graphics grfx = ppea.Graphics;
System.Drawing.Imaging.Metafile myImage;
grfx.DrawString(this.Text, this.Font, Brushes.Black, 0, 0);
Barcode1.RefreshPrinterDPI() //Normally you should only call RefreshPrinterDPI for each print job.
myImage = barcode1.Picture;
grfx.DrawImage(myImage, 0, 40);
return;
}

● This is a simple example of how we can print the barcode using Borland's C#Builder:
private void button1_Click(object sender, System.EventArgs e)
{
//This is the event handler to print the image of this barcode on the printer
//Create the document object that we are sending to the printer
System.Drawing.Printing.PrintDocument prndoc = new System.Drawing.Printing.PrintDocument();

//Give the document a title. This is what displays in the Printers Control Panel item
prndoc.DocumentName = "Printing a Barcode";

//Add an event handler to handle any additional processing that may need to occur, such as positioning of text
prndoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintBMPOnPrintPage);

//Initiate the printing of the page. PrintDocumentOnPrintPage will be handled next


prndoc.Print();

} //End Button_Click event

private void PrintBMPOnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ppea)


{
//This will send the bitmap to the printer.
System.Drawing.Graphics grfx = ppea.Graphics; //Create a Graphics Object
System.Drawing.Image MyImage; //Create the image object
MyImage = barcode1.BMPPicture; //Set the image object

//Draw everything on the Graphics object and then dispose of it


grfx.DrawString("Printing barcode using the bitmap image", this.Font, Brushes.Black, 0, 0);
grfx.DrawImage(MyImage, 2, 40);
grfx.Dispose();
MyImage = null;

http://www.idautomation.com/formscontrols/FormsControlManual.html (4 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Dynamically placing the control on a form:

● This is how the barcode can be created on the form with code. The code in the printing example above may be used to
print the image instead of sending it to a picturebox.

Dim NewBarcode As IDAutomation.Windows.Forms.LinearBarCode.Barcode = New Barcode()


NewBarcode.Size = New System.Drawing.Size(148, 64)
NewBarcode.Location = New System.Drawing.Point(176, 7)
NewBarcode.Name = "NewBarcode"
Me.Controls.AddRange(New System.Windows.Forms.Control() {NewBarcode})
NewBarcode.DataToEncode = "999928829"
PictureBox1.Image = NewBarcode.Picture

● This is how the barcode can be created on the form using Borland's C# Builder.

//Create the new barcode object


IDAutomation.Windows.Forms.LinearBarCode.Barcode NewBarcode = new IDAutomation.Windows.Forms.
LinearBarCode.Barcode();
NewBarcode.Location = new System.Drawing.Point(1, 1); //Set the location to the top left corner
NewBarcode.Name = "NewBarcode"; //Give the barcode a name
this.Controls.AddRange(new System.Windows.Forms.Control[] { NewBarcode }); //add the barcode to the controls
collection
NewBarcode.DataToEncode = "123ABC78"; //Update the Data
NewBarcode.RefreshImage();//Since there is not a paint event, update the images

Using the control as a DLL or in a Web Service Application (creates a barcode image without installing it on a form):

● The code in the printing example above may be used to print the image instead of sending it to a picturebox.

Dim NewBarcode As IDAutomation.Windows.Forms.LinearBarCode.Barcode = New Barcode()


NewBarcode.DataToEncode = "999928829"
PictureBox1.Image = NewBarcode.Picture

Creating JPEG, TIFF, BMP, PNG or other graphic files:

● Since our control uses the .NET framework to perform image conversion, you may create a barcode image in any format
that .NET supports in System.Drawing.Imaging.ImageFormat. Remember to set the DPI when creating images as in the
example below. If you are creating barcodes for the web browser, you should use 96 DPI.

Barcode1.Resolution = Barcode.Resolutions.Custom
Barcode1.ResolutionCustomDPI = 300
Barcode1.XDimensionCM = 0.03
Barcode1.SaveImageAs("SavedBarcode300DPI.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
Barcode1.Resolution = Barcode.Resolutions.Printer

● Using Borland's C# Builder for .NET

//The following is an example of changing the resolution of the barcode object and saving the image as a JPEG.
barcode1.Resolution = IDAutomation.Windows.Forms.LinearBarCode.Barcode.Resolutions.Custom; //Define your own
resolution size
barcode1.ResolutionCustomDPI = "300"; //Set the resolution
barcode1.XDimensionCM = "0.03"; //Set the X Dimension

http://www.idautomation.com/formscontrols/FormsControlManual.html (5 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

//Here's where the file is saved. If a full path is not specified, the file is created in
//the same directory as the IDAutomation.LinearBarcode.DLL.
barcode1.SaveImageAs("SavedBarcode300DPI.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
barcode1.SaveImageAs(@"C:\SavedBarcode300DPI.Tiff", System.Drawing.Imaging.ImageFormat.Tiff);
barcode1.Resolution = IDAutomation.Windows.Forms.LinearBarCode.Barcode.Resolutions.Printer; //Reset the resolution to
the default printer's DPI

Copying barcodes to the clipboard:

● Use the BMPPicture method to obtain an image that can be sent to the clipboard. You may also use the Picture method,
however, it will only paste from the clipboard accurately into applications when using the 1.1 version of the .NET
Framework.

Dim datobj As New System.Windows.Forms.DataObject()


Dim MyBitmap As New System.Drawing.Bitmap(Maxicode1.BMPPicture)
datobj.SetData(System.Windows.Forms.DataFormats.Bitmap, MyBitmap)
System.Windows.Forms.Clipboard.SetDataObject(datobj)
MyBitmap = Nothing
datobj = Nothing

Step 3 - adjust the properties of the control

After you insert the control in your application as described in step 2, you may adjust the properties of the control. To do this,
you can change the properties with program code or you can right-click on the control and choose Properties if it is installed on
a form.

This section explains the main configuration parameters and methods of the control:

NOTE: Many of the barcode sizing parameters are calculated in CM (centimeters). Some barcode measurements are determined
in "mils", which are 1/1000 of an inch. You may use the following rules for your conversions:

To convert mils to CM, multiply the mils value by .00254. For example, 12 mils * .00254 = .03 CM.
To convert CM to mils, divide the CM value by 2.54. For example, .03 CM / 2.54 = 11.8 mils.
To convert inches to CM, multiply the value in inches by 2.54.

http://www.idautomation.com/formscontrols/FormsControlManual.html (6 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Properties:

● DataToEncode - this is the data that is to be encoded in the barcode. If


you connect the control to a control source, then the source will override
this field.
● SymbologyID - this is the type of barcode to be used. The default is Code
128. For more information on barcode types, visit our barcoding for
beginners site.
● BarHeightCM - the height of the barcode in CM. Default is 1 CM.
● leftMarginCM - the space of the left margin in CM.
● XDimensionCM - width in centimeters of the narrow bars. The default is
0.03 CM which is about .012" or 12 mils. You may need to increase this
value if your scanner cannot read barcodes with small X dimensions. If
you have a high quality laser or CCD scanner, you may decrease this value
to obtain a higher density barcode.
● XDimensionMILS - the width in mils (1/1000 of an inch) of the narrow
bars.
● Apply Tilde - this option is only available when the symbology is Code
128, the character set is AUTO and Apply Tilde is enabled. Default is off.
When Apply Tilde is enabled, the following options are available:
❍ Encode an ASCII character: the format ~ddd may be used to

specify the ASCII code of the character to be encoded. For


example, if you enter the following text in the Data field: 66~02977
you will actually be encoding 66GS77 Where GS is a delimiter
ASCII 29 character. Other commonly used ASCII codes are ~009
for a tab and ~013 which is a return function. For encoding other
functions, please refer to our ASCII chart.
❍ Encoding UCC/EAN-128: to encode alpha-numeric UCC/EAN128, the character must be set to "AUTO" for

automatic. Then, ASCII 202 or character Ê is entered as the FNC1 before each AI and the required start C is
included automatically. For example, the UCC number of (8100)712345(21)12WH5678 should be entered as:
Ê8100712345Ê2112WH5678. In most cases, the AIs will be properly represented in the human readable text. If
the parenthesis is not around the correct number for the AI, enter the following extended ASCII character as the
FNC1 for the correct number of digits in your AI:
ASCII 212 = 2 digits
ASCII 213 = 3 digits
ASCII 214 = 4 digits
ASCII 215 = 5 digits
ASCII 216 = 6 digits
ASCII 217 = 7 digits
For example, to encode (1277)56, enter Ö127756.
For more information about this, please refer to the UCC/EAN 128 section of our Code 128 FAQ
❍ Create a Mod 10 Check digit: to Create a Mod 10 check digit for xx number of characters add the following to
the DataToEncode: ~mnn (where nn is a 2 digit number representing the number of characters preceding the tilde
in which to base the Mod 10 calculation). The additional MOD 10 check digit is commonly used in UCC or EAN
barcode types. For example, setting the DataToEncode property to Ê4021234567890123456~m16, will cause a
mod 10 check digit to be created based on all 16 characters before the tilde. The human readable text and scanned
data will display as (402)12345678901234566. The final 6 is the mod 10 check digit and replaces ~m16.
❍ Encode hexadecimal representation: to encode the hexadecimal representation of values in a barcode, add the
following to the DataToEncode: ~xnn (where nn is a 2 digit number, ranging from 01 to 99, representing the
number of characters after nn to convert to their hex equivalent). For example, setting the DataToEncode property
to ABCD~x041234EFGH would encode in the barcode and scan as ABCD31323334EFGH. Note that 31, 32, 33,
& 34 are the hexadecimal values of 1, 2, 3, & 4, respectively. Refer to our ASCII chart for a list of ASCII
characters and their hex equivalents.

http://www.idautomation.com/formscontrols/FormsControlManual.html (7 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

❍ FNC2: When necessary, the FNC2 character may be inserted into the DataToEncode string by using ASCII 197.
For example; Å8012349091. Our SC5USB Scanner can be programmed to hold the barcode starting with the
FNC2 in memory and only transmit it to the computer after scanning a barcode containing the FNC1.
● BMPPicture - use the BMPPicture method to obtain an image that can be sent to the clipboard. You may also use the
Picture method, however, it will only paste from the clipboard accurately into applications when using the 1.1 version of
the .NET Framework. See an example...
● CaptionAbove - Text that can be placed above the barcode
● CaptionBelow - Text that can be placed below the barcode
● CaptionTopAlignment - The left, right, or center alignment, in the drawing area, of the text above the barcode
● CaptionBottomAlignment - The left, right, or center alignment, in the drawing area, of the text below the barcode
● CaptionBottomColor - The color of the font of the caption below the barcode
● CaptionTopColor - The color of the font of the caption above the barcode
● CaptionBottomSpace - The distance, in CM, between the human readable text below the barcode and the caption below
the barcode
● CaptionTopSpace - The distance, in CM, between the bottom of the caption above the barcode and the top of the barcode
● CheckCharacter - automatically adds the check digit to the barcode. The check digit is required for all symbologies
except Code 39, Industrial 2 of 5 and Codabar. When using symbologies that do not require the check digit, you may
disable the check digit.
● CheckCharacterInText - automatically adds the check digit that is encoded in the barcode to the human readable text
that is displayed. This is not applicable to Code 128.
● CodabarStartCharacter - the start character for CODABAR. Valid values are "A", "B", "C" or "D".
● CodabarStopCharacter - the stop character for CODABAR. Valid values are "A", "B", "C" or "D".
● Code128CharSet - the set of characters to be used in code128. Valid values are: AUTO, A, B or C. The default and
recommended selection is AUTO. For more information on Code 128, review our Code 128 FAQ.
● BackColor - the background color of the barcode.
● Font - the font of the text in the barcode.
To change the font in code, use the following syntax for VB .NET:
Barcode1.Font = New Font(New FontFamily("Arial"), 14)
To only the point size in code, use the following syntax for VB.NET:
Barcode1.Font = New Font(Barcode1.Font.FontFamily, 14)
● ForeColor - the color of the foreground text and bars in the barcode.
● FitControlToBarcode - if true will automatically size the control canvas to fit the barcode at design or runtime.
● IndependentEMF - the property used to retrieve a device independent metafile image. For example: myImage =
Barcode1.IndependentEMF - see the VB source code example for more information. NOTE: It is suggested that the
Picture method be used when printing to printers with less than 600 DPI. *
● NarrowToWideRatio - this is the wide to narrow ratio of symbologies that only contain narrow and wide bars such as
Code 39, Interleaved 2 of 5 and MSI. Usually, this value is between 2 and 3. The default value is 2.
● RotationAngle - indicates the orientation of the barcode. Valid values are 0 (normal), 90 (vertical),180 (inverted) and 270
(inverted vertical). *
● Picture - this property is used to retrieve the metafile image that is calculated according to Resolution. It is suggested that
this be used when printing to printers with less than 600 DPI. This property creates the EMF with the resolution
information for very precise printing. Should be used with the RefreshPrinterDPI() method. See an example... *
● Resolution - the source that is used to determine the resolution the image is drawn to, which creates a more accurate
barcode. Default is printer. If custom is selected, the number residing in the ResolutionCustomDPI property will
determine the resolution.
● ResolutionPrinterToUse - the property used to get the resolution for the images based off a specific printer in the printer
list. This allows printing to a printer that is not the default. Invalid printer names passed into this function will be ignored.
A developer can retrieve the list of valid printer name string values by checking the installed printers collection. The
following C# code snippet loops through all installed printers on a machine and writes the names of the printers to the
console: *
foreach(string pkInstalledPrinters in PrinterSettings.InstalledPrinters)
{Console.Write("Installed printer name is " + pkInstalledPrinters + (char)10);}
● ShowText - if this value is yes or true, the human readable text will be displayed with the barcode.

http://www.idautomation.com/formscontrols/FormsControlManual.html (8 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

● ShowTextLocation - the human-readable text can be placed above or below the barcode. Default is below.
● TextMarginCM - the distance between the lower portion of the barcode and the text.
● TopMarginCM - the top margin in CM.
● UPCESystem - the encoding system to be used for UPC-E, valid values are 0 and 1.

Methods:

● SaveImageAs (filename as string, format as ImageFormat) - this method allows the barcode object to be saved as an
image such as JPEG, GIF, TIFF or PNG file. It also allows for conversion to any image type that the framework supports.
for example:
Barcode1.SaveImageAs("SavedBarcode.png", System.Drawing.Imaging.ImageFormat.Png) *
● RefreshPrinterDPI() - this method should be called every time the default printer has changed when printing with the
Picture method. When printing to a printer that is not the default, the ResolutionPrinterToUse property should be set first.
This sets Barcode.Resolutions.Printer to the printer's resolution. It is recommended that RefreshPrinterDPI() is called just
before each print job. We do not recommend calling RefreshPrinterDPI() every time the barcode itself is printed because
it takes about .5 seconds to execute. *

* This property or method is not supported when using the Compact .NET Framework Barcode Control due to current
limitations of the Compact Framework.

PDF417: Read the PDF417 FAQ for information about this symbology.
These properties are available only in the 2D version for idautomation.pdf417.dll. Related properties not mentioned here are the
same as in the Linear Control.

● ApplyTilde - if set to "true", you can use the format ~ddd to specify the ASCII code of the character to be encoded.
Default is on. Commonly used ASCII codes are ~009 for a tab and ~013 which is a return function.
● PDFColumns - controls the width and height by increasing the number of data columns in the PDF417 barcode. The
default is 0 and the maximum is 30. When this is left at 0, the control will automatically adjust this setting.
● PDFErrorCorrectionLevel - the Reed Solomon error correction level placed in the symbol. More error correction
creates a larger symbol that can withstand more damage. Default = 0 for automatic selection.
● PDFMode - the default, (binary mode) encodes bytes of data and text mode encodes all characters on the US keyboard
plus returns and tabs. If you are encoding only text, text mode can sometimes reduce symbol size.
● PDFRows - the number of minimum rows in the symbol. If this setting is left at 0 the control will automatically adjust
this setting. We recommend leaving this alone because the number of rows should be automatically generated.
● XtoYRatio - the X multiple height of individual cells; default=3, usually 2 to 4 times the XDimensionCM (X).

Methods:

● FontEncoder(string strDataToEncode, int ECCLevel, int NumColumns, int NumRows, bool truncated, PDFModes
inPDFMode, bool inTilde): returns a string value formatted specifically for the IDAutomation.com DataMatrix fonts.
The parameters are as follows:
❍ strDataToEncode: The data that should be formatted for the PDF417 fonts

❍ ECCLevel: The integer value representing the amount of error correction that should be applied to the data. A

value of 0 tells the function to figure out the optimum value. Other valid values are 1 - 8.
❍ NumColumns: The number of columns in the PDF417 barcode. A value of 0 tells the function to figure out the

optimum number of columns for the amount of data to be barcoded. Other valid values are 1 - 90.
❍ NumRows: The number of rows in the PDF417 barcode. A value of 0 tells the function to figure out the optimum

number of rows for the amount of data to be barcoded. Other valid values are 1 - 30.
❍ truncated: Determines if the stop bar and closing row should be eliminated from the barcode

❍ inTilde: True or false value indicating if the tilde character should be interpreted for special processing. See

ApplyTilde above for details concerning the tilde character

http://www.idautomation.com/formscontrols/FormsControlManual.html (9 of 16)24/11/2005 02:31:27 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Data Matrix: Read the DataMatrix FAQ for information about this symbology.
These properties are available only in the 2D version for idautomation.datamatrix.dll. Related properties not mentioned here are
the same as in the Linear Control.

● EncodingMode - the encoding mode that compresses information in the symbol; valid values are, E_ASCII, E_C40,
E_TEXT or E_BASE256 (default).
❍ ASCII: it is used to encode data that mainly contains ASCII characters (0-127). It encodes one alphanumeric or

two numeric characters per byte.


❍ C40: it is used to encode data that mainly contains numeric and upper case characters. C40 encodes three

alphanumeric data characters into two bytes.


❍ TEXT: it is used to encode data that mainly contains numeric and lowercase characters. TEXT encodes three

alphanumeric data characters into two bytes.


❍ BASE256: it is used to encode bytes of data and 8 bit values.

❍ More information about the modes is documented here.

● PreferredFormat (DM_FORMAT): sets the preferred format represented by a number; valid values are from 0 (10X10)
to 23 (144X144) and from 24 (8X18) to 29 (16X48); This will be automatically determined if the size of the symbol
chosen is too small. More about this is also documented here.
● ProcessTilde - if true ("Y") the tilde (~) will be processed. For example, you may use ~d032 for a space character, ~d009
for a tab and ~d013 to encode a return.
❍ ~dNNN: Represents the ASCII character encoded by the 3 digits NNN. For example, ~d065 represents the

character 'A'.
❍ ~1: Represents the character FNC1. When FNC1 appears in the first position (or in the fifth position of the first

symbol of a Structured Append), it will indicate that the data conforms to the UCC/EAN Application Identifier
standard format.
❍ More about the tilde formatting is documented here.

Methods:

● FontEncode(string strDataToEncode, bool blnProcessTilde, EncodingModes em, PreferredFormats pf): returns a


string value formatted specifically for the IDAutomation.com DataMatrix fonts. The parameters are as follows:
❍ strDataToEncode: The data that should be formatted for the DataMatrix fonts

❍ blnProcessTilde: True or false value indicating if the tilde character should be interpreted for special processing.

See ProcessTilde above for details concerning the tilde character


❍ em: The encoding mode to be applied to the data. This is an enumeration of the different encoding modes outlined

above in the EncodingMode bullet point


❍ pf: The size of the matrix that the data should be formatted for. This is an enumeration of the different formats

outlined in the PreferredFormat bullet point above

MaxiCode: Read the MaxiCode FAQ for information about this symbology.
These properties are available only in the 2D version for idautomation.maxicode.dll. Related properties not mentioned here are
the same as in the Linear Control.

When Maxicode is used for UPS applications, it is recommended that the input be a single complete string, formatted with the
specifications that UPS requires and using the ApplyTilde function to encode the RS, GS and EOT codes as recommended in our
Maxicode FAQ. For example:
[)
>~03001~02996336260000~029840~029002~0291Z14647438~029UPSN~029410E1W~029195~029~0291/1~029~029Y~029135Lightner
~029TAMPA~029FL~030~004

● ApplyTilde - if set to "true", you can use the format ~ddd to specify the ASCII code of the character to be encoded.
Default is on. Commonly used ASCII codes are ~029 for GS, ~030 for RS, ~004 for EOT, ~009 for a tab and ~013 which

http://www.idautomation.com/formscontrols/FormsControlManual.html (10 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

is a return function.
● EncodingMode - modes 2 and 3 are designed for use in the transport industry. They encode the destination address and
the class of service as defined by the carrier. Mode 4 can encode up to 93 characters or 138 digits. Mode 5 can only
encode up to 77 characters, but it provides more error correction capabilities than mode 4. Mode 6 indicates that the
symbol encodes a message used to program the reader system (scanner). Mode 2 is the default.

The following properties are only used in modes 2 and 3 and are ignored if the data begins with [)>RS01GS as explained here.

● CountryCode - a 3 digit number representing the country code.


● ServiceClass - a 3 digit number representing the service code.
● ZipCode - the postal code; mode 2 uses a 9 digit numeric postal code and mode 3 uses a 6 character alphanumeric postal
code.

MICR: The MICR control is used to print MICR E-13 on bank checks.
These properties are available only in the MICR control (idautomation.micrcontrol.dll) and the 2D version. Related properties
not mentioned here are the same as in the Linear Control.

● LeftMargin - the margin between the left of the control area and the beginning of the text measured in inches. The default
is .1.
● TopMargin - the margin between the top of the control area and the top of the text measured in inches. The default is .1.
● BMP_Image - a method that returns a read-only bitmap representation of the image.
● CharacterHeight - scales the height of each character in proportion to the optimum, default size of each character. For
example, setting this to 2 doubles the height.
● CharacterWidth - scales the width of each character in proportion to the optimum, default size of each character. For
example, setting this to .5 decreases the width by 50 %.
● CharacterSpacing - the number of inches between each character. The default is .06 inches to allow for the optimal 8
characters per inch threshold.
● PrintIntensity - the intensity or darkness of the characters. There are 3 values that range from darkest to lightest and they
are Maximum, Nominal, and Minimum.

When troubleshooting MICR print issues, please refer to our support incident about MICR

RSS, Composite & MicroPDF417 Symbology: Read the RSS and Composite Symbology FAQ or the MicroPDF417
FAQ for more information about these bar-code types.
Related properties not mentioned here are the same as in the Linear Control if applicable.

● CompositeData - the composite data to be encoded above the linear barcode. Not applicable when using PDF417 or
MicroPDF417.
● SymbologyID - this is the type of RSS or Composite barcode to be used. Please refer to the RSS FAQ and Tutorial for an
explanation of which symbology to use or contact EAN International or the UCC for assistance. There is an implied AI
encoded for RSS-14 of 01 that should not be part of the DataToEncode except when using RSS-14 Expanded. When using
RSS Expanded, the AI's must be entered manually to ensure the proper encoding method, for example: (01)
90012345678908(3103)012233(15)991231
● IncludeAIinHRText - true or false value that determines if the implied AI is displayed in the human readable text. An
RSS 14 barcode contains an implied AI of (01).
● InludeLinkageFlaginHRText - true or false (default is false) value that determines if the Linkage Flag for the barcode
should be displayed in the human readable text. This linkage flag determines if there is a 2D composite barcode to go
along with the linear RSS barcode.
● IsComposite - true or false (default is false) value that determines the linkage flag. The linkage flag tells the scanner
whether or not there is a 2D composite barcode associated with the barcode.

http://www.idautomation.com/formscontrols/FormsControlManual.html (11 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Properties in the RSS control specific to Composite, MicroPDF417 or PDF417:

● ApplyTilde - if set to "true", you can use the format ~ddd to specify the ASCII code of the character to be encoded.
Default is on. Commonly used ASCII codes are ~009 for a tab and ~013 which is a return function.
● PDFColumns - controls the width and height by increasing the number of data columns in the PDF417 barcode. The
default is 0 and the maximum is 30. When this is left at 0, the control will automatically adjust this setting.
● PDFErrorCorrectionLevel - the Reed Solomon error correction level placed in the symbol. More error correction
creates a larger symbol that can withstand more damage. Default = 0 for automatic selection.
● PDFMode - the default, (binary mode) encodes bytes of data and text mode encodes all characters on the US keyboard
plus returns and tabs. If you are encoding only text, text mode can sometimes reduce symbol size.
● XtoYRatio - the X multiple height of individual cells; default=3, usually 2 to 4 times the XDimensionCM (X).

Font encoder properties in the RSS control specific to Composite, MicroPDF417 or PDF417:

● FontEncoderPDF - the font encoder function to be used for PDF417, for code examples please refer to the PDF417 Font
FAQ- API Section or the example provided in the ZIP file of the purchased version.
● FontEncoderMicroPDF - the font encoder function to be used for MicroPDF417, for code examples please refer to the
PDF417 Font FAQ- API Section or the example provided in the ZIP file of the purchased version.

Symbology specific notes

UPC-A, UPC-E, EAN-8 and EAN-13


Enter the data to be encoded without any spaces or dashes. You can enter the +2 and +5 add-on codes by just adding them to the
end of the string. If the check digit is added, it will be ignored and regenerated to ensure that the code can be scanned. If you
rotate the barcode by 270, you may need to increase the top margin. For UPC-E, you must enter the full 11 or 12 digit UPC-A
code and the barcode will be compressed if possible.

POSTNET and PLANET


When using the POSTNET barcode, the XDimensionCM (Narrow Bar Width) of .05 CM should be used. For barcodes to be
acceptable to the US post offices, they must be between 22 and 24 bars per inch. Setting the XDimensionCM to .05 should
produce about 23 bars per inch. You should adjust this setting for your printer if your results are different.

Code 128
The "AUTO" setting for Code 128 will automatically switch character sets in the barcode as necessary. Our implementation of
Code 128 auto has many options as described below:

● Encoding functions such as tabs and returns in Code128:


If ApplyTilde is set to "true", you can use the format ~ddd to specify the ASCII code of the character to be encoded. For
example, Code~009Bar~013 will create a barcode that encodes Code<Tab Function>Bar<Return Function>. For other
functions, refer to the ASCII chart.
● Encoding UCC/EAN-128:
To encode alpha-numeric UCC/EAN-128, the character set is set to "AUTO" for automatic. Then, ASCII 202 or character
Ê is entered as the FNC1 before each AI and the required start C is also included. For example, the UCC number of (8100)
712345(21)12WH5678 should be entered as: Ê8100712345Ê2112WH5678. In most cases, the AIs will be properly
represented in the human readable text. If the parenthesis is not around the correct number for the AI, enter the following
extended ASCII character as the FNC1 for the correct number of digits in your AI:
ASCII 212 = 2 digits
ASCII 213 = 3 digits
ASCII 214 = 4 digits
ASCII 215 = 5 digits

http://www.idautomation.com/formscontrols/FormsControlManual.html (12 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

For example, to encode (1277)56, you would enter Ö127756.


● For more information about this, please refer to the UCC/EAN 128 section of our Code 128 FAQ or visit the UCC
website.

UCC128
This symbology option encodes an even number of number digits and includes the FNC1 character in set C as required. Use
Code 128 Auto to encode additional FNC1 codes or data containing text or odd numbers. Use the UCC128 function only for
UCC-128 applications where the input data is an even number such as in SSCC-18 and SCC-14 barcodes. For example, to
encode an SSCC-18 barcode, you would enter 00000123455555555558 as the data input. For more information, please visit here.

Using the Property Page DLLs

The .NET Forms Controls include an accompanying DLL that can be used for setting the properties of the component at run-
time. This DLL provides a direct visual interface for setting the properties of all IDAutomation .NET Forms Controls. Using the
Property Dialog DLL is as simple as adding 3 lines of code to your application. The following VB code snippet creates a
Property Dialog page for the control. This code snippet assumes that a barcode control named Barcode1 has already been created
in your .NET project. You will also need to add references to the associated PropertyDialog and NumberBox DLLs.

'Create the property page object. The constructor takes a barcode object and a Boolean value determining whether or not to display the
property tabs for captions
Dim p As New IDAutomation.Windows.Forms.LinearBarCode.frmBarcodeProperties(Barcode1, false)
p.showPropertyDialogBox(IDAutomation.Windows.Forms.supportedUnits.inch) 'show the property box with units in inches, use cm for
metric measurements
p.Dispose() 'clean up the object

Using the showPropertyDialogBox will produce a screen similar to the following:

The fields in these pages link directly to the properties associated with the control that was passed into the constructor.

http://www.idautomation.com/formscontrols/FormsControlManual.html (13 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Using the property page tabs individually:

The property pages for the control can be referenced and used individually in an application, if need be. It is not necessary to
work in the confines of the property page tabs themselves. Each tab has an accessor function that allows it to be added to any tab
control in your application. The following code snippet is an example of adding the tabs controlling the top caption and the color
of barcode to a tab control in an application. This example assumes that there is already a barcode component named Barcode1, a
tab control named tabControl1 and references to the associated PropertyDialog and NumberBox DLLs in your application:

IDAutomation.Windows.Forms.LinearPropertyPage.frmBarcodeProperties p = new IDAutomation.Windows.Forms.LinearPropertyPage.


frmBarcodeProperties(Barcode1, true );
tabControl1.TabPages.Add(p.get_ColorTabPage());
tabControl1.TabPages.Add(p.get_TopCaptionTabPage());
p=null;

Using the .NET Compact Framework Version of the Linear Barcode Control

NOTE: At this time we only have the Compact Framework Control available in the Linear version. If you need the Compact
Framework Control for another barcode type, please contact us.

There are two components necessary when creating an application for the .NET Compact Framework (CF). A design time
component (IDAutomation.design.LinearBarcodeControl.dll), which can use all of the functionality of the full .NET Framework,
and a run-time component (IDAutomationCFLinear.dll), which uses only functionality allowed by the Compact Framework. The
two components can be found in the CompactFramework folder of the zip file that was downloaded.

Before the controls can be used in your CF application, they must be placed in specific locations so that the Visual Studio IDE
can find them. Once the DLL's have been copied to the correct locations, they can be referenced in your application. The
following steps outline the process for setting up your environment to use our Compact Framework control.

1. Copy the designer version of the control, IDAutomation.design.LinearBarcodeControl.dll, from the zip folder
directory to "C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE
\Designer". This is the location that the Visual Studio IDE looks for components for the Device Controls section of the
Toolbox.
2. Copy the run time version of the control, IDAutomationCFLinear.dll, to "C:\Program Files\Microsoft Visual Studio .
NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE\". This is the location where the Visual Studio IDE looks for
the DLL that will be copied to the target device or PocketPC emulator.
3. Add the control to a Smart Device Application project in Visual Studio.NET
4. If the Toolbox is not visible in your application, select View | Toolbox from the main Visual Studio.NET menu
5. Find the section in the Toolbox entitled Device Controls. Right click the Toolbox and choose Add/Remove Items. A
screen similar to the figure below will appear:

http://www.idautomation.com/formscontrols/FormsControlManual.html (14 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

6. Click the "Browse" button and navigate to the location where the designer version of the control was copied to, "C:
\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\WindowsCE\Designer", select
IDAutomation.design.LinearBarcodeControl.dll, click "Open", then click "OK" on the Customize Toolbox dialog.
7. The control should appear on the Toolbox as illustrated below:

8. Before dragging the control on to a form, a reference must be set to the run-time version of the control so that it is copied
to the target device or emulator. This is done from Solution Explorer. If Solution Explorer is not visible, click View |
Solution Explorer. Right click "References" in Solution Explorer. Click "Add Reference".

9. On the Add Reference dialog click "Browse". Navigate to the location of the run time version of the control "C:\Program
Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE", select
IDAutomationCFLinear.dll and click "Open". Click "OK" on the Add Reference dialog

The control is now available to be used in your Compact Framework application. The image below displays an example of a
simple Compact Framework application for displaying barcodes on a PocketPC. Consult your MSDN documentation for ways to
print, save, and display the bitmap image associated with the Linear Barcode Control for the Compact Framework.

http://www.idautomation.com/formscontrols/FormsControlManual.html (15 of 16)24/11/2005 02:31:28 p.m.


Dotnet Linear Barcode Windows Forms Control Tutorial & Manual

Technical support

To obtain technical support for this product, please visit the Dotnet Windows Forms Technical Support Site.

You may also view our product index to obtain a list of all products we offer.

Product Links: [Barcode Fonts | Barcode Components | Barcode Label Software | Barcode Scanners]

Copyright © 2000-2005 IDAutomation.com, Inc. IDAutomation and BizFonts are registered


trademarks of IDAutomation.com, Inc. All other trademarks mentioned are the property of their
respective owners.

Over 70% of Fortune 100 companies use our products to automate their businesses.

http://www.idautomation.com/formscontrols/FormsControlManual.html (16 of 16)24/11/2005 02:31:28 p.m.

Anda mungkin juga menyukai