public void PrintVoucher(string printerName, string printDocumentName, int length, string documentInitialization, IList <IPrintLine> lines) { Debug.Assert(!string.IsNullOrEmpty(printerName)); var b = new StringBuilder(); b.Append(MTPL.PUMOn(true)); b.Append(MTPL.SetFormLength(length));//6119 b.AppendLine(documentInitialization); PrintLine lastLine = null; const int MIN_V_STEP = 50; foreach (PrintLine line in lines) { if (lastLine == null || Math.Abs(line.Y - lastLine.Y) > MIN_V_STEP) { b.Append(MTPL.SetAbsolutePosition((int)line.X, (int)line.Y)); } else { b.Append(MTPL.SetAbsoluteHorizontalPosition((int)line.X)); } line.Print(b); lastLine = line; } b.Append(ASCII.FF); string text = b.ToString(); PrinterQueue.AddJob(printerName, printDocumentName, text); }
public void czech_print_format_TypeX_2() { var str = MTPL.NumToString("0A313233FF"); var str2 = MTPL.NumToString("32323232", 10); //Oki var docText1 = Helper.ToChr(27, 16, 65, 8, 3, 0, 1, 2, 1, 1, 1, 2, 30, 31, 32, 33, 34, 35, 36, 37) + ASCII.LF + ASCII.FF; var docText2 = string.Format(@"{0}it1r1s0x70y00b{1}\\", (char)27, 123456789) + ASCII.LF + ASCII.FF; var docText3 = MTPL.PrintI2Of5Barcode("123456789", 10, "000") + ASCII.FF; var docText4 = MTPL.NumToString("494E5445534C45415645442032204F4620350A0D1B10410803000102010101021B10420A313233343536373839300FFF"); var docText5 = ASCII.ESC + "it130r1s0x00y170b123456789012?+12345\\" + ASCII.LF + ASCII.FF; var docText6 = ASCII.ESC + "ih10w10x25y230lSample\\" + ASCII.LF + ASCII.ESC + "ix90y230s4h10w10f2g2e" + ASCII.LF + ASCII.ESC + "ix105y230s4h10w10v" + ASCII.LF + ASCII.FF; var docText7 = MTPL.PrintUSPSBarcode("123445") + ASCII.LF + ASCII.FF; var docText8 = MTPL.NumToString("271666101234567890") + ASCII.LF + ASCII.FF; var docText9 = MTPL.NumToString("1B 10 42 0A 31 32 33 34 35 36 37 38 39 30") + ASCII.LF + ASCII.FF; DirectHelper.SendStringToPrinter(Printers.Tally_T2365_2T, "test", docText9); }
public void PrintVoucher(string printerName, string printDocName, int length, string docInitialization, IList <IPrintLine> lines) { StringBuilder builder = new StringBuilder(); //Setting form length if (FormLength > 0) { builder.Append(MTPL.SetFormLength(FormLength)); } builder.Append(Context); builder.Clean(); //Parse commands var pattern1 = @"\[cmd\s*:\s*{([^}]*)\}\s*\]"; //{(char)27 + "[11w"} var re1 = new Regex(pattern1, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline); re1.Replace(ref builder, (ma) => { return(ma.Groups[1].Success ? CacheManager.Instance.Table.GetValueAdd <string>(ma.Groups[1].Value, new Func <string>(() => Convert.ToString(CommonTools.Eval(ma.Groups[1].Value)))) : null); }); //Replace spaces builder.Replace("<nbsp>", " "); //<ht><ht>[VATNumber,10]<ht>[VATNumber,-10]<ht>[VATNumber]<br> foreach (PrintLine line in lines) { //Parse params var pattern2 = string.Format(@"\[(?<name>{0})(?<value>,\-?\d+)?\]", line.Description); var re2 = new Regex(pattern2, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline); re2.Replace(ref builder, (ma) => { if (ma.Groups[2].Success) { return(string.Format(string.Concat("{0", ma.Groups["value"].Value, "}"), line.Text)); } else if (ma.Groups[1].Success) { return(line.Text ?? ""); } else { return(null); } }); } //Replace htabs builder.Replace("<ht>", ASCII.HT); //Replace vtabs builder.Replace("<vt>", ASCII.VT); //Replace line breaks builder.Replace("<br>", ASCII.LF + ASCII.CR); //End of form builder.Append(ASCII.FF); var docText = builder.ToString(); PrinterQueue.AddJob(printerName, printDocName, docText); }
public virtual void Print(StringBuilder b) { b.Append(MTPL.SetFontDensity((Cpi)this.Size)); b.Append(this.Text); }
public override void Print(StringBuilder b) { b.AppendLine(MTPL.PrintI2Of5Barcode(base.Text, base.Size, this.XYZ)); b.AppendLine(); }