dLSoft

Quick_links...

Search site
Trial products
Online tutorials

Products

Barcodes for Office
Barcode creators
Barcode fonts
Developer tools
Label printing
Labelling tools
Windows Phone

Resources

New to barcodes?
How To ...
Support centre
Tutorial centre
Which product

For users

Common problems
What's New?
Newsletter
Online registration
Contact us

GS1

Award 2009

Award 2008

Powered by a
UK2 VPS

Barcodes on ASP.NET pages

Select on of the link below to see one of the dBarcode.NET components on an ASP.NET page

dBarcode.NET Dual Universal

dBarcode.NET GS1-Composite

dBarcode.NET components can generate barcode images in BMP, EPS, GIF, PNG, JPG, TIF and WMF formats, and for more than 60 barcode types.  dBarcode.NET components are also used in our Barcodes Online service

Using a dBarcode.NET component

One method, suitable for use when the barcode is to be data-dependent, is to use two aspx files, one which creates a memorystream barcode image using one of the dLSoft dBarcode.NET components and then uses a dummy ASP.NET page as the SRC for an IMG tag to display the image at the correct size, eg.

<script type="text/vb" runat="server">
sub Page_Load(Sender As Object, E As EventArgs)
…………………..
m_barcode.Unit = GraphicsUnit.Inch
m_barcode.XUnit = 0
m_barcode.Font=m_Font
m_barcode.Orientation=0
m_barcode.AutoCheckdigit=TRUE
m_barcode.BarcodeHeight = tht     ' desired height in inches
m_barcode.BarcodeWidth = twd    ' desired width in inches
m_barcode.CodeTypeValue = 8
m_barcode.caption = Session("xx")
' this example creates barcodes at 300 pixels per inch
Session("ms")=m_barcode.sBarcode(300,300,System.Drawing.Imaging.ImageFormat.Png)
if Session("ms").Length>0 then
Session("ht")=m_barcode.ImageHeight*96/300 ' adjust size for the desired image resolution
Session("wd")=m_barcode.ImageWidth*96/300
end if
</script>
</head>
<BODY>
<H1>dLSoft dBarcode.NET - on ASP.NET</H1>
<IMG SRC="page2.aspx" HEIGHT=" <% =Session("ht") %> " WIDTH=" <% =Session("wd") %> ">
<p> dBarcode.NET components can generate barcode images in BMP, GIF, PNG, JPG, TIF and WMF formats, and for more than 50 barcode types.
</BODY>
</HTML>

The Session variables ht and wd contain the actual sizes at which the barcode image is to be drawn on the web page. These are calculated when the page is loaded and used when the IMG SRC calls the second page.

The second file (page2.aspx) serves up the image at the correct size, eg.
<%@ LANGUAGE="VB"%>
<%
Response.ContentType="image/png"
Response.BinaryWrite(Session("ms").GetBuffer())
%>