Microsoft
Visual C# .NET Integration Guide
IDAutomation provides a variety of solutions for integrating
barcodes into Visual C# .NET with flexible license agreements such as Single
User Licenses, Multi-User Licenses and royalty-free Developer Licenses. Please
review the integration chart below to determine the solution that best fits your
needs.
|
Integration Options |
Advantages
and Disadvantages |
Product:
Code39
Barcode Fonts
Single Users From $139
Developers From $395
Supported:
  |
- The easiest option when the specific
barcode type is not important and the data consists of numbers
and/or uppercase letters.
- Data is easily formatted to the barcode font by appending
asterisks to the beginning and ending of the data being
encoded
- No DLLs or source code needed.
|
Product:
.NET
Forms Controls
Developers From $395
Supported:
 |
- Created exclusively for .NET Windows Applications.
- Generates graphic barcode images without fonts.
- Supports several linear and 2D barcode types such as Intelligent Mail,
PDF417, Data Matrix and Maxicode.
- Includes VB.NET source code for the Barcode Image Generator.
- DLLs provided are signed and time-stamped with Verisign
Authenticode Certificates.
|
Product:
ASP.NET
Web Server Controls
Developers From $395
Supported:
 |
- Created exclusively for ASP.NET Web Applications.
- Generates graphic barcode images without fonts as an
ASP.NET server control in Visual Studio.
- Supports several linear and 2D barcode types including Intelligent Mail, PDF417,
Data Matrix and Maxicode.
- Compiled in C# Dotnet for speed.
- DLLs provided are signed and time-stamped with Verisign
Authenticode Certificates.
|
Product:
Barcode
Fonts
Tool: C# Class File
Single Users From $139
Developers From $395
Supported:
  |
- Easily integrates into projects without the need
for additional DLLs.
- Supports many linear barcode types.
- C# source code included.
- Methods in the class file and source
code calculate the start, stop and check digits and return a character
string that create a readable barcode when used in conjunction with IDAutomation
barcode fonts.
|
Product: Barcode
Fonts or
Universal
Barcode Font
Tool:
Native Windows DLL
Single Users From $139
Developers From $395
Supported:
  |
- Supports many linear barcode types.
-
Methods in the Barcode DLL calculate the star, stop
and check digits and return a character string that creates a readable barcode
when used in conjunction with IDAutomation barcode fonts, including the
Universal Barcode Font.
- Universal Barcode Font creates multiple barcodes as a single font
on multiple operating systems and locales, including Double
Byte versions of Windows such as those used in China and
Japan as well as other Asian locale settings.
- C++ source code for the
Universal Barcode Font DLL may be provided with the purchase of
a
Developer License and a signed
Source Code Agreement.
|
Product: PDF417 Font
and Encoder or Data
Matrix Font and Encoder
Tool: ActiveX or .NET Forms Control Encoders
Provided
Developers From $895
Supported:
 
|
- Many different 2D barcode encoders are provided for
a single symbology in the PDF417 and Data Matrix Font and Encoder packages, including 100%
managed code .NET encoders.
- Includes the applicable
.NET Forms Control and
ActiveX Barcode Control.
|
Product:
ActiveX Controls
Single Users From $199
Developers From $395
Supported:
 |
- Supports several linear and 2D barcode types such as Intelligent Mail, PDF417,
Data Matrix and Maxicode.
- All DLLs provided are signed and time-stamped with Verisign
Authenticode Certificates.
- May also be used in Access, Excel, Infopath, VB and
many other applications.
|
IDAutomation.cs Class Barcode Integration Tutorial
The
C# IDAutomation.cs class file combines the encoding and
printing of barcodes into one object. This class may be used as a template
for C# barcoding needs. The class encodes data into the appropriate
symbology format and sends the barcoded string to the default printer.
It is important that the appropriate IDAutomation fonts are installed before calling the print method of
the class.
-
Download the IDAutomation C# barcode class file and save it to the local hard drive.
The file should be saved in the C# .NET project directory where the project
lives.
- Open the Visual Studio C# .NET project.
- To use the printing features of the IDAutomation.com
class, ensure that a reference to the System.Drawing namespace exists
in the C# solution. To include the System.Drawing namespace
- Click Project | Add Reference from the VS.NET IDE menu
- On the .NET tab, locate and select the component name System.Drawing.dll
- Click the Select button
- Click the OK button
- Add the IDAutomation.cs file to the project
- Click Project | Add Existing Item from the VS.NET IDE menu
- Navigate to the location where you saved the downloaded
IDAutomation.com class file
- Select IDAutomation.cs from the list and click Open
- Include the IDAutomation_FontEncoder namespace to the solution.
For example:
using IDAutomation_FontEncoder;
- Once the reference to the IDAutomation_FontEncoder
namespace is added to the C# solution, the bar code object may be
instantiated, for example:
clsBarCode IDAutomationBarcodeObject = new clsBarCode();
where IDAutomationBarcodeObject
is the name for the instance of this object. When
finished using the object, it is recommended to destroy
it to free memory. Example:
IDAutomationBarcodeObject = null;
- Use the methods associated with the barcode object from the
chart below. Methods in the class take a string as an input value,
add the appropriate start and stop characters of the selected symbology,
add the checksum character (if required by the symbology), and encode
the data to the format of the symbology. The class also includes
a print method that will take the encoded data, font type, and font
size as input values and print the barcode to the default printer
for the computer. The following table provides a detailed outline
of each method.
|
Method Name |
Font to Use |
Purpose |
| Code128(DataToEncode) |
IDAutomationC128 |
The recommended
and primary Code 128 method that will automatically encode any
data from ASCII 1 to ASCII 127. This method
contains many options. |
| Code128a(DataToEncode) |
IDAutomationC128 |
Code 128 character
set A. |
| Code128b(DataToEncode) |
IDAutomationC128 |
Code 128 character
set B. |
| Code128c(DataToEncode) |
IDAutomationC128 |
Code 128 character
set C. |
| Code128HR(DataToEncode) |
Text Font |
Returns the
human readable version of the data used in the Code128(DataToEncode)
method. |
| Interleaved2of5(DataToEncode) |
IDAutomationI25
or
IDAutomationHI25 |
Formats the
return string to the Interleaved 2 of 5 font. |
| Interleaved2of5Mod10(DataToEncode) |
IDAutomationI25
or
IDAutomationHI25 |
Performs the
mod10 checksum calculation for increased accuracy and formats
the return string to the Interleaved 2 of 5 font. |
| Code39(DataToEncode) |
IDAutomationC39
or
IDAutomationHC39 |
Formats the
output to print using Code 39 fonts. |
| Code39mod43(DataToEncode) |
IDAutomationC39
or
IDAutomationHC39 |
Performs the
mod43 checksum calculation for increased accuracy and then formats
the output to print using Code 39 fonts. The mod43 checksum
is usually required for LOGMARS and HIBC applications. |
| Codabar(DataToEncode) |
IDAutomationCB |
Formats the
output to print using Codabar fonts. |
| EAN13(DataToEncode) |
IDAutomationUPCEAN |
Enter EAN-13
with or without a check digit, add-ons are supported. If a check
digit is passed in it is ignored, recalculated, and added to
the encoded output. Formats output to the UPC/EAN barcode font. |
| EAN8(DataToEncode) |
IDAutomationUPCEAN |
Formats output
to the UPC/EAN barcode font. Enter exactly 7 characters (EAN-8
without the check digit). |
| MSI(DataToEncode) |
IDAutomationMSI |
Formats data
to the MSI font. |
| POSTNet(DataToEncode) |
IDAutomationPOSTNET
or
IDAutomationPLANET |
Enter a single
string of Zip, Zip + 4 or Zip + 4 + Delivery Point. The input
for this method must be a number and may include dashes and
spaces. |
| PrintBarCode(FontName,
DataToEncode, FontSize) |
na |
A print routine
that combines the encoded data, the name of the font, and the
font size as input parameters then sends the barcode to the
default printer. |
| UPCA(DataToEncode) |
IDAutomationUPCEAN |
Enter UPC-A
with or without a check digit, add-ons are supported. Formats
output to the UPC/EAN barcode font. |
Using The ActiveX Control Within a C# Application
The IDAutomation ActiveX Barcode Control allows generation of Windows
Enhanced Metafile barcode images and printing from Visual Studio.NET.
- Purchase
or download
and install the Barcode ActiveX Control.
- Open the project and choose Project - Add Reference.

- Select the IDAutomation ActiveX Barcode Control from the COM
components tab of the reference list. Click Select. Click OK.

- The following code examples use the IDAutomation Linear Barcode
ActiveX Control in the object named axBarCode1:
To print to the default printer, initiate the Print event of the
.NET PrintDocument object and call the DrawImage method of the .NET
Graphics object. Insert the following lines into the code at the
point in which you would want to initiate the printing of the image
e.g. in the click event of a command button:
//Create a PrintDocument
object
PrintDocument pd = new PrintDocument();
//set and create the EventHandler for printing the page.
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
//This will fire off the print page event
pd.Print();
Add an Event Handler method to the solution, which is called
prior to printing, that tells the printer what to print:
//The PrintPage
event is raised for each page to be printed.
void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
//Initialize the vertical position variable
of the graphic on the page
int yPos = 100;
//Initialize the left margin of the page
int leftMargin = ev.MarginBounds.Left;
//Print the enhanced metafile image of
the bar code
ev.Graphics.DrawImage(axBarCode1.GetEnhWMF(),
leftMargin, yPos);
}
An image may also be saved the to a local hard drive with
the following code:
//Preface the string variable with the @ sign, so that Windows does
not interpret the drive path as an escape sequence
string SaveLoc = @"C:\temp\SavedBarCodeImage.wmf";
this.axBarCode1.SymbologyID = 13;
this.axBarCode1.SaveBarCode(SaveLoc);
Copying the image to the clipboard is supported with The
IDAutomation .NET Barcode Forms
Controls.
|