public void MultipleElements() { var sampleText = "[_~^][LineBreak\n][The quick fox jumps over the lazy dog.]"; ZPLFont font = new ZPLFont(fontWidth: 50, fontHeight: 50); var elements = new List <ZPLElementBase>(); elements.Add(new ZPLTextField(sampleText, 50, 100, font)); elements.Add(new ZPLGraphicBox(400, 700, 100, 100, 5)); elements.Add(new ZPLGraphicBox(450, 750, 100, 100, 50, ZPLConstants.LineColor.White)); elements.Add(new ZPLGraphicCircle(400, 700, 100, 5)); elements.Add(new ZPLGraphicDiagonalLine(400, 700, 100, 50, 5)); elements.Add(new ZPLGraphicDiagonalLine(400, 700, 50, 100, 5)); elements.Add(new ZPLGraphicSymbol(ZPLGraphicSymbol.GraphicSymbolCharacter.Copyright, 600, 600, 50, 50)); elements.Add(new ZPLQRCode("MM,AAC-42", 200, 800)); //Add raw ZPL code elements.Add(new ZPLRaw("^FO200, 200^GB300, 200, 10 ^FS")); var renderEngine = new ZPLEngine(elements); var output = renderEngine.ToZPLString(new ZPLRenderOptions() { AddEmptyLineBeforeElementStart = true }); Console.WriteLine(output); }
public void TextFieldVariations() { var sampleText = "[_~^][LineBreak\n][The quick fox jumps over the lazy dog.]"; ZPLFont font = new ZPLFont(fontWidth: 50, fontHeight: 50); var elements = new List <ZPLElementBase>(); //Specail character is repalced with space elements.Add(new ZPLTextField(sampleText, 10, 10, font, useHexadecimalIndicator: false)); //Specail character is using Hex value ^FH elements.Add(new ZPLTextField(sampleText, 10, 50, font, useHexadecimalIndicator: true)); //Only the first line is displayed elements.Add(new ZPLSingleLineFieldBlock(sampleText, 10, 150, 500, font)); //Max 2 lines, text exceeding the maximum number of lines overwrites the last line. elements.Add(new ZPLFieldBlock(sampleText, 10, 300, 400, font, 2)); // Multi - line text within a box region elements.Add(new ZPLTextBlock(sampleText, 10, 600, 400, 100, font)); var renderEngine = new ZPLEngine(elements); var output = renderEngine.ToZPLString(new ZPLRenderOptions() { AddEmptyLineBeforeElementStart = true }); Console.WriteLine(output); }
public static int FontHeight(ZPLFont font, int?altoFuenteDescripcion) { int height = 10; if (altoFuenteDescripcion.HasValue) { height = altoFuenteDescripcion.Value; } switch (font) { case ZPLFont.FONT_A: return(5); case ZPLFont.FONT_B: return(7); case ZPLFont.FONT_C: case ZPLFont.FONT_D: return(10); case ZPLFont.FONT_E: return(20); case ZPLFont.FONT_F: return(13); case ZPLFont.FONT_G: return(40); case ZPLFont.FONT_H: return(22); case ZPLFont.FONT_P: return(18); case ZPLFont.FONT_Q: return(24); case ZPLFont.FONT_R: return(31); case ZPLFont.FONT_S: return(35); case ZPLFont.FONT_T: return(42); case ZPLFont.FONT_U: return(53); case ZPLFont.FONT_V: return(71); default: return(height); } }
public void ChaituTest() { var sampleText = "[_~^][LineBreak\n][Kühne + Nagel]"; ZPLFont font = new ZPLFont(fontWidth: 50, fontHeight: 50); var labelElements = new List <ZPLElementBase>(); //Specail character is repalced with space labelElements.Add(new ZPLTextField(sampleText, 10, 10, font, useHexadecimalIndicator: false)); var renderEngine = new ZPLEngine(labelElements); var output = renderEngine.ToZPLString(new ZPLRenderOptions() { AddEmptyLineBeforeElementStart = true }); Console.WriteLine(output); }
public static byte[] TextWrite(int left, int top, ElementDrawRotation rotation, ZPLFont font, int height, int width, string text, int codepage = 1252) { 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))); }
/// <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)}")); }
/// <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(Encoding.GetEncoding(codepage).GetBytes($"^FO{left},{top}^A{(char)font}{(char)rotation},{height},{width}^FD{text}^FS")); }