Esempio n. 1
0
        /// <summary>
        /// This is the method we print the receipt the way we want. Note the spaces.
        /// Wasted a lot of paper on this to get it right.
        /// </summary>
        /// <param name="bw"></param>
        private static void PrintReceipt(BookingReceipt r, BinaryWriter bw)
        {
            bw.Start();
            bw.NormalFont("Served By: " + r.servedBy);

            bw.FeedLines(1);
            bw.NormalFont("..............................");
            bw.FeedLines(1);

            bw.NormalFont("Date: " + r.date);
            bw.NormalFont("Invoice #: " + r.invoiceNumber);
            bw.NormalFont("Customer: " + r.customerName);
            bw.FeedLines(1);

            bw.NormalFont(r.booking + " " + r.amountDue);
            bw.NormalFont("Discount:              " + r.discount);

            bw.FeedLines(2);
            bw.High("    Total:         " + r.totalDue);

            bw.FeedLines(2);
            bw.NormalFont("Payment:              " + r.amountPaid);
            bw.NormalFont("Balance:              " + r.balance);

            bw.Finish();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                string receiptData = args[0];
                Console.WriteLine(receiptData);

                BookingReceipt r = JsonConvert.DeserializeObject <BookingReceipt>(receiptData);

                Console.WriteLine(r.servedBy);
                Print(PrinterName, GetDocument(r));
            }
            else
            {
                Console.WriteLine("you must pass receipt data as json string");
                Environment.Exit(1);
            }
        }
Esempio n. 3
0
        private static byte[] GetDocument(BookingReceipt r)
        {
            using (var ms = new MemoryStream())
                using (var bw = new BinaryWriter(ms))
                {
                    // Reset the printer bws (NV images are not cleared)
                    bw.Write(AsciiControlChars.Escape);
                    bw.Write('@');

                    // Render the logo
                    //RenderLogo(bw);
                    PrintReceipt(r, bw);

                    // Feed 3 vertical motion units and cut the paper with a 1 point cut
                    bw.Write(AsciiControlChars.GroupSeparator);
                    bw.Write('V');
                    bw.Write((byte)66);
                    bw.Write((byte)3);

                    bw.Flush();

                    return(ms.ToArray());
                }
        }