Tutorial

BarCode/ASP allows you to use barcodes in three ways:

- Dynamic JPEG Image
- Dynamic PNG Image
- Scripting

Other topics that you may need to be aware of:

- Barcode Size and Printer Resolution
- Threading Model

Dynamic JPEG Image

You can use dynamic barcode JPEG images in any HTML pages and this doesn't require any scripting. Simply embed, for example,
	<img src="barcode.asp?image=3&type=6&data=12345678">
in your HTML file and, voila, you have a Code 39 barcode image that's dynamically generated.

The advantage of the JPEG image format is that it's supported by virtually all commercial grade browsers in all their versions.

It's well-known that JPEG uses lossy image compression. BarCode/ASP generates JPEG with high quality (and low compression). The result is fairly good. However, you may see background noises when printing using Netscape; we think that's because Netscape adopts a low quality decompression approach (yes, like compression, you can specify a quality parameter for decompression, too). Fortunately, our tests show that the result is still scannable in our test conditions (300 dpi laser printer).

Dynamic PNG Image

BarCode/ASP also generates barcode images in PNG format, in addition to JPEG. You use PNG image generation the same way you JPEG. For example, the following HTML mark-up will generate a barcode image in PNG format:
	<img src="barcode.asp?image=1&type=6&data=12345678">
Unlike JPEG, PNG uses lossless image compression and gives you high quality images. The only drawback is that PNG is only support by recent browsers (i.e., IE 4.0 or later and Netscape 4.04 or later). If you're target these browsers, we highly recommend you PNG image format.
Why Not Supporting GIF?
GIF is not supported for legal reasons. We'll support GIF when there's enough demand for it. In fact, any web site operators who use GIF generation software on their web site would need to pay a substantial amount of royalties to Unisys Coporation ($5000 as of the time this product was being made as we were told). In addition, we would also need to pay Unisys an up-front fee.

Barcodes Thru Scripting

BarCode/ASP also allows you to create barcode HTML markup via server-side scripting that involve multiple (small) images (in gif format), each of which represents a barcode bar or space.

To ask BarCode/ASP to generate the sequence for you, just call the GetHTML2 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 Size and Printer Resolution

The minimum barcode width on the screen is given by the NumModules property. The barcode width can only be a multiple (1, 2, etc.) of this minimum width. You can change the scale factor when using barcode.asp, e.g. <img src=barcode.asp?barwidth=2> will use a scale factor of 2; if you script the BarCode/ASP component directly, you can set this scale factor in MakeImage, SaveImage, GetHTML2 or 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.

If you find the barcode size too big, you can specify a WIDTH attribute value for the <IMG> tag. This does not compromise the intrinsic barcode image quality as it comes down from the server; the image is simply scaled back at display time.

Threading Model

If you have to script BarCode/ASP directly, you need to know it 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.