The most useful methods of using the barcode image is to transmit it to the browser from an ASP page using an IMG tag. To achieve this
1. Obtain the image as a Variant
Session("vntStream2")=Session("m_barcode").Pic(0)
2. Obtain the height of the image using
ht=(Session("m_barcode").PictureHeight)
3. send the HTML code to the browser using
Response.Write("<IMG SRC=""barcd.asp"" HEIGHT=""" & ht & """>")
Where the barcd.asp page simply returns the contents of the Variant vntStream, i.e.
<%@ LANGUAGE="VBSCRIPT"
%>
<%
Response.ContentType="image/gif"
Response.BinaryWrite(Session("vntStream1"))
Response.End
%>
A simple and standardised way of performing these operations is to place most elements into a function, such as
<%@ LANGUAGE="VBSCRIPT" %>
<%
Function
Barc(xx)
Response.Buffer=TRUE
Session("m_barcode").CodeType=8 ‘ for Code
39
Session("m_barcode").Xunit=20 ‘ the x dimension – which determines the
barcode width
Session("m_barcode").ImageHeight=2000 ‘ the hight of the image
in HIMETRIC units
Session("m_barcode").Caption=xx ‘ the barcode
data
Session("vntStream1")=Session("m_barcode").Pic(0)
ht=(Session("m_barcode").PictureHeight)
Response.Write("<IMG
SRC=""barcd.asp"" HEIGHT=""" & ht & """>")
End
Function
%>
The function may then be called from anywhere on the page using
<% xx="12345798"
Barc(xx)
%>
The reason that two ASP pages are used is simply so that the barcode size can be obtained before the image is sent to the browser. The developer can, of course, set the barcode size manually in which case all elements can be contained within one ASP page.
More: