Click here to Skip to main content
15,879,004 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am using a GC420GT Zebra label printer.
My aim was to print label Stickers for large Cartons( ie single column label on paper rolls width ) and print label Stickers for small packets(ie 2 column label on paper rolls width)
and i need to print it based on a user defined no: of labels

I have searched google and i found ZPL, ZPL II and EPL2 programming languages.

Ques 1) if i impliment my requirement in any of the above languages does it support on common label printers other than zebra? if not plz give your valuable suggestions plz...

Ques 2) is it possible to print labels using microsofts RawPrinterHelper.SendStringToPrinter() function?
I have used it for thermal printing

Ques 3) to impliment device independant printing what method should i follow ?
plz give helping links & ur valuable suggestions
Posted
Updated 24-Oct-13 7:43am
v2

1) ZPL & EPL are common Zebra printer command languages and can be used with any Zebra printer supporting them as well as with other brands that usually ship ZPL or EPL emulation like Datamax, Intermec, etc. If you want to support a broader range of printers, then ZPL & EPL is not the way to go. In .NET, I'd use PrintDocument class for printing which will require a Windows driver for each target printer. Problem is printing performance. If you're going to support high volume printing, then using the native printer command language (like ZPL or EPL for Zebras) is the best approach and I'd not go through the Windows API printing (PrintDocument). Each approach has its pro & cons.

2) RawPrinterHelper can be used to send native printer commands only! i.e. you can send ZPL, EPL, ESC/POS i.e. any commands supported by the target printer

3) Again, I'd use .NET PrintDocument but printing performance will never be comparable to sending native printer commands.
 
Share this answer
 
Comments
george4986 24-Oct-13 15:54pm    
is it possible to print 2 labels like left and right of the paper, while using print document class of .NET?

suppose i need a label format like

heading1( of font1 size big)
heading2 (of font1 size medium)
barcode, heading3 (font1 size medium,position right side of barcode)
heading4 (of font1 size low)

plz give any helping links and sample codes
Marc Gabrie 24-Oct-13 16:22pm    
do you mean printing two labels per row on the roll media?
george4986 24-Oct-13 23:47pm    
yes two labels per row
Marc Gabrie 25-Oct-13 6:22am    
You have to consider that when printing with PrintDocument, you have to write code for printing 2 labels. When PrintDocument PrintPage event is raised, you'll have to print both labels as that event "happens" per printing row.
For generating barcodes and print them through PrintDocument, I'd recommend you zxingnet.codeplex.com which is free & open-source or this which is paid. I personally will discourage you to use barcode fonts i.e. TTF which can be used to print barcodes to avoid future headaches with barcode verifiers.
george4986 26-Oct-13 12:41pm    
thanks Marc for ur valuable suggestion. i got sample code from this link http://www.codeproject.com/Articles/20823/Barcode-Image-Generation-Library
Hello George,

you can use simple print command to printer using Zebra printer. You have to only set your tag size during printing.

Below is given code:-


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Drawing;
using System.Windows.Media;
using System.Drawing.Imaging;
using System.IO;
using System.Management;
using System.Globalization;



namespace Print
{
    public class PrintCode
    {
        #region Properties and Variables
        PrintDocument pdoc = null;
        private decimal _price = 0;
     
        public PrintCode()
        {
        }
        #endregion



        #region Print Page using Printer
        public void print()
        {
            try
            {
              
                PrintDialog pd = new PrintDialog();
                string strDefaultPrinter = pd.PrinterSettings.PrinterName;//Code to get default printer name  
                pdoc = new PrintDocument();
                PrinterSettings ps = new PrinterSettings();                
                Font font = new Font("Courier New", 15);//set default font for page
                PaperSize psize = new PaperSize("Custom", 212, 130);//set paper size sing code
                pd.Document = pdoc;
                pd.Document.DefaultPageSettings.PaperSize = psize;             
                pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

               //*************************Code to set Default Printer*************************************

                string defaultPrinterName = ps.PrinterName; // Code to get default printer

                if (defaultPrinterName == "GC420GT")
                {
                    ps.PrinterName = "GC420GT";//Code to set default printer name
                    pd.PrinterSettings.PrinterName = "GC420GT";//Code to set default printer name 
                }
                else
                {
                    ps.PrinterName = defaultPrinterName;//Code to set default printer name
                    pd.PrinterSettings.PrinterName = defaultPrinterName;//Code to set default printer name 
                }


                //************************************End**************************************************
               

                DialogResult result = pd.ShowDialog();
                if (result == DialogResult.OK)
                {
                 pdoc.Print();
                       
                }
                

                //***************************************************************End*****************************************************************//

            }
            catch (Exception ex)
            {

               
            }

        }

        void pdoc_PrintPage(object sender, PrintPageEventArgs e)
        {

            StringFormat sf = new StringFormat();
           //-------------------------------------End-----------------------------------------------------//

          
            Font font = new Font("Courier New", 10);// set default font size
            float fontHeight = font.GetHeight();
            int startX = 5;// Position of x-axis
            int startY = 2;//starting position of y-axis
            int Offset = 0;
            graphics.DrawString("xxxxxxxx", new Font("Courier New", 9), new SolidBrush(System.Drawing.Color.Black), startX, startY + Offset);
            Offset = Offset + 16;
            graphics.DrawString("$" + "100", new Font("Courier New", 12, FontStyle.Bold), new SolidBrush(System.Drawing.Color.Black), startX, startY + Offset);
            Offset = Offset + 20;
            //********************************************End********************************************

            Offset = 0;
        }
        #endregion





    }
}
 
Share this answer
 
v2
Comments
george4986 25-Oct-13 1:13am    
thanks for the code ,I am working on it .Can u suggest how to incorporate barcode in this print document
george4986 25-Oct-13 2:22am    
i got the code for barcode printing from bmp file
FileStream fileStream = new FileStream(tempPath, FileMode.CreateNew);
pictureBoxPL1.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Bmp);
e.Graphics.DrawImage(pictureBoxPL1.Image, startX+30, startY + Offset,100,15);
fileStream.Dispose();
thanks ur code works
User-8621695 25-Oct-13 17:46pm    
Do you want to printer bar code? If yes then send me a mail on vidya.vikas1@gmail.com because i check my mail every time but not this id so I will sent you code to printer bar code. Do u also want to barcode generation code ?
Shubham SD 15-Dec-16 0:44am    
is Solution 2 is Applicable to print barcode on Barcode Printer ex. TSC -TTP 244 pro
Ihave tried same before watching this on that printer but not working.
can u plz Help me?
User-8621695 7-Mar-17 2:10am    
you can use solution 3 to print barcode.
Check this code for barcode.

C#
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(code128.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
graphics.DrawImage(bm, startX, startY + Offset);
graphics.DrawString(_barCode, new System.Drawing.Font("Arial", 8, FontStyle.Regular), new SolidBrush(System.Drawing.Color.Black), startX, startY + Offset + 25);
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900