public static byte[] GraphicDirectWrite(int left, int top, string bitmapName, PrinterSettings settings) { Bitmap bmp = new Bitmap(bitmapName); List<byte> res = new List<byte>(); int byteWidth = bmp.Width % 8 == 0 ? bmp.Width / 8 : bmp.Width / 8 + 1; res.AddRange(Encoding.GetEncoding(437).GetBytes(string.Format("GW{0},{1},{2},{3},", left + settings.AlignLeft, top + settings.AlignTop, byteWidth, bmp.Height))); for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < byteWidth; x++) { BitArray ba = new BitArray(8); int scanx = x * 8; for (int k = 7; k >= 0; k--) { if (scanx >= bmp.Width) ba[k] = true; else ba[k] = bmp.GetPixel(scanx, y).R > 128; scanx++; } res.Add(convertToByte(ba)); } } return res.ToArray(); }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcode barcode, bool readable, string barcodeData, PrinterSettings settings) { string encodedReadable = readable ? "B" : "N"; return Encoding.GetEncoding(437).GetBytes(string.Format("B{0},{1},{2},{3},{4},{5},{6},{7},\"{8}\"\n", left + settings.AlignLeft, top + settings.AlignTop, (int)rotation, barcode.P4Value, barcode.BarWidthNarrow, barcode.BarWidthWide, height, encodedReadable, barcodeData)); }
public static byte[] EPL_Align(PrinterSettings p) { List<byte> res = new List<byte>(); res.AddRange(EPLCommands.LineWriteBlack(0, 20, 1, 20, p)); res.AddRange(EPLCommands.TextWrite(5, 20, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "0", p)); res.AddRange(EPLCommands.LineWriteBlack(5, 40, 1, 20, p)); res.AddRange(EPLCommands.TextWrite(10, 40, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "5", p)); res.AddRange(EPLCommands.LineWriteBlack(10, 60, 1, 20, p)); res.AddRange(EPLCommands.TextWrite(15, 60, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "10", p)); res.AddRange(EPLCommands.LineWriteBlack(15, 80, 1, 20, p)); res.AddRange(EPLCommands.TextWrite(20, 80, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "15", p)); res.AddRange(EPLCommands.LineWriteBlack(20, 100, 1, 20, p)); res.AddRange(EPLCommands.TextWrite(25, 100, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "20", p)); res.AddRange(EPLCommands.LineWriteBlack(40, 0, 20, 1, p)); res.AddRange(EPLCommands.TextWrite(40, 5, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "0", p)); res.AddRange(EPLCommands.LineWriteBlack(60, 5, 20, 1, p)); res.AddRange(EPLCommands.TextWrite(60, 10, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "5", p)); res.AddRange(EPLCommands.LineWriteBlack(80, 10, 20, 1, p)); res.AddRange(EPLCommands.TextWrite(80, 15, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "10", p)); res.AddRange(EPLCommands.LineWriteBlack(100, 15, 20, 1, p)); res.AddRange(EPLCommands.TextWrite(100, 20, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "15", p)); res.AddRange(EPLCommands.LineWriteBlack(120, 20, 20, 1, p)); res.AddRange(EPLCommands.TextWrite(120, 25, Com.SharpZebra.ElementDrawRotation.NO_ROTATION, Com.SharpZebra.ZebraFont.STANDARD_NORMAL, 1, 1, false, "20", p)); res.AddRange(EPLCommands.LineWriteBlack(p.Width, 20, 1, 20, p)); res.AddRange(EPLCommands.LineWriteBlack(p.Width - 5, 40, 1, 20, p)); res.AddRange(EPLCommands.LineWriteBlack(p.Width - 10, 60, 1, 20, p)); res.AddRange(EPLCommands.LineWriteBlack(p.Width - 15, 80, 1, 20, p)); res.AddRange(EPLCommands.LineWriteBlack(p.Width - 20, 100, 1, 20, p)); res.AddRange(EPLCommands.LineWriteBlack(40, p.Length, 20, 1, p)); res.AddRange(EPLCommands.LineWriteBlack(60, p.Length - 5, 20, 1, p)); res.AddRange(EPLCommands.LineWriteBlack(80, p.Length - 10, 20, 1, p)); res.AddRange(EPLCommands.LineWriteBlack(100, p.Length - 15, 20, 1, p)); res.AddRange(EPLCommands.LineWriteBlack(120, p.Length - 20, 20, 1, p)); return res.ToArray(); }
public USBPrinter(PrinterSettings settings) { Settings = settings; }
public static void print(Patient patient, string printer_name) { Com.SharpZebra.Printing.PrinterSettings ps = new Com.SharpZebra.Printing.PrinterSettings(); ps.PrinterName = printer_name; ps.Width = 203 * 4; ps.Length = 203 * 1; ps.Darkness = 30; int start_write = ps.Width / 5; int location = 25; List <byte> page = new List <byte>(); page.AddRange(EPLCommands.ClearPrinter(ps)); page.AddRange(EPLCommands.TextWrite(start_write, location, ElementDrawRotation.NO_ROTATION, ZebraFont.STANDARD_SMALL, 2, 2, false, (patient.firstName + " " + patient.lastName), ps)); //Increment location to start printing appointments location += 30; for (int i = 0; i <= patient.appointments.Count; i++) { if (patient.appointments.Count - 1 >= i) { page.AddRange(EPLCommands.TextWrite(start_write, location, ElementDrawRotation.NO_ROTATION, ZebraFont.STANDARD_SMALL, 2, 2, false, patient.appointments[i].ToShortDateString() + " @ " + patient.appointments[i].ToShortTimeString(), ps)); } //increment location by 30 location += 25; //check for 0 to prevent incorrect spacing if ((i + 1) % 5 == 0 && i != 0) { location += 80; } } switch (patient.appointments.Count % 5) { case 4: location += 60; break; case 0: location += 35; break; default: break; } location -= 25; //Print patient reminder //Increment by 25 page.AddRange(EPLCommands.TextWrite(start_write, location, ElementDrawRotation.NO_ROTATION, ZebraFont.STANDARD_SMALL, 2, 2, false, "Please call if you are", ps)); page.AddRange(EPLCommands.TextWrite(start_write, location + 22, ElementDrawRotation.NO_ROTATION, ZebraFont.STANDARD_SMALL, 2, 2, false, "unable to make your", ps)); page.AddRange(EPLCommands.TextWrite(start_write, location + 44, ElementDrawRotation.NO_ROTATION, ZebraFont.STANDARD_SMALL, 2, 2, false, "appointments", ps)); page.AddRange(EPLCommands.PrintBuffer(1)); new SpoolPrinter(ps).Print(page.ToArray()); }
public static byte[] GraphicWrite(int left, int top, string imageName, PrinterSettings settings) { return Encoding.GetEncoding(437).GetBytes(string.Format("GG{0},{1},\"{2}\"\n", left, top, imageName)); }
public NetworkPrinter(PrinterSettings settings) { Settings = settings; }
public SpoolPrinter(PrinterSettings settings) { Settings = settings; }
public static byte[] DiagonalLineWrite(int left, int top, int lineThickness, int right, int bottom, PrinterSettings settings) { return Encoding.GetEncoding(437).GetBytes(string.Format("LS{0},{1},{2},{3},{4}\n", left + settings.AlignLeft, top + settings.AlignTop, lineThickness, right + settings.AlignLeft, bottom + settings.AlignTop)); }
private static byte[] LineDraw(string lineDrawCode, int left, int top, int width, int height, PrinterSettings settings) { return Encoding.GetEncoding(437).GetBytes(string.Format("{0}{1},{2},{3},{4}\n", lineDrawCode, left + settings.AlignLeft, top + settings.AlignTop, width, height)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int horizontalMult, int verticalMult, bool isReverse, string text, PrinterSettings settings) { return Encoding.GetEncoding(437).GetBytes(string.Format("A{0},{1},{2},{3},{4},{5},{6},\"{7}\"\n", left + settings.AlignLeft, top + settings.AlignTop, (int)rotation, (char)font, horizontalMult, verticalMult, isReverse ? "R" : "N", text.Replace(@"\", @"\\").Replace("\"", "\\\""))); }
public static byte[] LineWriteWhite(int left, int top, int width, int height, PrinterSettings settings) { return LineDraw("LW", left, top, width, height, settings); }