Пример #1
0
        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);
        }
Пример #2
0
        public override void PrintVouchers(string printerName, string printDocName, int length, string docInitialization, Queue <IList <IPrintLine> > multilines)
        {
            var ma = m_BodyRegEx.Match(m_Output);

            if (!ma.Groups[1].Success)
            {
                throw new Exception("Can't find body tag");
            }

            if (string.IsNullOrWhiteSpace(ma.Groups[1].Value))
            {
                throw new Exception("Body tag is empty");
            }

            StringBuilder builder = new StringBuilder();

            builder.Append(ma.Groups[1].Value);
            //Replace spaces
            builder.Replace("<nbsp>", " ");
            //Replace htabs
            builder.Replace("<ht>", ASCII.HT);
            //Replace vtabs
            builder.Replace("<vt>", ASCII.VT);
            //Replace lf
            builder.Replace("<lf>", ASCII.LF);
            //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);
        }
Пример #3
0
        public virtual void InitPrinter(string printDoc)
        {
#if INIT_PRINTER_PER_RETAILER
            var b = new StringBuilder();
            b.Append(PtfTally.PUMOn(true));
            b.Append(PtfTally.SetPositionalUnitMode(SSU.Millimeters));
            b.Append(PtfTally.SetFormLength(Settings.FormLength));//6119
            b.Append(PtfTally.HQMode);
            PrinterQueue.AddJob(printDoc, b.ToString());
#endif
        }
Пример #4
0
        public void PrintVoucher(string printName, string printDocName, int length, string docInitialization, IList <IPrintLine> lines)
        {
            StringBuilder b = new StringBuilder();

            //b.Append(ESC_P2.SetPageLengthLines(layout.FormLength));
            //b.Append(layout.Context);
            //b.Clean();

            //b.Replace("<nbsp>", " ");

            //foreach (PrintLine line in lines)
            //    b.Replace(string.Format("[{0}]", line.Description), line.Text);

            //b.Replace("<ht>", ESC_P2.HT);
            //b.Replace("<vt>", ESC_P2.VT);
            //b.Replace("<br>", ESC_P2.LF);
            //b.Append(ESC_P2.FF);

            var docText = b.ToString();

            PrinterQueue.AddJob(printName, printDocName, docText);
        }
Пример #5
0
        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);
        }