I printed blank label

Apr 2, 2014 at 11:37 PM
Dear all,
I do not understand why prints blank label. What am I doing wrong?
        PrinterSettings ps = null;
        ps = new PrinterSettings();
        ps.PrinterName = "ZDesigner GX420t";
  • ZPL
        List<byte> page = null;
    
        page = new List<byte>();
        page.AddRange(ZPLCommands.ClearPrinter(ps));
    
        page.AddRange(ZPLCommands.TextWrite(100, 100, ElementDrawRotation.NO_ROTATION, 30, "ZPL Utility"));
        page.AddRange(ZPLCommands.BarCodeWrite(50, 130, 100, ElementDrawRotation.NO_ROTATION, new Barcode {Type=BarcodeType.CODE128_AUTO}, true, "HELLO WORLD"));
    
        page.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
  • EPL
        List<byte> page = null;
    
        page = new List<byte>();
        page.AddRange(ZPLCommands.ClearPrinter(ps));
    
        page.AddRange(EPLCommands.TextWrite(5, 20, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "0", ps));
    
        page.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
  • BMP
        List<byte> page = null;
        List<byte> res = null;
    
        page = new List<byte>();
        page.AddRange(ZPLCommands.ClearPrinter(ps));
        page.AddRange(ZPLCommands.GraphicDelete('E', "MT"));
        page.AddRange(ZPLCommands.ClearPrinter(ps));
        page.AddRange(ZPLCommands.GraphicStore(new Bitmap(@"C:\MT.bmp"), 'E', "MT"));
        page.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
        res = new List<byte>();
        res.AddRange(ZPLCommands.ClearPrinter(ps));
        res.AddRange(ZPLCommands.GraphicWrite(15, 15, "MT", 'E'));
        res.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
  • PCX
        List<byte> page = null;
        List<byte> res = null;
    
        //Carga de una imagen a la impresora
        page = new List<byte>();
        page.AddRange(ZPLCommands.ClearPrinter(ps));
        page.AddRange(ZPLCommands.GraphicDelete('E', "PRINTER"));
        page.AddRange(ZPLCommands.ClearPrinter(ps));
        page.AddRange(ZPLCommands.GraphicStore(new Bitmap(@"C:\printer.pcx"), 'E', "PRINTER"));
        page.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
        //Impresión de la imagen cargada en impresora
        res = new List<byte>();
        res.AddRange(ZPLCommands.ClearPrinter(ps));
        res.AddRange(ZPLCommands.GraphicWrite(15, 15, "PRINTER", 'E'));
        res.AddRange(ZPLCommands.PrintBuffer(1));
        new SpoolPrinter(ps).Print(page.ToArray());
    
Help please

Regads
Toni.
Coordinator
Apr 6, 2014 at 12:29 AM
You code looks fine, I don't recall if the ClearPrinter command is ok to be used after the start, it's probably fine though. It is unnecessary, as it's ok to do a GraphicDelete, GraphicStore and GraphicWrite in 3 successive lines.

Regarding the blank label, I will start by assuming you can print to the printer fine with the windows test page.
If that is ok, you can try setting the other PrinterSettings values. In particular Width, Length and Darkness can be important.
assuming a 3" x 4" label in portrait orientation (and assuming your printer is 203 dpi, adjust accordingly if 300), you would do this:
        ps = new PrinterSettings();
        ps.PrinterName = "ZDesigner GX420t";
        ps.Width = 812;    //203dpi x 4" 
        ps.Height = 603;   //203dpi x 3"
        ps.Darkness = 23;  //usually a good value for thermal transfer, for direct thermal try around 28