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))); }
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") )); }
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") );
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() )); }
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() );
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); }