Using BarCode/ASP
Threading Model
The BarCode Active Server Component uses the apartment threading model,
which means that it can be used at the ASP Page and Session object
level but not at the Application object level. Typically, you would create
a BarCode object in an ASP page and delete it before the page goes
out of the scope (or has it deleted automatically if the variable holding
the object is a page level variable). To delete the object explicitly, you
would do:
set barcode = nothing
assuming barcode
is the variable holding the object.
How a BarCode Is Drawn
BarCode/ASP does not create a barcode image (i.e., gif, jpeg) dynamically.
Rather, it generates (or allows you to generate) a sequence of HTML IMG tags
representing the barcode bars and spaces. The image SRC of these IMGs will
be, by default, "black.gif" and "white.gif", which are part of the product.
These two images are and need only be one pixel big.
You can change the images though the ForeImageURL
and BackImageURL properties.
To ask BarCode/ASP to generate
the sequence for you, just call the GetHTML
method, as demonstrated by Sample 1
and Sample 2.
You can also generate the sequence yourself in scripting languages.
You'll need then to call the EnumBarStart
and EnumBarNext methods to get the positions
and widths of the barcode bars. Sample 3
demonstrates this.
Barcode Types and Data
Barcode type can be changed using the BarcodeType
property, main data using the Data property,
and add-on data (if any) using the AddOnData
property. You must change the barcode type before everything else.
Barcode type constants are defined in the VBScript include file
ezbarvbs.inc
, which you can include in your ASP file
by doing, for example,
<!-- #include file="ezbarvbs.inc" -->
assuming ezbarvbs.inc
has been copied to the same
directory where the ASP file is.
Barcode Size and Printer Resolution
The minimum barcode width on the screen is given by the
NumModules property. The barcode width
can only be multiple (1, 2, etc.) of this minimum width; you can
set this scale factor in GetHTML
and EnumBarStart. While different bar
widths are in proportion on the screen, the printed version may
be different. The higher the printer resolution, the better the result
is. If the printer resolution is low, you may need to use a scale
factor of 2 or higher, so that the printed barcode is scannable.
Note that this is different from applications using directly
BarCode/OCX
or DLL, in which case the barcode component has the
opportunity of tuning the barcode directly according to the
destination printer resolution.