| ||||||||
| ||||||||
| ||||||||
Home: Products: Barcode Components: Windows .NET Forms Controls: User Manual | ||||||||
INDEX:
It is important to have the ability to test printed barcodes with a barcode
scanner.
If a scanner is not available for testing purposes, IDAutomation
also provides high quality
complete barcode scanner kits.
Application Compatibility
IDAutomation's Barcode .NET Forms Controls are compatible with Microsoft C#, VB .NET, Borland Delphi for Microsoft .NET, C# Builder, Visual Studio and the .NET Framework 1.0 or greater. They are used to create MICR and barcode images that may be saved to a file or sent to a printer on a local PC. This product is not designed to be used with compact framework applications or web applications; for these purposes, the Compact Framework Controls for the PocketPC or the ASP.NET Web Component for web applications should be used. The RFID control provided in the linear package is compatible with the .NET Framework 2.0 or greater.
|
Installation
Registering the Control in Microsoft® Visual Basic .NET and Microsoft C# .NET:
Registering the Control in a Borland Delphi for Microsoft .NET or C# Builder:
.NET Forms Control Tutorial and Source Code Examples |
Once installed, several different methods may be used to size, print and create barcode images.
Sizing the Control:
The control cannot be sized by dragging the object because barcodes 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 barcode width, increase the XDimension property. To increase the height, increase the BarHeight property.
Printing from the Control:
Example of Printing a Barcode from Visual Basic .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
prndoc.DocumentName = "Printing the IDAutomation.com 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 PrintPageEventArgs)
Dim grfx As System.Drawing.Graphics = ppea.Graphics
grfx.PageUnit = GraphicsUnit.Millimeter
grfx.PageScale = 1.0F
grfx.DrawString(Me.Text, Me.Font, Brushes.Black, 0, 0)
grfx.DrawString("IDAutomation.com Example", New Font("Arial", 10), New SolidBrush(Color.Black), 20, 90)
Barcode1.PaintOnGraphics(grfx, 0, 200) ' Note: if PaintOnGraphics does not exist in the DLL being utilized*
End Sub
Example of how to Print the Barcode from C#.NET:
private void button1_Click(object sender, System.EventArgs e)
{
System.Drawing.Printing.PrintDocument prndoc = new System.Drawing.Printing.PrintDocument();
prndoc.DocumentName = "Printing a Barcode";
prndoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintDocumentOnPrintPage );
prndoc.Print();
}
private void PrintDocumentOnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ppea )
{
Graphics grfx = ppea.Graphics;
grfx.DrawString(this.Text, this.Font, Brushes.Black, 0, 0);
Barcode1.PaintOnGraphics(grfx, 0, 200); // Note: if PaintOnGraphics does not exist in the DLL being utilized*
return;
}
Example of how a Metafile may be Sent to a PictureBox in VB .NET:
Private Sub cmdDisplayMetafile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDisplayMetafile.Click
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
Example of how to Print a Bar Code from 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;
}
Example of Dynamically Placing the Control on a Form:
The following is an example of 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
Example of 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
Example of Using the Control as a DLL or in a Web Service
Application:
(creates a
barcode image without installing it on a form)
NOTE: for web
services, IDAutomation recommends the Barcode XML Webservice
Component
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
Example of Creating JPEG, TIFF, GIF, BMP, PNG or other Graphic Files:
Since IDAutomation's control uses the .NET framework to perform image conversion, a barcode image in any format can be created that .NET supports in System.Drawing.Imaging.ImageFormat.
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
Example of Copying Barcodes to the Clipboard:
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
Properties and Methods | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. This section explains the main configuration properties and methods of the linear control. For advanced properties, please refer to the API Documentation. | ||
Name | Default | Description |
ApplyTilde | False | When true in Code 128 with the Auto character set, the format ~??? may be used to specify the ASCII code of the character to be encoded and several other tilde options are enabled. For example, the data of "ITF~d009Barcode39" would encode "ITF <TAB> Barcode39". |
BackColor | Transparent | The background color of the barcode canvas. |
BarHeightCM | 1 | The height of the barcode in centimeters (CM). |
BearerBarHorizontal | 0 | The width of the horizontal bearer bars as a multiple of the XDimension; valid options are 0-10. |
BearerBarVertical | 0 | The width of the vertical bearer bars as a multiple of the XDimension; valid options are 0-10. |
CaptionAbove | Null | When text appears in this property, it is displayed in the margin above the symbol. |
CaptionBelow | Null | When text appears in this property, it is displayed in the margin below the symbol. |
CharacterGrouping | 0 | Determines the number of characters between spaces in the text interpretation of the data encoded in the barcode. Supported values are 0 (which disables grouping), 3, 4 and 5. |
CheckCharacter | True | AddCheckDigit automatically adds the check digit to the barcode when true. 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, the check digit may be disabled. |
CheckCharacterInText | False | AddCheckDigitToText automatically adds the check digit that is encoded in the barcode to the human readable text that is displayed when true. |
CodabarStartCharacter | A | The Start Character in the Codabar barcode. |
CodabarStopCharacter | B | The Stop Character in the Codabar barcode. |
Code128CharSet | Auto | The set of characters to be used in Code128. Valid values are: Auto, A, B or C. IDAutomation recommends using Auto. |
DataToEncode | 123456789012 | The data that is to be encoded in the barcode. |
FitControlToBarcode | True | Automatically sizes the control canvas to fit the barcode at design or runtime. |
Font | Sans Serif 8.25 Points |
Used to change the font or font point size of the text interpretation or human readable text. |
ForeColor | Black | The color of the foreground text and bars in the barcode. |
LeftMarginCM | 0.2 | The space of the left margin in centimeters. |
NarrowToWideRatio | 2.0 | The wide to narrow ratio of symbologies that only contain narrow and wide bars such as Code 39, Interleaved 2 of 5 and MSI. Common values are 2, 2.5, 2.75 and 3. |
Resolution | Printer | The source that is used to determine the resolution the image is drawn to, which creates a more accurate barcode. Default is set to printer. If custom option is selected, the number residing in the ResolutionCustomDPI property will determine the resolution. |
ResolutionPrinterToUse | Null | 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 may 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);} |
RotationAngle | Zero_Degrees | Orientation indicates the orientation of the barcode. Valid values are Zero_degrees, Ninety_Degrees, One_Hundred_Eighty_Degrees and Two_Hundred_Seventy_Degrees. |
ShowText | True | When ShowText is "True," the human readable text will be displayed with the barcode. The setting of "False" disables this option. |
ShowTextLocation | Bottom | Determines if the human-readable text is placed above or below the barcode. |
SuppSeparationCM | 0.5 | The distance between the end of the barcode and the beginning of the supplement for UPC/EAN symbologies. |
SymbologyID | Code128 | The symbology or barcode type. To obtain more information about barcode types, visit the bar-coding for beginners site. |
TextMarginCM | 0.10 | Sets the distance between the symbol and the text in centimeters. |
TopMarginCM | 0.2 | The top margin in centimeters. |
UPCESystem | 0 | The encoding system to be used for UPC-E; valid values are 0, 1, and Auto. |
WhiteBarIncrease* | 0 | A percentage value to increase the white space between the bars to improve readability. Common values are 10, 15, 20 and 25. * |
XDimensionCM | 0.03 | The width in centimeters of the narrow bars. The X dimension should be increased if the barcode scanner being used does not dependably decode the symbol. |
XDimensionMILS | 11.8 | The width in mils (1/1000 of an inch) of the narrow bars. The X dimension should be increased if the barcode scanner being used does not dependably decode the symbol. |
Image Processing Properties and Methods | ||
BMPPicture | Returns a bitmap image. For example: myBitMapImage = Barcode1.BMPPicture. | |
DrawImage(Graphics used to draw with, X Offset, Y Offset) | Draws a barcode image based on the current resolution. | |
IndependentEMF | Returns a device independent metafile image. For example: myImage = Barcode1.IndependentEMF. | |
PaintOnGraphics (Graphics used to draw with, X Offset, Y Offset) | Efficiently paints the image based on the resolution of the selected printer. This is the method used in IDAutomation's Barcode Label Software; it is the most efficient method of printing multiple barcode images. | |
Picture | Used to retrieve an enhanced metafile image that is calculated according to the Resolution. | |
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 according to the
Resolution.
It also allows for conversion to any image type that the .NET framework
supports. For example: Barcode1.SaveImageAs("SavedBarcode128.png", System.Drawing.Imaging.ImageFormat.Png) | |
RefreshPrinterDPI() | This method has been replaced by PaintOnGraphics and is provided for backward compatibility only. This method may 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. However, do not call RefreshPrinterDPI() every time the barcode itself is printed because it takes time to determine the value from the printer and print driver. |
PDF417 Specific Properties: | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. | ||
Name | Default | Description |
ApplyTilde | True | When true, the format ~??? may be used to specify the ASCII code of the character to be encoded. |
PDFErrorCorrectionLevel | 0 | The Reed Solomon error correction level encoded in the symbol. More error correction creates a larger symbol that can withstand more damage. The default setting of 0 performs automatic selection. |
MacroPDFEnable | False | When true, indicates that this barcode is part of a MacroPDF sequence. |
MacroPDFFileID | 0 | Assigns a file id to the MacroPDF barcode. Each barcode in the MacroPDF sequence must have the same file id assigned to it. Valid options are 0-899. |
MacroPDFSegmentIndex | 0 | The index number of each MacroPDF symbol must have a unique segment index, starting at zero and incrementing thereafter by one. |
MacroPDFLastSegment | False | When true, indicates that this is the final barcode in the MacroPDF sequence. |
PDFColumns | 0 | The number of data columns in the PDF417 barcode. The default is 0 and the maximum is 30. |
PDFMode | Binary | The mode of compaction used to encode data in the symbol. When set to "Text," a smaller symbol may be created. Text mode encodes all characters on the US keyboard plus returns and tabs. |
PDFRows | 0 | Sets the number of rows. It is recommended to leave this setting at 0, the default. |
Truncated | False | A truncated PDF417 symbol is more area efficient than normal PDF417. When true, the right hand side of the PDF417 is removed or truncated. |
XtoYRatio | 3 | The X multiple height of individual cells; default = 3, usually 2 to 4 times the NarrowBarCM (X). |
Data Matrix Specific Properties: | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. | ||
Name | Default | Description |
ApplyTilde | True | When true, the tilde (~) will be processed as explained in the DataMatrix FAQ and the format ~d??? may be used to specify the ASCII code of the character to be encoded. For example, "ECC200~d009Code128" encodes "ECC200 <TAB> Code128." |
EncodingMode | E_BASE256 | Valid Encoding Mode values are E_ASCII, E_C40, E_TEXT or E_BASE256. |
LeftMarginCM | 0.10 | The left and right margin of the symbol in centimeters. |
PreferredFormat | Auto | Sets the preferred format; valid values are from 0 (10X10) to 23 (144X144) and from 24 (8X18) to 29 (16X48); the default value of "Auto" is used for automatic formatting. |
TopMarginCM | 0.10 | The top and bottom margin of the symbol in centimeters. |
XDimensionCM | 0.06 | The width in centimeters of the narrow bars. This value may need to be increased if the scanner cannot read barcodes with small X dimensions. When working with a high quality imager, this value may be decreased to create a smaller symbol. |
MaxiCode Specific Properties: | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. | ||
Name | Default | Description |
ApplyTilde | True | When true, the format ~??? may be used to specify the ASCII code of the character to be encoded as explained in the Maxicode FAQ. A setting of "False" will disable ApplyTilde. |
CountryCode | na | A 3-digit number representing the country code. Proper implementation for UPS and other transportation applications will automatically override this field. |
EncodingMode | Mode2 | The mode of compression and encoding used in the symbol. Modes 2 and 3 are designed for use in the transport industry. Mode 4 encodes up to 93 characters or 138 digits. Mode 5 encodes up to 77 characters and provides more error correction capabilities than mode 4. Mode 6 indicates that the symbol encodes a message used to program a reader system (scanner). |
ServiceClass | na | A 3 digit number representing the service code. Proper implementation for UPS and other transportation applications will automatically override this field. |
ZipCode | na | The postal code; mode 2 uses a 9-digit numeric postal code and mode 3 uses a 6 character alphanumeric postal code. Proper implementation for UPS and other transportation applications will automatically override this field. |
Aztec Specific Properties: | ||
ApplyTilde | True | When set to "True," the format ~d??? may be used to specify the ASCII code of the character to be encoded. Commonly used ASCII codes are ~d009 which is a tab function and ~d013 which is a return function. |
MessageAppend | na | Specifies the message appended across multiple symbols. Only valid if NumberOfSymbols is greater than 1. |
NumberOfSymbols | 1 | Invokes MessageAppend across # symbols |
XDimensionCM | 0.06 | The width in centimeters of the narrow bars. This value may need to be increased if the scanner cannot read barcodes with small X dimensions. When working with a high quality imager, this value may be decreased to create a smaller symbol. |
GS1 DataBar (RSS), Composite & MicroPDF417 Properties: | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. | ||
Name | Default | Description |
ApplyTilde | False | When true, the format ~??? may be used to specify the ASCII code of the character to be encoded. |
CompositeData | Null | The composite data to be encoded above the linear barcode; however, not applicable when using PDF417 or MicroPDF417. |
IncludeAIinHRText | True | When true, the implied AI is displayed in the human-readable text. DataBar-14 contains an implied AI of (01). |
InludeLinkageFlagin HRText |
False | When true, the Linkage Flag for the barcode is displayed in the human readable text. The linkage flag determines if there is a 2D composite barcode to go along with the linear DataBar barcode. |
IsComposite | False | True or false value that determines the linkage flag. The linkage flag informs the scanner whether or not there is a 2D composite barcode associated with the linear barcode. |
PDFErrorCorrectionLevel | 0 | The Reed Solomon error correction level encoded in the symbol. More error correction creates a larger symbol that can withstand more damage. The default setting of 0 performs automatic selection. |
PDFColumns | 3 | The number of data columns in the PDF417 barcode. The default is 3 and the maximum is 30. |
PDFMode | Text | The mode of compaction used to encode data in the symbol. When set to "Text," a smaller symbol may be created. Text mode encodes all characters on the U.S. keyboard, plus returns and tabs. |
SymbologyID | Code128 | This is the type of symbology to be used. When using DataBar (RSS), the data must be formatted according to the IDAutomation GS1 DataBar & Composite FAQ. |
XtoYRatio | 2 | The X multiple height of individual cells; the acceptable range is 2 to 5. |
MICR Control Properties: | ||
IDAutomation recommends using default values for all properties, unless requirements dictate otherwise. | ||
Name | Default | Description |
CharacterSpacing | 0.011 | Sets the number of inches between each character. This property should be adjusted to 8 characters per inch. |
PrintIntensity | Nominal | This sets 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 used with low-resolution devices such as the display screen, changes in the WhiteBarIncrease property value may not be visible in the control itself. However, the change will usually only be visible when printed, if a printer with 300 dpi or greater is used.
Property Page Forms |
'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
'Show the property box with units in inches, use cm for metric
measurements
Dim p As New
IDAutomation.Windows.Forms.LinearBarCode.Barcode(True)
p.ShowPropertiesDialogBox(IDAutomation.Windows.Forms.LinearBarCode.PropertyPage.supportedUnits.inch)
p.Dispose()
'clean up the object
Using Property Page Tabs Individually:
The property pages for the control may be referenced and used individually in
an application. 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 the 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 the
application:
tabControl1.TabPages.Add(p.get_ColorTabPage());
tabControl1.TabPages.Add(p.get_TopCaptionTabPage());
p=null;
Technical Support: |
Free product support may be obtained by reviewing articles that are documented at the .NET Windows Forms Support Site and by searching the resolved public help desk issues. Priority phone, e-mail and help desk support is provided up to 30 days after purchase. Additional priority phone, e-mail and help desk support may be obtained if a Priority Support and Upgrade Subscription is active.
Common Problems and Solutions:
Related Products and Information: |
The following product and information links relate to this product and may be of interest:
|
Product Quick Links: [Barcode Fonts | Font Tools | Components | Label Software | Scanners | Printers | RFID | Product Index] |
© Copyright 2000-2008 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses. |