Example #1
0
 public static byte[] TextStyles(ICommandEmitter e)
 {
     return(ByteSplicer.Combine(
                e.SetStyles(PrintStyle.None),
                e.Print("Default: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.FontB),
                e.Print("Font B: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.Bold),
                e.Print("Bold: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.Underline),
                e.Print("Underline: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.DoubleWidth),
                e.Print("DoubleWidth: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.DoubleHeight),
                e.Print("DoubleHeight: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Underline |
                            PrintStyle.Bold),
                e.Print("All Styles: The quick brown fox jumped over the lazy dogs.\n"),
                e.SetStyles(PrintStyle.None),
                e.ReverseMode(true),
                e.PrintLine("REVERSE MODE: The quick brown fox jumped over the lazy dogs."),
                e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth),
                e.PrintLine("REVERSE MODE: The quick brown fox jumped over the lazy dogs."),
                e.SetStyles(PrintStyle.None),
                e.ReverseMode(false),
                e.SetStyles(PrintStyle.None),
                e.RightCharacterSpacing(5),
                e.PrintLine("Right space 5: The quick brown fox jumped over the lazy dogs."),
                e.RightCharacterSpacing(0),
                e.SetStyles(PrintStyle.None),
                e.UpsideDownMode(true),
                e.PrintLine("Upside Down Mode: The quick brown fox jumped over the lazy dogs."),
                e.UpsideDownMode(false)
                ));
 }
Example #2
0
        public static byte[] TwoDimensionCodes(ICommandEmitter e) =>
        ByteSplicer.Combine(
            e.PrintLine("PDF417:"),
            e.Print2DCode(TwoDimensionCodeType.PDF417, websiteString),
            e.PrintLine(),

            e.PrintLine("PDF417 (TINY):"),
            e.Print2DCode(TwoDimensionCodeType.PDF417, websiteString, Size2DCode.TINY),
            e.PrintLine(),

            e.PrintLine("PDF417 (LARGE):"),
            e.Print2DCode(TwoDimensionCodeType.PDF417, websiteString, Size2DCode.LARGE),
            e.PrintLine(),

            e.PrintLine("QRCODE MODEL 1:"),
            e.Print2DCode(TwoDimensionCodeType.QRCODE_MODEL1, websiteString),
            e.PrintLine(),

            e.PrintLine("QRCODE MODEL 2:"),
            e.PrintQRCode(websiteString),
            e.PrintLine(),

            e.PrintLine("QRCODE MICRO:"),
            e.Print2DCode(TwoDimensionCodeType.QRCODE_MICRO, websiteString),
            e.PrintLine(),

            e.PrintLine("QRCODE MODEL 1 (TINY):"),
            e.Print2DCode(TwoDimensionCodeType.QRCODE_MODEL1, websiteString, Size2DCode.TINY),
            e.PrintLine(),

            e.PrintLine("QRCODE MODEL 1 (LARGE):"),
            e.Print2DCode(TwoDimensionCodeType.QRCODE_MODEL1, websiteString, Size2DCode.LARGE),
            e.PrintLine()
            );
Example #3
0
 public static byte[] Images(ICommandEmitter e, bool isLegacy)
 {
     return(ByteSplicer.Combine(
                e.CenterAlign(),
                e.PrintLine("Test PNG images with widths 100 - 600 px,"),
                e.PrintLine("at native resolution"),
                e.PrintLine("-- pd-logo-100.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-100.png"), true, isLegacy),
                e.PrintLine("-- pd-logo-200.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-200.png"), true, isLegacy),
                e.PrintLine("-- pd-logo-300.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy),
                e.PrintLine("-- pd-logo-400.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-400.png"), true, isLegacy),
                e.PrintLine("-- pd-logo-500.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-500.png"), true, isLegacy),
                e.PrintLine("-- pd-logo-600.png --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-600.png"), true, isLegacy),
                e.PrintLine("Test resizing 600 px image to 300px"),
                e.PrintLine("-- pd-logo-600.png /300 --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-600.png"), true, isLegacy, 300),
                e.PrintLine("Test image with taller height than width"),
                e.PrintLine("-- abe-lincoln.png /300 --"),
                e.PrintImage(File.ReadAllBytes("images/abe-lincoln.png"), true, isLegacy, 300),
                e.PrintLine("Test 300px image resized to all remainders of 8,"),
                e.PrintLine("to ensure overflow checking"),
                e.PrintLine("-- pd-logo-300.png /296 (0 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 296),
                e.PrintLine("-- pd-logo-300.png /297 (1 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 297),
                e.PrintLine("-- pd-logo-300.png /298 (2 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 298),
                e.PrintLine("-- pd-logo-300.png /299 (3 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 299),
                e.PrintLine("-- pd-logo-300.png /300 (4 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 300),
                e.PrintLine("-- pd-logo-300.png /301 (5 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 301),
                e.PrintLine("-- pd-logo-300.png /302 (6 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 302),
                e.PrintLine("-- pd-logo-300.png /303 (7 remainder) --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, isLegacy, 303),
                e.PrintLine("Test 300px image in JPG format"),
                e.PrintLine("-- pd-logo-300.jpg --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.jpg"), true, isLegacy),
                e.PrintLine("Test 300px image in BMP format"),
                e.PrintLine("-- pd-logo-300.jpg --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.bmp"), true, isLegacy),
                e.PrintLine("Test 300px image in GIF format"),
                e.PrintLine("-- pd-logo-300.jpg --"),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.gif"), true, isLegacy),
                e.PrintLine("Test full color image converted"),
                e.PrintLine("to black and white and interpolated"),
                e.PrintLine("-- kitten.jpg --"),
                e.PrintImage(File.ReadAllBytes("images/kitten.jpg"), true, isLegacy, 500),
                e.PrintLine("-- portal companion cube.jpg --"),
                e.PrintImage(File.ReadAllBytes("images/Portal_Companion_Cube.jpg"), true, isLegacy, 500)));
 }
Example #4
0
        public static byte[] Images(ICommandEmitter e)
        {
            Stopwatch s = Stopwatch.StartNew();

            return(ByteSplicer.Combine(
                       e.CenterAlign(),
                       e.PrintLine("Test PNG images with widths 100 - 600 px at native resolution"),
                       e.PrintLine("-- pd-logo-100.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-100.png"), true),
                       e.PrintLine("-- pd-logo-200.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-200.png"), true),
                       e.PrintLine("-- pd-logo-300.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true),
                       e.PrintLine("-- pd-logo-400.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-400.png"), true),
                       e.PrintLine("-- pd-logo-500.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-500.png"), true),
                       e.PrintLine("-- pd-logo-600.png --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-600.png"), true),
                       //e.PrintImage(File.ReadAllBytes("abe-lincoln.png"), true, 257),
                       e.PrintLine("Test resizing 600 px image to 300px"),
                       e.PrintLine("-- pd-logo-600.png /300 --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-600.png"), true, 300),
                       e.PrintLine("Test image with taller height than width"),
                       e.PrintLine("-- abe-lincoln.png /300 --"),
                       e.PrintImage(File.ReadAllBytes("images/abe-lincoln.png"), true, 300),
                       e.PrintLine("Test 300px image resized to all remainders of 8 to ensure overflow checking"),
                       e.PrintLine("-- pd-logo-300.png /296 (0 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 296),
                       e.PrintLine("-- pd-logo-300.png /297 (1 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 297),
                       e.PrintLine("-- pd-logo-300.png /298 (2 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 298),
                       e.PrintLine("-- pd-logo-300.png /299 (3 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 299),
                       e.PrintLine("-- pd-logo-300.png /300 (4 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 300),
                       e.PrintLine("-- pd-logo-300.png /301 (5 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 301),
                       e.PrintLine("-- pd-logo-300.png /302 (6 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 302),
                       e.PrintLine("-- pd-logo-300.png /303 (7 remainder) --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true, 303),
                       e.PrintLine("Test 300px image in JPG format"),
                       e.PrintLine("-- pd-logo-300.jpg --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.jpg"), true),
                       e.PrintLine("Test 300px image in BMP format"),
                       e.PrintLine("-- pd-logo-300.jpg --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.bmp"), true),
                       e.PrintLine("Test 300px image in GIF format"),
                       e.PrintLine("-- pd-logo-300.jpg --"),
                       e.PrintImage(File.ReadAllBytes("images/pd-logo-300.gif"), true),
                       e.PrintLine("Test full color image converted to black and white"),
                       e.PrintLine("-- kitten.jpg --"),
                       e.PrintImage(File.ReadAllBytes("images/kitten.jpg"), true, 400),
                       e.PrintLine("Time taken: " + s.ElapsedMilliseconds + "ms")
                       ));
        }
Example #5
0
 public byte[] PrintImage(byte[] image, bool isHiDPI, bool isLegacy = false, int maxWidth = -1, int color = 1)
 {
     if (isLegacy)
     {
         return(ByteSplicer.Combine(BufferImage(image, maxWidth, isLegacy)));
     }
     return(ByteSplicer.Combine(SetImageDensity(isHiDPI), BufferImage(image, maxWidth, isLegacy, color),
                                WriteImageFromBuffer()));
 }
        public static byte[] BarcodeStyles(ICommandEmitter e) =>
        ByteSplicer.Combine(
            //TODO: test all widths and put bar in front in label
            e.PrintLine("Thinnest Width:"),
            e.SetBarcodeHeightInDots(300),
            e.SetBarWidth(BarWidth.Thinnest),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Thin Width:"),
            e.SetBarcodeHeightInDots(300),
            e.SetBarWidth(BarWidth.Thin),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Default Width:"),
            e.SetBarcodeHeightInDots(300),
            e.SetBarWidth(BarWidth.Default),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Thicker Width:"),
            e.SetBarcodeHeightInDots(300),
            e.SetBarWidth(BarWidth.Thick),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Thickest Width:"),
            e.SetBarcodeHeightInDots(300),
            e.SetBarWidth(BarWidth.Thickest),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),


            e.PrintLine("Short (50 dots):"),
            e.SetBarcodeHeightInDots(50),
            e.SetBarWidth(BarWidth.Default),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Tall (255 dots):"),
            e.SetBarcodeHeightInDots(255),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Label Above:"),
            e.SetBarcodeHeightInDots(50),
            e.SetBarLabelPosition(BarLabelPrintPosition.Above),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Label Above and Below:"),
            e.SetBarLabelPosition(BarLabelPrintPosition.Both),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Label Below:"),
            e.SetBarLabelPosition(BarLabelPrintPosition.Below),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905"),

            e.PrintLine("Font B Label Below:"),
            e.SetBarLabelFontB(true),
            e.PrintBarcode(BarcodeType.UPC_A, "012345678905")

            );
 public static byte[] LineSpacing(ICommandEmitter e) =>
 ByteSplicer.Combine(
     e.SetLineSpacingInDots(200),
     e.PrintLine("This is the default spacing."),
     e.SetLineSpacingInDots(15),
     e.PrintLine("This has 200 dots of spacing above."),
     e.ResetLineSpacing(),
     e.PrintLine("This has 15 dots of spacing above."),
     e.PrintLine("This has the default spacing.")
     );
 public static byte[] BarcodeTypes(ICommandEmitter e)
 {
     return(ByteSplicer.Combine(
                e.SetBarcodeHeightInDots(600),
                e.SetBarWidth(BarWidth.Thinnest),
                e.SetBarLabelPosition(BarLabelPrintPosition.Below),
                e.PrintLine("CODABAR_NW_7:"),
                e.PrintBarcode(BarcodeType.CODABAR_NW_7, "A31117013206375B"),
                e.PrintLine("CODE128:"),
                e.PrintBarcode(BarcodeType.CODE128, "ESC_POS_NET"),
                e.PrintLine(),
                e.PrintLine("CODE128 Type C:"),
                e.PrintBarcode(BarcodeType.CODE128, "123456789101", BarcodeCode.CODE_C),
                e.PrintLine(),
                e.PrintLine("CODE39:"),
                e.PrintBarcode(BarcodeType.CODE39, "*ESC-POS-NET*"),
                e.PrintLine(),
                e.PrintLine("CODE93:"),
                e.PrintBarcode(BarcodeType.CODE93, "*ESC_POS_NET*"),
                e.PrintLine(),
                e.PrintLine("GS1_128:"),
                e.PrintBarcode(BarcodeType.GS1_128, "(01)9501234567890*"),
                e.PrintLine(),
                e.PrintLine("GS1_DATABAR_EXPANDED:"),
                e.PrintBarcode(BarcodeType.GS1_DATABAR_EXPANDED, "0001234567890"),
                e.PrintLine(),
                e.PrintLine("GS1_DATABAR_LIMITED:"),
                e.PrintBarcode(BarcodeType.GS1_DATABAR_LIMITED, "0001234567890"),
                e.PrintLine(),
                e.PrintLine("GS1_DATABAR_OMNIDIRECTIONAL:"),
                e.PrintBarcode(BarcodeType.GS1_DATABAR_OMNIDIRECTIONAL, "0001234567890"),
                e.PrintLine(),
                e.PrintLine("GS1_DATABAR_TRUNCATED:"),
                e.PrintBarcode(BarcodeType.GS1_DATABAR_TRUNCATED, "0001234567890"),
                e.PrintLine(),
                e.PrintLine("ITF:"),
                e.PrintBarcode(BarcodeType.ITF, "1234567895"),
                e.PrintLine(),
                e.PrintLine("JAN13_EAN13:"),
                e.PrintBarcode(BarcodeType.JAN13_EAN13, "5901234123457"),
                e.PrintLine(),
                e.PrintLine("JAN8_EAN8:"),
                e.PrintBarcode(BarcodeType.JAN8_EAN8, "96385074"),
                e.PrintLine(),
                e.PrintLine("UPC_A:"),
                e.PrintBarcode(BarcodeType.UPC_A, "042100005264"),
                e.PrintLine(),
                e.PrintLine("UPC_E:"),
                e.PrintBarcode(BarcodeType.UPC_E, "425261"),
                e.PrintLine()
                ));
 }
Example #9
0
 public static byte[] Printing(ICommandEmitter e) =>
 ByteSplicer.Combine(
     e.Print("Multiline Test: Windows...\r\nOSX...\rUnix...\n"),
     //TODO: sanitize test.
     e.PrintLine("Feeding 250 dots."),
     e.FeedDots(250),
     e.PrintLine("Feeding 3 lines."),
     e.FeedLines(3),
     e.PrintLine("Done Feeding."),
     e.PrintLine("Reverse Feeding 6 lines."),
     e.FeedLinesReverse(6),
     e.PrintLine("Done Reverse Feeding.")
     );
Example #10
0
 public static byte[] GetReceiptFooter(ICommandEmitter e) =>
 ByteSplicer.Combine(
     e.LeftAlign(),
     e.PrintLine("SUBTOTAL"),
     e.PrintLine(),
     e.PrintLine(),
     e.CenterAlign(),
     e.SetStyles(PrintStyle.None),
     e.PrintLine($"{DateTime.Today.ToShortDateString()}"),
     e.PrintLine("Made With Love"),
     e.PrintLine("Tibo Van De Sijpe"),
     e.PrintLine("Bram Van den Abbeele"),
     e.PrintLine("Pierre Vanvolsem")
     );
Example #11
0
 public static byte[] Receipt(ICommandEmitter e)
 {
     return(ByteSplicer.Combine(
                e.CenterAlign(),
                e.PrintImage(File.ReadAllBytes("images/pd-logo-300.png"), true),
                e.PrintLine(),
                e.SetBarcodeHeightInDots(360),
                e.SetBarWidth(BarWidth.Default),
                e.SetBarLabelPosition(BarLabelPrintPosition.None),
                e.PrintBarcode(BarcodeType.ITF, "0123456789"),
                e.PrintLine(),
                e.PrintLine("B&H PHOTO & VIDEO"),
                e.PrintLine("420 NINTH AVE."),
                e.PrintLine("NEW YORK, NY 10001"),
                e.PrintLine("(212) 502-6380 - (800)947-9975"),
                e.SetStyles(PrintStyle.Underline),
                e.PrintLine("www.bhphotovideo.com"),
                e.SetStyles(PrintStyle.None),
                e.PrintLine(),
                e.LeftAlign(),
                e.PrintLine("Order: 123456789        Date: 02/01/19"),
                e.PrintLine(),
                e.PrintLine(),
                e.SetStyles(PrintStyle.FontB),
                e.PrintLine("1   TRITON LOW-NOISE IN-LINE MICROPHONE PREAMP"),
                e.PrintLine("    TRFETHEAD/FETHEAD                        89.95         89.95"),
                e.PrintLine("----------------------------------------------------------------"),
                e.RightAlign(),
                e.PrintLine("SUBTOTAL         89.95"),
                e.PrintLine("Total Order:         89.95"),
                e.PrintLine("Total Payment:         89.95"),
                e.PrintLine(),
                e.LeftAlign(),
                e.SetStyles(PrintStyle.Bold | PrintStyle.FontB),
                e.PrintLine("SOLD TO:                        SHIP TO:"),
                e.SetStyles(PrintStyle.FontB),
                e.PrintLine("  LUKE PAIREEPINART               LUKE PAIREEPINART"),
                e.PrintLine("  123 FAKE ST.                    123 FAKE ST."),
                e.PrintLine("  DECATUR, IL 12345               DECATUR, IL 12345"),
                e.PrintLine("  (123)456-7890                   (123)456-7890"),
                e.PrintLine("  CUST: 87654321"),
                e.PrintLine(),
                e.PrintLine()
                ));
 }
Example #12
0
 public static byte[] TextStyles(ICommandEmitter e) =>
 ByteSplicer.Combine(
     e.SetStyles(PrintStyle.None),
     e.Print("Default: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.FontB),
     e.Print("Font B: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.Bold),
     e.Print("Bold: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.Underline),
     e.Print("Underline: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.DoubleWidth),
     e.Print("DoubleWidth: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.DoubleHeight),
     e.Print("DoubleHeight: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Underline | PrintStyle.Bold),
     e.Print("All Styles: The quick brown fox jumped over the lazy dogs.\n"),
     e.SetStyles(PrintStyle.None)
     );
Example #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter printer IP address: (e.g. 192.168.0.2) default port is 9100");
            var ip      = Console.ReadLine();
            var printer = new NetworkPrinter(string.IsNullOrEmpty(ip) ? "192.168.3.100" : ip, 9100, true);

            var e = new EPSON();

            printer.Write(ByteSplicer.Combine(
                              e.Initialize(),
                              e.PrintLine("Hello Xprinter!"),
                              e.CodePage(CodePage.CHINA),
                              e.PrintLine("中文菜单"),
                              e.FullCutAfterFeed(3)
                              ));

            Console.Read();
        }
Example #14
0
 public static byte[] GetReceiptHeader(ICommandEmitter e, Horeka.Data.Occupancy occupancy) =>
 ByteSplicer.Combine(
     e.CenterAlign(),
     e.PrintLine("HOREKA APPLICATIE"),
     e.PrintLine(),
     e.PrintLine(),
     e.PrintLine("Odisee Brussel"),
     e.PrintLine("Warmoesberg 26"),
     e.PrintLine("Belgium, Brussels, 1000"),
     e.PrintLine("0496/12.12.12"),
     e.SetStyles(PrintStyle.Underline),
     e.PrintLine("www.odisee.be"),
     e.SetStyles(PrintStyle.None),
     e.PrintLine(),
     e.LeftAlign(),
     e.PrintLine($"Order: {occupancy.ID}"),
     e.PrintLine(),
     e.PrintLine()
     );
Example #15
0
        public void PrintQRCode_Success(TwoDimensionCodeType codeType, Size2DCode size2DCode, CorrectionLevel2DCode correctionLevel2DCode)
        {
            string data     = codeType == TwoDimensionCodeType.QRCODE_MICRO ? SHORTER_WEBSITE_STRING : WEBSITE_STRING;
            var    begining = new byte[] { 29, 40, 107, 4, 0, 49, 65, (byte)codeType, 0, 29, 40, 107, 3, 0, 49, 67, (byte)size2DCode, 29, 40, 107, 3, 0, 49, 69, (byte)correctionLevel2DCode, 29, 40, 107, (byte)(data.Length + 3), 0, 49, 80, 48, 104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47 };
            var    ending   = new byte[] { 29, 40, 107, 3, 0, 49, 81, 48 };

            byte[] result;
            if (codeType == TwoDimensionCodeType.QRCODE_MICRO)
            {
                result = ByteSplicer.Combine(begining, ending);
            }
            else
            {
                var longerStr = new byte[] { 108, 117, 107, 101, 118, 112, 47, 69, 83, 67, 45, 80, 79, 83, 45, 46, 78, 69, 84, 47, };
                result = ByteSplicer.Combine(begining, longerStr, ending);
            }

            Assert.Equal(result, new EPSON().Print2DCode(codeType, data, size2DCode, correctionLevel2DCode));
        }
Example #16
0
        static void Main(string[] args)
        {
            FilePrinter printer = new FilePrinter("/dev/usb/lp0");
            var         p       = new ESCP();

            printer.Write(ByteSplicer.Combine(
                              p.PrintLine("Hello"),
                              p.SetPrintStyle(PrintStyle.Bold),
                              p.Beep(),
                              p.PrintLine("sadasd"),
                              p.SelectJustification(Justification.Center),
                              p.SetPrintStyle(PrintStyle.None),
                              p.Select15Cpi(),
                              p.SelectPrintQuality(PrintQuality.LQ_NLQ),
                              p.PrintLine("The end"),
                              p.SelectJustification(Justification.Left)
                              ));
            Console.ReadKey();
        }
Example #17
0
        static void StartPrintJungsan(JObject json)
        {
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            printer.Write(
                ByteSplicer.Combine(
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("판매집계표"),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight),
                    e.PrintLine(json["date"].ToString()),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------")
                    ));
            printer.Write(
                ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth),
                    e.LeftAlign(),
                    e.PrintLine("구분 \t\t 건수 \t\t 금액"),
                    e.PrintLine("--------------------------"),
                    e.PrintLine("총매출액 \t\t\t" + json["totalCnt"] + " \t\t " + json["totalPrice"]),
                    e.PrintLine("텀블러할인 \t\t\t" + json["discountCnt"] + " \t\t " + json["discountPrice"]),
                    e.PrintLine("취소 \t\t\t" + json["canceledCnt"] + " \t\t " + json["canceledPrice"]),
                    e.PrintLine("--------------------------"),
                    e.PrintLine("순매출액 \t\t\t" + json["sunCnt"] + " \t\t " + json["sunPrice"]),
                    e.FeedLines(3),
                    e.FullCut()
                    ));

            printer.Dispose();
        }
Example #18
0
        // 다시 프린트
        static void StartLongPrint(JObject json)
        {
            //프린터 연결
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            // 메뉴 해쉬코드 - 내용 딕셔너리
            Dictionary <string, JToken> menuDictionary = new Dictionary <string, JToken>();
            Dictionary <string, int>    menuPriceTable = new Dictionary <string, int>();

            // 각 메뉴마다 수량 겟하고 내용 저장
            foreach (var menu in json["menus"])
            {
                string menuName  = menu["name"].ToString();
                int    menuPrice = menu["totalPrice"].ToObject <int>();

                if (menuDictionary.ContainsKey(menuName))
                {
                    menuDictionary[menuName]["quantity"] = menuDictionary[menuName]["quantity"].ToObject <int>() + 1;
                    menuPriceTable[menuName]            += menuPrice;
                }
                else
                {
                    menu["quantity"] = 1;

                    var option = menu["options"].First;

                    // 옵션 확인하고 수량 없으면 삭제
                    while (option != null)
                    {
                        var currentOption = option;
                        option = currentOption.Next;
                        if (currentOption["quantity"].ToObject <int>() <= 0)
                        {
                            currentOption.Remove();
                        }
                    }

                    menuDictionary.Add(menuName, menu);
                    menuPriceTable.Add(menuName, menuPrice);
                }
            }

            string orderNum = json["orderNum"].ToString();

            printer.Write(
                ByteSplicer.Combine(
                    e.FeedLines(1),
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("주문번호: " + orderNum),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.FeedLines(1),
                    e.PrintLine("11호관 커피숍"),
                    e.PrintLine("울산시 남구 대학로 93 11호관 305호"),
                    e.PrintLine("TEL.052-220-5757"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                    e.PrintLine("---------------------------"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.LeftAlign(),
                    e.PrintLine("  메뉴\t\t\t\t수량\t\t가격"),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                    e.PrintLine("---------------------------")
                    ));

            byte[] bodyBytes = e.FeedLines(1);
            foreach (var menu in menuDictionary.Values)
            {
                int    menu_quantity = menu["quantity"].ToObject <int>();
                string menu_price    = menu["totalPrice"].ToString();
                string menu_name     = menu["name"].ToString();

                // (온도) 메뉴이름 (포장여부)
                string menu_name_line = menu_name;

                byte[] menuBytes = ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                    e.PrintLine("  " + menu_name_line + "\t\t\t\t" + menu_quantity + "\t\t" + menuPriceTable[menu_name])
                    );
                bodyBytes = ByteSplicer.Combine(bodyBytes, menuBytes, e.FeedLines(1));
            }

            printer.Write(bodyBytes);

            string orderPrice  = json["totalPrice"].ToString();
            int    supplyPrice = (int)(json["totalPrice"].ToObject <int>() / 1.1);
            int    tax         = json["totalPrice"].ToObject <int>() - supplyPrice;

            printer.Write(ByteSplicer.Combine(
                              e.FeedLines(1),
                              e.RightAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                              e.PrintLine("합계금액 : " + orderPrice + " 원"),
                              e.PrintLine("공급가액 : " + supplyPrice + " 원"),
                              e.PrintLine("부가세 : " + tax + " 원"),
                              e.LeftAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.Bold | PrintStyle.DoubleWidth),
                              e.PrintLine("---------------------------")
                              ));

            printer.Write(ByteSplicer.Combine(
                              e.FeedLines(1),
                              e.CenterAlign(),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.Bold),
                              e.PrintLine("신용카드 승인 정보"),
                              e.SetStyles(PrintStyle.FontB | PrintStyle.Bold),
                              e.PrintLine("카드명: " + json["cardCompany"].ToString()),
                              e.PrintLine("카드번호: " + json["cardNumber"].ToString() + "**********"),
                              e.PrintLine("매입사명: " + json["aqCompany"].ToString()),
                              e.FeedLines(1),
                              e.PrintLine("사업자:  691-85-00176 엄문호"),
                              e.PrintLine("가맹점명:  11호관 커피숍"),
                              e.PrintLine("가맹번호:  157431024"),
                              e.PrintLine("승인일시:  " + json["ApprovalDate"].ToString()),
                              e.PrintLine("승인번호:  " + json["ApprovalNumber"].ToString()),
                              e.PrintLine("승인금액:  " + orderPrice + "원"),
                              e.FeedLines(1),
                              e.PrintLine("11호관 카페를 이용해주셔서 감사합니다.")
                              ));

            printer.Write(
                ByteSplicer.Combine(e.FeedLines(3)));

            printer.Write(
                ByteSplicer.Combine(
                    e.FullCut()
                    )
                );
            //프린터 해제
            printer.Dispose();
        }
Example #19
0
        public void printOutSlip_Backup(responseSaveVn app)
        {
            try
            {
                SerialPrinter printer = new SerialPrinter(portName: "COM3", baudRate: 38400);

                EPSON e = new EPSON();

                string fontName = "Tahoma";

                Font fontRegular       = new Font(fontName, 26, FontStyle.Regular, GraphicsUnit.Pixel);
                Font fontBoldUnderline = new Font(fontName, 26, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);
                Font fontBold          = new Font(fontName, 26, FontStyle.Bold, GraphicsUnit.Pixel);
                Font fontJumbo         = new Font(fontName, 48, FontStyle.Bold | FontStyle.Underline, GraphicsUnit.Pixel);

                byte[] ImgTitle = DrawText($"ใช้บริการโดยตู้ Kiosk {app.dateSave}", fontRegular);
                byte[] ImgEx    = DrawText(app.ex, fontBoldUnderline);
                byte[] ImgVn    = DrawText("HN : " + app.hn + "\nVN : " + app.vn, fontJumbo);
                byte[] ImgName  = DrawText($"ชื่อ : {app.ptname}", fontRegular);

                byte[] ImgPtright = DrawText($"สิทธิ : {app.ptright}", fontBoldUnderline);

                string extraTxt = "";
                if (!String.IsNullOrEmpty(app.hospCode))
                {
                    extraTxt += $"\n{app.hospCode}";
                }

                if (!String.IsNullOrEmpty(app.doctor))
                {
                    extraTxt += $"\n{app.doctor}";
                }

                byte[] ImgHn = DrawText($"อายุ {app.age}\nบัตร ปชช. : {app.idcard}\n{app.mx}{extraTxt}", fontRegular);


                printer.Write(
                    ByteSplicer.Combine(
                        e.CenterAlign(),
                        e.PrintImage(File.ReadAllBytes("Images/LogoWithName2.png"), true, false, 500),
                        e.PrintImage(ImgTitle, true),
                        e.PrintImage(ImgEx, true),
                        e.PrintImage(ImgVn, true),
                        e.PrintImage(ImgName, true),
                        e.PrintImage(ImgHn, true),
                        e.PrintImage(ImgPtright, true),
                        e.PrintLine(" "),
                        e.SetBarcodeHeightInDots(350),
                        e.SetBarWidth(BarWidth.Thin),
                        e.PrintBarcode(BarcodeType.CODE128, app.hn),
                        e.PrintLine(" "),
                        e.FeedLines(6),
                        e.FullCut()
                        )
                    );


                if (app.queueStatus == "y")
                {
                    byte[] ImgTitleQueue = DrawText("ใช้บริการโดยตู้ Kiosk\nตรวจโรคทั่วไป\n", fontRegular);
                    byte[] ImgHnVn       = DrawText($"HN : {app.hn} VN : {app.vn} \n ชื่อ : {app.ptname}", fontBold);
                    byte[] ImgDetail     = DrawText($"ประเภท : {app.ptType}", fontRegular);
                    byte[] ImgQueue      = DrawText(app.queueNumber, fontJumbo);
                    byte[] ImgQueueWait  = DrawText($"จำนวนคิวที่รอ {app.queueWait} คิว", fontRegular);
                    printer.Write(
                        ByteSplicer.Combine(
                            e.CenterAlign(),
                            e.PrintImage(File.ReadAllBytes("Images/LogoWithNameOPD.png"), true, false, 500),
                            e.PrintImage(ImgTitleQueue, true),
                            e.PrintImage(ImgHnVn, true),
                            e.PrintImage(ImgDetail, true),
                            e.PrintImage(ImgQueue, true),
                            e.PrintImage(ImgQueueWait, true),
                            e.FeedLines(6),
                            e.FullCut()
                            )
                        );
                    printer.Dispose(); // close
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Example #20
0
 public static byte[] CashDrawerOpenPin2(ICommandEmitter e) =>
 ByteSplicer.Combine(
     e.CashDrawerOpenPin2(),    // Fire this twice ensures it's operation
     e.CashDrawerOpenPin2());
Example #21
0
 private void UpdateBuffer(byte[] newBytes)
 => this.Buffer = ByteSplicer.Combine(Buffer, newBytes);
Example #22
0
        // 직원용프린트 함수
        static void StartPrint(JObject json)
        {
            //프린터 연결
#if DEBUG
            printer = new TestSerialPrinter(portName: "COM1", baudRate: 9600);
#else
            printer = new SerialPrinter(portName: "COM1", baudRate: 9600);
#endif

            // 메뉴 해쉬코드 - 내용 딕셔너리
            Dictionary <int, JToken> menuDictionary = new Dictionary <int, JToken>();

            // 각 메뉴마다 수량 겟하고 내용 저장
            foreach (var menu in json["menus"])
            {
                int menuHash = menu.ToString().GetHashCode();

                if (menuDictionary.ContainsKey(menuHash))
                {
                    menuDictionary[menuHash]["quantity"] = menuDictionary[menuHash]["quantity"].ToObject <int>() + 1;
                }
                else
                {
                    menu["quantity"] = 1;

                    var option = menu["options"].First;

                    // 옵션 확인하고 수량 없으면 삭제
                    while (option != null)
                    {
                        var currentOption = option;
                        option = currentOption.Next;
                        if (currentOption["quantity"].ToObject <int>() <= 0)
                        {
                            currentOption.Remove();
                        }
                    }

                    menuDictionary.Add(menuHash, menu);
                }
            }

            string orderNum = json["orderNum"].ToString();

            printer.Write(
                ByteSplicer.Combine(
                    e.FeedLines(1),
                    e.CenterAlign(),
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine("주문번호: " + orderNum),
                    e.SetStyles(PrintStyle.None),
                    e.PrintLine("--------------------------"),
                    e.PrintLine(System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")),//시간
                    e.PrintLine("--------------------------")
                    ));

            byte[] bodyBytes = e.FeedLines(1);
            foreach (var menu in menuDictionary.Values)
            {
                string menu_pojang   = menu["isTakeOut"].Value <bool>() ? "포장" : "테이블";
                string menu_name     = menu["name"].ToString();
                string menu_tumbler  = menu["isTumbler"].Value <bool>() ? "텀블러" : null;
                string menu_temp     = menu["temp"].ToString(); // 아이스, 핫
                int    menu_quantity = menu["quantity"].ToObject <int>();

                // (온도) 메뉴이름 (포장여부)
                string menu_name_line = "(" + menu_temp + ") " + menu_name + " (" + menu_pojang + ")";

                byte[] menuBytes = ByteSplicer.Combine(
                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth | PrintStyle.Bold),
                    e.PrintLine(menu_name_line),
                    e.PrintLine("수량 : " + menu_quantity)
                    );
                if (menu["options"].Any())
                {
                    menuBytes = ByteSplicer.Combine(menuBytes,
                                                    e.SetStyles(PrintStyle.FontB | PrintStyle.DoubleHeight | PrintStyle.DoubleWidth)
                                                    // , e.PrintLine("옵션")
                                                    );
                    JArray optionsArray = menu["options"].ToObject <JArray>();

                    foreach (var option in optionsArray)
                    {
                        menuBytes = ByteSplicer.Combine(menuBytes,
                                                        e.PrintLine(option["name"].ToString() + " : " + option["quantity"].ToString())
                                                        );
                    }
                }

                bodyBytes = ByteSplicer.Combine(bodyBytes, menuBytes, e.FeedLines(1));
            }

            printer.Write(bodyBytes);

            printer.Write(
                ByteSplicer.Combine(e.FeedLines(3)));

            printer.Write(
                ByteSplicer.Combine(
                    e.FullCut()
                    )
                );
            //프린터 해제
            printer.Dispose();
        }
        public static byte[] TestLargeByteArrays(ICommandEmitter e)
        {
            var kitten         = e.PrintImage(File.ReadAllBytes("images/kitten.jpg"), true, true, 500);
            var cube           = e.PrintImage(File.ReadAllBytes("images/Portal_Companion_Cube.jpg"), true, true, 500);
            var expectedResult = ByteSplicer.Combine(
                e.CenterAlign(),
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube,
                kitten,
                cube
                );
            MemoryPrinter mp = new MemoryPrinter();

            mp.Write(expectedResult);
            var  response  = mp.GetAllData();
            bool hasErrors = false;

            if (expectedResult.Length != response.Length)
            {
                Console.WriteLine($"Error: MemoryPrinter length mismatch - ${response.Length}, expected ${expectedResult.Length}");
                hasErrors = true;
            }
            else
            {
                for (int i = 0; i < expectedResult.Length; i++)
                {
                    if (expectedResult[i] != response[i])
                    {
                        Console.WriteLine($"Error: MemoryPrinter data mismatch - ${expectedResult[i]}, expected ${response[i]}, at location ${i}");
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                Console.WriteLine("MemoryPrinter: ALL OK!");
            }
            else
            {
                Console.WriteLine("MemoryPrinter: Errors occured during testing, aborting!");
                throw new ArgumentException();
            }

            Random r        = new Random();
            var    filename = $"{r.NextDouble().ToString()}.tmp";

            using (FilePrinter fp = new FilePrinter(filename, true))
            {
                fp.Write(expectedResult);
            }
            response  = File.ReadAllBytes(filename);
            hasErrors = false;
            if (expectedResult.Length != response.Length)
            {
                Console.WriteLine($"Error: FilePrinter length mismatch - ${response.Length}, expected ${expectedResult.Length}");
                hasErrors = true;
            }
            else
            {
                for (int i = 0; i < expectedResult.Length; i++)
                {
                    if (expectedResult[i] != response[i])
                    {
                        Console.WriteLine($"Error: FilePrinter data mismatch - ${expectedResult[i]}, expected ${response[i]}, at location ${i}");
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                Console.WriteLine("FilePrinter: ALL OK!");
            }
            else
            {
                Console.WriteLine("FilePrinter: Errors occured during testing, aborting!");
                throw new ArgumentException();
            }

            return(expectedResult);
        }
Example #24
0
        public async Task PrintText(string input, string printerName)
        {
            using (BluetoothAdapter bluetoothAdapter = BluetoothAdapter.DefaultAdapter)
            {
                if (bluetoothAdapter == null)
                {
                    throw new Exception("No default adapter");
                    //return;
                }

                if (!bluetoothAdapter.IsEnabled)
                {
                    throw new Exception("Bluetooth not enabled");
                }

                BluetoothDevice device = (from bd in bluetoothAdapter.BondedDevices
                                          where bd.Name == printerName
                                          select bd).FirstOrDefault();
                if (device == null)
                {
                    throw new Exception(printerName + " device not found.");
                }

                try
                {
                    using (BluetoothSocket _socket = device.CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805f9b34fb")))
                    {
                        await _socket.ConnectAsync();


                        switch (input)
                        {
                        case "LF":
                            _socket.OutputStream.WriteByte(0x0A);
                            break;

                        default:
                            byte[] message = System.Text.Encoding.ASCII.GetBytes(input);
                            await _socket.OutputStream.WriteAsync(message, 0, message.Length);

                            _socket.OutputStream.WriteByte(0x0A);

                            //try ESCPOS_NET
                            var e      = new EPSON();
                            var buffer = ByteSplicer.Combine(
                                e.CenterAlign(),
                                e.PrintLine("Receipt"),
                                e.Print("From "), e.SetStyles(PrintStyle.Bold), e.Print($"bold"), e.SetStyles(PrintStyle.None),
                                e.SetBarcodeHeightInDots(48), e.PrintBarcode(BarcodeType.CODE39, "ABC"), e.PrintLine(""),
                                e.LeftAlign(), e.PrintLine("left"),
                                e.PrintLine("user: "******"username")
                                );
                            await _socket.OutputStream.WriteAsync(buffer, 0, buffer.Length);

                            break;
                        }

                        _socket.Close();
                    }
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
        }
Example #25
0
 public static byte[] GetReceiptProduct(ICommandEmitter e, Horeka.Data.Sale sale, int i) =>
 ByteSplicer.Combine(
     e.SetStyles(PrintStyle.FontB),
     e.LeftAlign(),
     e.PrintLine($"{i}. {sale.Product.Name} - € {sale.Product.Price}")
     );