Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 5 of 5

Thread: Code 39/128 Barcode Image Generator

  1. #1
    west is offline Junior Member
    Join Date
    Dec 2009
    Posts
    6

    Default Code 39/128 Barcode Image Generator

    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.
    Last edited by west; 07-21-2010 at 09:45 PM.

  2. #2
    puvanah is offline Junior Member
    Join Date
    Nov 2010
    Posts
    1

    Default How to load /bin/itextsharp.dll file in web.config?

    I use Barcode39 in my web app and I don't need to config anything in web.config for my computer But when I upload it to hosting(clound) the barcode generator is doesn't work - the /bin/itextsharp.dll is don't load.

    How to load the dll in web.config?

    Thank you,
    Puvana

  3. #3
    west is offline Junior Member
    Join Date
    Dec 2009
    Posts
    6

    Default

    Hi puvanah,
    Sorry for the late reply. You do not need to modify the web.config file on your hosting server either. Try to restart the web appl on the hosting server by touching the web.config file (open web.config in a text editor and hit save with no changes made). It will force to restart the website. Hope this helps you.

  4. #4
    mikemurphy is offline Senior Member
    Join Date
    Mar 2006
    Location
    United Kingdom
    Posts
    207

    Default

    Hi West - i get a compilation error

    http://staging.aspdotnetstorefront.t...aspx?code=1234

    Any idea why ?

    <SORTED...i missed the closing tags>
    Last edited by mikemurphy; 06-06-2011 at 01:49 PM.
    8.0.1.4 W2008R2 64-bit MSSQL2005

  5. #5
    mikemurphy is offline Senior Member
    Join Date
    Mar 2006
    Location
    United Kingdom
    Posts
    207

    Default

    West, how do i get the text (order no.) to appear beneath the barcode ?
    8.0.1.4 W2008R2 64-bit MSSQL2005