Click here to Skip to main content
14,972,394 members
Articles / General Programming / Printing
Article
Posted 11 Oct 2013

Stats

15.7K views
3 bookmarked

zebra barcode printing using asp.net

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Oct 2013CPOL1 min read
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

756 members


Comments and Discussions

 
-- There are no messages in this forum --