public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcodes barcode, bool readable, string barcodeData) { string encodedReadable = readable ? "Y" : "N"; char encodedRotation = Rotation.ZPLRotationMap[(int)rotation]; switch (barcode.Type) { case BarcodeType.CODE39_STD_EXT: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B3{3},N,{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.CODE128_AUTO: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BC{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.UPC_A: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BU{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.UPC_E: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B9{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.EAN8: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B8{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); case BarcodeType.EAN13: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BE{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData))); default: throw new ApplicationException("Barcode not yet supported by LabelPrinter library or printer language."); } }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcode barcode, bool readable, string barcodeData) { var encodedReadable = readable ? "Y" : "N"; switch (barcode.Type) { case BarcodeType.CODE39_STD_EXT: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B3{3},,{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, (char)rotation, height, encodedReadable, barcodeData))); case BarcodeType.CODE128_AUTO: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BC{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, (char)rotation, height, encodedReadable, barcodeData))); case BarcodeType.UPC_A: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BU{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, (char)rotation, height, encodedReadable, barcodeData))); case BarcodeType.EAN13: return(Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BE{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, (char)rotation, height, encodedReadable, barcodeData))); default: throw new ApplicationException("Barcode not yet supported by SharpZebra library."); } }
/// <summary> /// Writes text using the printer's (hopefully) built-in font. /// <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=1336"/> /// ZPL Command: ^A. /// Manual: <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=42"/> /// </summary> /// <param name="left">Horizontal axis.</param> /// <param name="top">Vertical axis.</param> /// <param name="rotation">Rotate field.</param> /// <param name="font">ZPLFont to print with.</param> /// <param name="height">Height of text in dots. 10-32000, or 0 to scale based on width</param> /// <param name="width">Width of text in dots. 10-32000, default or 0 to scale based on height</param> /// <param name="text">Text to be written</param> /// <param name="codepage">The text encoding page the printer is set to use</param> /// <returns>Array of bytes containing ZPLII data to be sent to the Zebra printer.</returns> public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZPLFont font, int height, int width = 0, string text = "", int codepage = 850) { return(string.IsNullOrEmpty(text) ? new byte[0] : Encoding.GetEncoding(codepage) .GetBytes($"^FO{left},{top}^A{(char) font}{(char) rotation},{height},{width}{FixTilde(text)}")); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, TSCFont font, int horizontalMult, int verticalMult, string text, int codepage = 1252) { return(Encoding.GetEncoding(codepage).GetBytes(string.Format("TEXT {0},{1},\"{2}\",{3},{4},{5},\"{6}\"\n", left, top, (int)font, Rotation.TSCPLRotationMap[(int)rotation], horizontalMult, verticalMult, text.Replace(@"\", @"\\").Replace("\"", "\\\"")))); }
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[] 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)); }
/// <summary> /// Writes text using a font previously uploaded to the printer. Prints with the last used font. /// ZPL Command: ^A@. /// Manual: <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=44"/> /// </summary> /// <param name="left">Horizontal axis.</param> /// <param name="top">Vertical axis.</param> /// <param name="rotation">Rotate field.</param> /// <param name="height">Height of text in dots for scalable fonts, nearest magnification found for bitmapped fonts (R, E, B or A)</param> /// <param name="text">Text to be written</param> /// <param name="codepage">The text encoding page the printer is set to use</param> /// <returns>Array of bytes containing ZPLII data to be sent to the Zebra printer.</returns> public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text, int codepage = 850) { //uses last specified font return(string.IsNullOrEmpty(text) ? new byte[0] : Encoding.GetEncoding(codepage) .GetBytes($"^A@{(char) rotation},{height}^FO{left},{top}{FixTilde(text)}")); }
/// <summary> /// Writes Data Matrix Bar Code for ZPL. /// ZPL Command: ^BX. /// Manual: <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=122"/> /// </summary> /// <param name="left">Horizontal axis.</param> /// <param name="top">Vertical axis.</param> /// <param name="height">Height is determined by dimension and data that is encoded.</param> /// <param name="rotation">Rotate field.</param> /// <param name="text">Text to be encoded</param> /// <param name="qualityLevel">Version of Data Matrix.</param> /// <param name="aspectRatio">Choices the symbol, it is possible encode the same data in two forms of Data Matrix, a square form or rectangular.</param> /// <returns>Array of bytes containing ZPLII data to be sent to the Zebra printer.</returns> public static byte[] DataMatrixWrite(int left, int top, ElementDrawRotation rotation, int height, string text, QualityLevel qualityLevel = QualityLevel.ECC_200, AspectRatio aspectRatio = AspectRatio.SQUARE) { var rotationValue = (char)rotation; var qualityLevelValue = (int)qualityLevel; var aspectRatioValue = (int)aspectRatio; return(Encoding.GetEncoding(850).GetBytes($"^FO{left},{top}^BX{rotationValue}, {height},{qualityLevelValue},,,,,{aspectRatioValue},^FD{text}^FS")); }
/// <summary> /// Write any windows-supported text in any windows-supported font style to the printer - including international characters! /// Note that if your printer's RAM drive letter is something other than 'E', you must set it in printer settings before calling ZPLCommands.ClearPrinter! /// </summary> /// <param name="left"></param> /// <param name="top"></param> /// <param name="rotation"></param> /// <param name="font"></param> /// <param name="text"></param> /// <returns></returns> public static byte[] CustomStringWrite(int left, int top, ElementDrawRotation rotation, Font font, string text) { var s = new CustomString { Font = font, Rotation = rotation, Text = text }; return(CustomStringWrite(left, top, s)); }
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))); }
/// <summary> /// Writes text using a font previously uploaded to the printer. /// ZPL Command: ^A@. /// Manual: <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=44"/> /// </summary> /// <param name="left">Horizontal axis.</param> /// <param name="top">Vertical axis.</param> /// <param name="rotation">Rotate field.</param> /// <param name="fontName">The name of the font from the printer's directory listing (ends in .FNT)</param> /// <param name="storageArea">The drive the font is stored on. From your printer's directory listing.</param> /// <param name="height">Height of text in dots for scalable fonts, nearest magnification found for bitmapped fonts (R, E, B or A)</param> /// <param name="text">Text to be written</param> /// <param name="codepage">The text encoding page the printer is set to use</param> /// <returns>Array of bytes containing ZPLII data to be sent to the Zebra printer.</returns> public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, string fontName, char storageArea, int height, string text, int codepage = 850) { var rotationValue = (char)rotation; return(string.IsNullOrEmpty(text) ? new byte[0] : Encoding.GetEncoding(codepage).GetBytes(string.Format("^A@{0},{1},{1},{2}:{3}^FO{4},{5}{6}", rotationValue, height, storageArea, fontName, left, top, FixTilde(text)))); }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcodes barcode, bool readable, string barcodeData) { string encodedReadable = readable ? "1" : "0"; string bartype = BarcodeTypeMap.TSCPLBarcodeTypeMap[(int)barcode.Type]; if (bartype == string.Empty) { throw new ApplicationException("Barcode not yet supported by LabelPrinter library or printer language."); } return(Encoding.GetEncoding(850).GetBytes(string.Format("BARCODE {0},{1},\"{2}\",{3},{4},{5},{6},{7},\"{8}\"\n", left, top, bartype, height, encodedReadable, Rotation.TSCPLRotationMap[(int)rotation], barcode.BarWidthNarrow, barcode.BarWidthWide, barcodeData))); }
public static int Rotation(ElementDrawRotation rotation) { switch (rotation) { case ElementDrawRotation.NO_ROTATION: return(0); case ElementDrawRotation.ROTATE_90_DEGREES: return(1); case ElementDrawRotation.ROTATE_180_DEGREES: return(2); case ElementDrawRotation.ROTATE_270_DEGREES: return(4); default: return(0); } }
public static byte[] BarCodeWrite(int left, int top, int height, ElementDrawRotation rotation, Barcode barcode, bool readable, string barcodeData) { string encodedReadable = readable ? "Y" : "N"; char encodedRotation = Rotation.ZPLRotationMap[(int)rotation]; switch (barcode.Type) { case BarcodeType.CODE39_STD_EXT: return Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^B3{3},,{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData)); case BarcodeType.CODE128_AUTO: return Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BC{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData)); case BarcodeType.UPC_A: return Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BU{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData)); case BarcodeType.EAN13: return Encoding.GetEncoding(850).GetBytes(string.Format("^FO{0},{1}^BY{2}^BE{3},{4},{5}^FD{6}^FS", left, top, barcode.BarWidthNarrow, encodedRotation, height, encodedReadable, barcodeData)); default: throw new ApplicationException("Barcode not yet supported by SharpZebra library."); } }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int height, int width = 0, string text = "", int codepage = 850) { return(Encoding.GetEncoding(codepage).GetBytes($"^FO{left},{top}^A{(char)font}{(char)rotation},{height},{width}^FD{text}^FS")); }
/// <summary> /// Write any windows-supported text in any windows-supported font style to the printer - including international characters! /// Note that if your printer's RAM drive letter is something other than 'E', you must set it in printer settings before calling ZPLCommands.ClearPrinter! /// </summary> /// <param name="left"></param> /// <param name="top"></param> /// <param name="rotation"></param> /// <param name="font"></param> /// <param name="text"></param> /// <returns></returns> public static byte[] CustomStringWrite(int left, int top, ElementDrawRotation rotation, Font font, string text) { var s = new CustomString {Font = font, Rotation = rotation, Text = text}; return CustomStringWrite(left, top, s); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text) { return(TextWrite(left, top, rotation, height, text, 850)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, string fontName, char storageArea, int height, string text, int codepage = 850) { return(Encoding.GetEncoding(codepage).GetBytes(string.Format("^A@{0},{1},{1},{2}:{3}^FO{4},{5}^FD{6}^FS", (char)rotation, height, storageArea, fontName, left, top, text))); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int height, int width, string text) { return TextWrite(left, top, rotation, font, height, width, text, 850); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int height, int width, string text, int codepage) { return Encoding.GetEncoding(codepage).GetBytes(string.Format("^FO{0},{1}^A{2}{3},{4},{5}^FD{6}^FS", left, top, (char)font, Rotation.ZPLRotationMap[(int)rotation], height, width, text)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text) { return TextWrite(left, top, rotation, height, text, 850); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int height, int width, string text) { return(TextWrite(left, top, rotation, font, height, width, text, 850)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZebraFont font, int height, int width, string text, int codepage = 850) { return(Encoding.GetEncoding(codepage).GetBytes(string.Format("^FO{0},{1}^A{2}{3},{4},{5}^FD{6}^FS", left, top, (char)font, (char)rotation, height, width, text))); }
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[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text, int codepage = 850) { //uses last specified font return(Encoding.GetEncoding(codepage).GetBytes(string.Format("^A@{0},{1}^FO{2},{3}^FD{4}^FS", (char)rotation, height, left, top, text))); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, string fontName, char storageArea, int height, string text) { return TextWrite(left, top, rotation, fontName, storageArea, height, text, 850); }
/// <summary> /// Writes text using a font previously uploaded to the printer. Prints with the last used font. /// ZPL Command: ^A@. /// Manual: <see href="https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf#page=44"/> /// </summary> /// <param name="left">Horizontal axis.</param> /// <param name="top">Vertical axis.</param> /// <param name="rotation">Rotate field.</param> /// <param name="height">Height of text in dots for scalable fonts, nearest magnification found for bitmapped fonts (R, E, B or A)</param> /// <param name="text">Text to be written</param> /// <param name="codepage">The text encoding page the printer is set to use</param> /// <returns>Array of bytes containing ZPLII data to be sent to the Zebra printer.</returns> public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text, int codepage = 850) { //uses last specified font return(Encoding.GetEncoding(codepage).GetBytes($"^A@{(char) rotation},{height}^FO{left},{top}^FD{text}^FS")); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, int height, string text, int codepage) { //uses last specified font return Encoding.GetEncoding(codepage).GetBytes(string.Format("^A@{0},{1}^FO{2},{3}^FD{4}^FS", Rotation.ZPLRotationMap[(int)rotation], height, left, top, text)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, string fontName, char storageArea, int height, string text, int codepage) { return Encoding.GetEncoding(codepage).GetBytes(string.Format("^A@{0},{1},{1},{2}:{3}^FO{4},{5}^FD{6}^FS", Rotation.ZPLRotationMap[(int)rotation], height, storageArea, fontName, left, top, text)); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, string fontName, char storageArea, int height, string text) { return(TextWrite(left, top, rotation, fontName, storageArea, height, text, 850)); }