This procedure will allow you to integrate Code 39 or Code 128 barcode image generator into your storefront. No source code is required. You will be able to print barcodes for Order Numbers, Customer Numbers and SKUs on receipts.
1. You need to download iTextSharp.dll here: http://sourceforge.net/projects/itextsharp/ and place it in the root/bin/ directory of your website.
2. Create a file Barcode.aspx containing the following code and place it in the root of your website:
Code:
<%@ Page language="c#" Inherits="AspDotNetStorefront.Barcode" CodeFile="Barcode.aspx.cs" %>
3. Create a file Barcode.aspx.cs containing the following code and place it in the root of your website:
Code:
using iTextSharp.text.pdf;
namespace AspDotNetStorefront
{
public partial class Barcode : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
Barcode39 code39 = new Barcode39();
code39.Code = Request["code"];
// Holds the minimum width of a bar. Default is 0.8f.
code39.X = 0.8f;
// You can set the amount of ink spreading. This value is subtracted from the width of each bar. Default is 0f.
code39.InkSpreading = 0f;
// Holds the multiplier for wide bars for some types. Default is 2f.
code39.N = 3f;
// Defines the font of the text (if any).
code39.Font = BaseFont.CreateFont("Helvetica", "winansi", false);
// Size of the font.
code39.Size = 10f;
// Distance between text and barcode. Negative values put the text above the bar.
code39.Baseline = 10f;
// Changes the bar height.
code39.BarHeight = 28f;
// Generates a checksum.
code39.GenerateChecksum = false;
// Makes the calculated value visible in the human-readable text (or not).
code39.ChecksumText = false;
// Sets the start/stop sequence visible for those barcodes that use these sequences.
code39.StartStopText = true;
// Extended Code39.
code39.Extended = false;
// Text alignment.
//code39.TextAlignment = Element.ALIGN_CENTER;
// Code 128 value.
//code128.CodeType = Barcode128.CODE_A;
System.Drawing.Image bc = code39.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);
Response.ContentType = "image/gif";
bc.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
}
}
}
4. Place the following code in the notification.receipt.xml.config file located in the root/XmlPackages/ directory where you need it:
Code:
<tr>
<td colspan="2" align="center">
<img src="{/root/System/StoreUrl}Barcode.aspx?code={/root/QueryString/ordernumber}" alt="Order Number {/root/QueryString/ordernumber}" />
</td>
</tr>
This is all. You can test it by going to: www.yourdomain.com/barcode.aspx?code=1234
If you need to integrate Code 128 barcodes change all 39s to 128 in Barcode.aspx.cs file.