Click here to Skip to main content
13,054,329 members (122,300 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


12 bookmarked
Posted 4 Jan 2011

Generating and Printing Barcodes on Zebra Printer

, 4 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Access zebra printer from ASP.NET

It is really difficult to find something on internet to print 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

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

Both aspx and cs file code is attached

Any one who wants to print barcodes using zebra printers can use it, using ASP.NET (webforms). Any one using JavaScript for printing and try to print on zebra printer has issues. AS barcode generated does not get scanned. So using the code the barcode generated is corrected printed by zebra printer.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing.Printing;
using System.Text;
using System.Drawing;
using System.IO;
using System.ComponentModel;
namespace RahulMehtaGhatkopar100
    public partial class WebForm4 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        public void Submit_Click(object sender, EventArgs e)
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                // Set the printer name. 
                //pd.PrinterSettings.PrinterName = "\\NS5\hpoffice
                //pd.PrinterSettings.PrinterName = "Zebra New GK420t"               
            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("*AAAAAAFFF*", printFont, br, 10, 65);
            ev.Graphics.DrawString("*AAAAAAFFF*", printFont1, br, 10, 85);  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Rahul AnilKumar Mehta
Web Developer Imperial College London
United Kingdom United Kingdom
Over 10 years of experience in the analysis, design, development, implementation of full life cycle of Web and Windows Based .Net applications.
Proven strength in trouble shooting, problem solving, coordination and analysis.
A good team player, self-motivated and good communication skills.
Domain knowledge of Finance and Health care.
Development experience using ASP .NET, VB .Net, C#, and SQL Server
Worked with companies and clients like Merrill Lynch , Glaxo SmithKline and ICICI Prudential Insurance.
1. Certified professional Microsoft Certified Application Developer ( MCAD)

2. Exam 70-573:
TS: Microsoft SharePoint 2010, Application Development
(Year :2011)

3. Microsoft® Community Contributor Award - 2011

SharePoint 2007, WSS 3.0 , BizTalk Server, WPF, WWF, WCF

Active Member of Group

Specialties: C# (Both Windows and Web Application)

Interested in SharePoint 2007, WSS 3.0 , BizTalk Server, WPF, WWF, WCF.

Currently Working In UK.
Have worked in India, USA and Australia. Now working in Uk for around 4 years

You may also be interested in...

Comments and Discussions

QuestionExtraordinary Pin
Mrkraju21-May-15 6:34
memberMrkraju21-May-15 6:34 
GeneralMy vote of 1 Pin
VICK22-Jan-15 1:15
professional VICK22-Jan-15 1:15 
Questioni use vb Pin
David Ortega20-Nov-13 6:15
memberDavid Ortega20-Nov-13 6:15 
QuestionWhat would the analagous event for a project? Pin
Member 90401374-Feb-13 14:13
memberMember 90401374-Feb-13 14:13 
QuestionDoes not work from published code. Pin
faizkazi4u17-Dec-12 2:17
memberfaizkazi4u17-Dec-12 2:17 
AnswerRe: Does not work from published code. Pin
rahulbhat22-Mar-17 23:05
memberrahulbhat22-Mar-17 23:05 
GeneralThank you Pin
Khybar Dev14-Oct-12 17:13
memberKhybar Dev14-Oct-12 17:13 
GeneralReason for my vote of 5 good job. Pin
CS140127-Jan-12 21:21
memberCS140127-Jan-12 21:21 
GeneralReason for my vote of 1 not Working Pin
ramomex220-Jun-11 12:25
memberramomex220-Jun-11 12:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 4 Jan 2011
Article Copyright 2011 by Rahul AnilKumar Mehta
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid