The Barcode Object has a number of properties which may be set to specify characteristics of the barcode required, and these are described in detail in the reference section. The object also has three properties which may be read to form the barcode image: PictureHeight and PictureWidth (which specify the sizes of the image) and the Pic() property which is a Variant that can be used to display the image in a web browser.
A minimal sample (which just creates a fixed barcode) would be as shown below, and several sample pages are included in the "samples" subdirectory of the product's installation directory. There are three basic coponents:
1. GLOBAL.ASA
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Dim vntStream
Sub Session_OnStart
Set Session("m_barcode") =
Server.CreateObject("B1barcode.Control")
Session("m_barcode").Serial=”12345”
Session("m_barcode").CodeType=0
Session("m_barcode").Xunit=20
Session("m_barcode").ImageHeight=2000
</SCRIPT>
2. BARCD.ASP
This is a simple file that contains the code to return the image at the point it is required. The file content is typically:
<%@ LANGUAGE="VBSCRIPT" %>
<%
Response.ContentType="image/gif"
Response.BinaryWrite(Session("vntStream"))
Response.End
%>
And may specify the content type as being one of the following:
GIF image = image/gif
PNG image = image/x-png
WMF image = image/x-wmf
3. An ASP page (eg. Page1.asp) that returns HTML to the users browser and will include the barcode:
<%@ LANGUAGE="VBSCRIPT" %>
<%
Function Barc(xx) ‘ this is the function that returns the
barcode picture
Response.Buffer=TRUE
Session("m_barcode").Caption=xx
Session("vntStream")=Session("m_barcode").Pic(0)
ht=(Session("m_barcode").PictureHeight)
Response.Write("<IMG SRC=""barcd0.asp"" HEIGHT=""" & ht & """>")
End Function
%>
<HTML>
<BODY>
<H1>dLSoft Barcode
IMG Server</H1>
……….
<% xx="501234567890"
Barc(xx) ‘ this is the call to obtain the barcode picture
%>
…………….
</BODY>
</HTML>
Those familiar with
ASP coding will realise that there are many ways of obtaining the same
result!
Barcode IMG Server for IIS supports the use of GIF, PNG or WMF images, the type of image generated being determined by the parameter of the Pic(i) call, for which i=0 gives GIF, i=1 gives PNG and i=2 gives WMF images. PNG images are smaller than the corresponding GIF images, but (at the time of writing) some older versions of the popular browsers have problem printing PNG images. WMF images are suitable for display on Microsoft Windows clients only.
More: