Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

zebra barcode printing using asp.net

0.00/5 (No votes)
27 Dec 2012 1  
zebra barcode printing using asp.netIt is really difficult to find something on internet to print zebra code from asp.net form Yes what

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

zebra barcode printing using asp.net

It is really difficult to find something on internet to print zebra code from asp.net form 
Yes what you will find is javascript to acheive the same. Also its easy to do from windows application.
 
Issue : when you use javascript , you have to save the image(barcode) on aspx page and then fire the javascript print command. It works well with lazer printer but has issue with Zebra printer as image  gets generated but there , we are not able to scan it. So Barcode generated is no use if you are using Zebra printer
 
Code is simple and strait forward.
It allows you to print barcode  and also access zebra printer from asp.net.
 
1.       Install font which is free on .net “3 of 9 Barcode
2.       Create an Asp.net project
3.        Add this code
 
 
public void Submit_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                // Set the printer name.
                //pd.PrinterSettings.PrinterName = "file://ns5/hpoffice
                //pd.PrinterSettings.PrinterName = "Zebra New GK420t"              
                pd.Print();
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.ToString());
            }
        }
        void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            Font printFont = new Font("3 of 9 Barcode", 17);
            Font printFont1 = new Font("Times New Roman", 9, FontStyle.Bold);

            SolidBrush br = new SolidBrush(Color.Black);

            ev.Graphics.DrawString("*texttodisplay*", printFont, br, 10, 65);
            ev.Graphics.DrawString("*texttodisplay*", printFont1, br, 10, 85);
          
        }



License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here