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:-
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;
pdoc = new PrintDocument();
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 212, 130);
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
string defaultPrinterName = ps.PrinterName;
if (defaultPrinterName == "GC420GT")
{
ps.PrinterName = "GC420GT";
pd.PrinterSettings.PrinterName = "GC420GT";
}
else
{
ps.PrinterName = defaultPrinterName;
pd.PrinterSettings.PrinterName = defaultPrinterName;
}
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
catch (Exception ex)
{
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
StringFormat sf = new StringFormat();
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
int startX = 5;
int startY = 2;
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;
Offset = 0;
}
#endregion
}
}