public static byte[] CreateTextPageModeData(Emulation emulation, LocalizeReceipt localizeReceipt, Rectangle printRegion, BitmapConverterRotation rotation, bool utf8) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.BeginPageMode(printRegion, rotation); localizeReceipt.AppendTextLabelData(builder, utf8); builder.EndPageMode(); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateTextPageModeData(StarIoExtEmulation emulation, LocalizeReceipts.ILocalizeReceipts localizeReceipts, Rectangle rectangle, BitmapConverterRotation rotation, bool utf8) { ICommandBuilder commandBuilder = Extension.CreateCommandBuilder(emulation); commandBuilder.BeginDocument(); commandBuilder.BeginPageMode(rectangle, rotation); localizeReceipts.AppendTextLabelData(commandBuilder, utf8); commandBuilder.EndPageMode(); commandBuilder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); commandBuilder.EndDocument(); return(commandBuilder.Commands); }
public static byte[] CreateCouponData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, BitmapConverterRotation rotation) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); Bitmap rasterImage = localizeReceipt.CreateCouponImage(); builder.AppendBitmap(rasterImage, false, width, true, rotation); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.AppendPeripheral(PeripheralChannel.No1); builder.EndDocument(); return(builder.Commands); }
public void Print(List <TicketBase> tickets, int issueingNumber, Action <int> onPrint, Action <Exception, int> onError) { StarPrinterStatus status = port.BeginCheckedBlock(); if (status.Offline) { } ICommandBuilder builder = StarIoExt.CreateCommandBuilder(Emulation.StarGraphic); builder.BeginDocument(); tickets.ForEach((t, i) => { try { int height = 8 * 58 - 25 - 15; Bitmap bmp = t.Bitmap.Clone(new Rectangle((t.Bitmap.Width - 576) / 2, 25, 576, height), t.Bitmap.PixelFormat); builder.AppendBitmapWithAbsolutePosition(bmp, false, 576, false, BitmapConverterRotation.Normal, 0); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); bmp.Dispose(); onPrint(i); } catch (Exception ex) { onError(ex, i); } }); builder.EndDocument(); byte[] command = builder.Commands; uint writtenLength = port.WritePort(command, 0, (uint)command.Length); status = port.EndCheckedBlock(); if (status.Offline) { } }
public static byte[] CreateBlackMarkData(Emulation emulation, BlackMarkType type) { byte[] data = Encoding.UTF8.GetBytes("Hello World.\n"); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.AppendBlackMark(type); builder.Append(data); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); //builder.AppendBlackMark(BlackMarkType.Invalid); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateInitializationData(Emulation emulation) { byte[] data = Encoding.UTF8.GetBytes("Hello World.\n"); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(data); builder.AppendMultiple(2, 2); builder.Append(data); builder.AppendFontStyle(FontStyleType.B); builder.Append(data); builder.AppendInitialization(InitializationType.Command); builder.Append(data); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateRasterReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool receipt, bool info, bool qrCode) { if (!receipt && !info && !qrCode) { return(null); } Bitmap image = localizeReceipt.CreateRasterReceiptImage(); byte[] urlData = SMCSAllReceipts.UploadBitmap(image); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); if (receipt) { builder.AppendBitmap(image, false); } byte[] allReceiptsData; if (emulation == Emulation.StarGraphic) { allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode, width); // Support to centering in Star Graphic. } else { allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode);// Non support to centering in Star Graphic. } builder.AppendRaw(allReceiptsData); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateAbsolutePositionData(Emulation emulation) { byte[] data = Encoding.UTF8.GetBytes("Hello World.\n"); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(data); builder.AppendAbsolutePosition(40); builder.Append(data); builder.Append(data); builder.AppendAbsolutePosition(data, 40); builder.Append(data); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateLogoData(Emulation emulation) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(Encoding.UTF8.GetBytes("*Normal*\n")); builder.AppendLogo(LogoSize.Normal, 1); builder.Append(Encoding.UTF8.GetBytes("\n*Double Width*\n")); builder.AppendLogo(LogoSize.DoubleWidth, 1); builder.Append(Encoding.UTF8.GetBytes("\n*Double Height*\n")); builder.AppendLogo(LogoSize.DoubleHeight, 1); builder.Append(Encoding.UTF8.GetBytes("\n*Double Width and Double Height*\n")); builder.AppendLogo(LogoSize.DoubleWidthDoubleHeight, 1); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateBitmapDataDetail(Emulation emulation) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); String BitmapTitle; Font TitleFont; Bitmap rasterImage; String BitmapDetail; BitmapTitle = "交易明細\n"; TitleFont = new Font("新細明體", 40); rasterImage = CreateBitmapFromString(BitmapTitle, 96.0F, 96.0F, TitleFont, 96); builder.AppendBitmap(rasterImage, false); String DateTime = " " + dr["printtime"] + "\n\n"; Font DateTimeFont = new Font("新細明體", 20); Bitmap rasterImage3 = CreateBitmapFromString(DateTime, 96.0F, 96.0F, DateTimeFont, 0); builder.AppendBitmap(rasterImage3, false); Font DetailFont = new Font("新細明體", 18); string subtitle = "品名/數量\t單價\t金額"; string subtitleWithSpace = CalculateSpaceWidth(subtitle, DetailFont, 96.0F, 96.0F, 20); BitmapDetail = subtitleWithSpace + "\n"; foreach (string productlist in products) { string[] lines = productlist.Split('\n'); foreach (string line in lines) { string productWithSpace = CalculateSpaceWidth(line, DetailFont, 96.0F, 96.0F, 20); BitmapDetail += productWithSpace + "\n"; } } Bitmap rasterImage4 = CreateBitmapFromString(BitmapDetail, 96.0F, 96.0F, DetailFont, 0, true); builder.AppendBitmap(rasterImage4, false); String total = "\n總計:" + new string(' ', 10) + dr["total"] + " 元\n"; Font totalFont = new Font("新細明體", 18); Bitmap rasterImage5 = CreateBitmapFromString(total, 96.0F, 96.0F, totalFont, 0, false); builder.AppendBitmap(rasterImage5, false); builder.AppendUnitFeed(5); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.AppendPeripheral(PeripheralChannel.No1); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateBitmapData(Emulation emulation) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); string logoFile = appPath + @"\" + dr["logo"]; Bitmap logo = (Bitmap)Bitmap.FromFile(logoFile); Bitmap newImage = ResizeBitmap(logo, 400, 66); builder.AppendBitmap(newImage, false); builder.AppendUnitFeed(16); String BitmapTitle; Font TitleFont; Bitmap rasterImage; if (dr["atttext"] != "") { BitmapTitle = "電子發票證明聯補印\n"; TitleFont = new Font("新細明體", 36); rasterImage = CreateBitmapFromString(BitmapTitle, 92.0F, 96.0F, TitleFont, -8); } else { BitmapTitle = "電子發票證明聯\n"; TitleFont = new Font("新細明體", 40); rasterImage = CreateBitmapFromString(BitmapTitle, 96.0F, 96.0F, TitleFont, 0); } builder.AppendBitmap(rasterImage, false); String InvoiceTitle = " " + dr["year"] + "年" + dr["months"] + "月" + "\n"; InvoiceTitle += " " + dr["invoice"] + "\n"; Font InvoiceTitleFont = new Font("新細明體", 40, FontStyle.Bold); Bitmap rasterImage2 = CreateBitmapFromString(InvoiceTitle, 96.0F, 96.0F, InvoiceTitleFont, 0); builder.AppendBitmap(rasterImage2, false); //格式 String DateTime = " " + dr["printtime"] + " "; if (dr["fixtext"] != "") { DateTime += "格式 " + dr["fixtext"] + "\n"; } else { DateTime += "\n"; } Font DateTimeFont = new Font("新細明體", 20); Bitmap rasterImage3 = CreateBitmapFromString(DateTime, 96.0F, 96.0F, DateTimeFont, 0); builder.AppendBitmap(rasterImage3, false); String Random_Total = " 隨機碼 " + dr["randcode"] + " "; Random_Total += "總計 " + dr["total"] + "\n"; Font Random_TotalFont = new Font("新細明體", 20); Bitmap rasterImage4 = CreateBitmapFromString(Random_Total, 96.0F, 96.0F, Random_TotalFont, 0); builder.AppendBitmap(rasterImage4, false); String Seller_Buyer = " 賣方 " + dr["sellerid"] + " "; if (dr["byerid"] != "0000000000") { Seller_Buyer += "買方 " + dr["byerid"] + "\n"; } else { Seller_Buyer += "\n"; } Font Seller_BuyerFont = new Font("新細明體", 20); Bitmap rasterImage5 = CreateBitmapFromString(Seller_Buyer, 96.0F, 96.0F, Seller_BuyerFont, 0); builder.AppendBitmap(rasterImage5, false); builder.AppendUnitFeed(5); Image c39Img = GetCode39(dr["barcode"], 50); //計算條碼寬度產生的比例(會依照印表機DPI值變化) //可列印寬度(兩側留白0.3以上) = 5.7 - (0.3 * 2) = 5.1cm float ItoC = 2.54f; float dpiX = (float)200; float dpiY = (float)200; float widthlimit = (5.7f / ItoC) * dpiX; float rate = 0f; float newWidth = 0f; do { rate++; newWidth = c39Img.Width * rate; } while ((c39Img.Width * (rate + 1.0f)) <= widthlimit); //計算X定位點(條碼置中) float newX = (((5.7f / ItoC) * dpiX) / 2.0f) - (newWidth / 2.0f); Bitmap mybmp1 = new Bitmap((int)newWidth, 60); Graphics gr1 = Graphics.FromImage(mybmp1); gr1.DrawImage(c39Img, new Point[] { new Point(0, 0), new Point((int)newWidth, 0), new Point(0, c39Img.Height) }); gr1.Dispose(); builder.AppendBitmap(mybmp1, false); //QR碼 //利用matrix來計算產生QR碼的實際Size(去白邊) var hints = new Dictionary <EncodeHintType, object> { { EncodeHintType.CHARACTER_SET, "UTF-8" }, { EncodeHintType.QR_VERSION, 8 } }; var matrix = new MultiFormatWriter().encode(dr["qrcode1"], BarcodeFormat.QR_CODE, 140, 140, hints); var matrix2 = new MultiFormatWriter().encode(dr["qrcode2"], BarcodeFormat.QR_CODE, 140, 140, hints); matrix = CutWhiteBorder(matrix); matrix2 = CutWhiteBorder(matrix2); //把QR碼實際Size給BarcodeWriter參考產生 var qr1Writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = new QrCodeEncodingOptions { Height = matrix.Height, Width = matrix.Width, CharacterSet = "utf-8", Margin = 0, ErrorCorrection = ErrorCorrectionLevel.L, QrVersion = 8 } }; var qr2Writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = new QrCodeEncodingOptions { Height = matrix2.Height, Width = matrix2.Width, CharacterSet = "utf-8", Margin = 0, ErrorCorrection = ErrorCorrectionLevel.L, QrVersion = 8 } }; //QR碼至此產生的大小為不含白邊的原圖大小 Image qr1Img = qr1Writer.Write(dr["qrcode1"]); Image qr2Img = qr2Writer.Write(dr["qrcode2"]); Bitmap mybmp = new Bitmap(600, 180); Graphics gr = Graphics.FromImage(mybmp); //處理第一張圖片 gr.DrawImage(qr1Img, new Point[] { new Point(0, 0), new Point(140, 0), new Point(0, 140) }); gr.DrawImage(qr2Img, new Point[] { new Point(204, 0), new Point(344, 0), new Point(204, 140) }); //處理第二張圖片 gr.Dispose(); builder.AppendBitmapWithAbsolutePosition(mybmp, false, 30); // 打統編要接著印交易明細 if (dr["byerid"] == "0000000000") { builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); } builder.AppendPeripheral(PeripheralChannel.No1); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreatePageModeData(Emulation emulation, int width) { byte[] data; data = Encoding.UTF8.GetBytes("Hello World.\n"); Bitmap starLogoImage; using (var stream = Properties.Resources.star_logo_image) { starLogoImage = new Bitmap(stream); } int height = 30 * 8; // 30mm!! Rectangle rectangle; ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(Encoding.UTF8.GetBytes("\n*Normal*\n")); rectangle = new Rectangle(0, 0, width, height); builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal); builder.Append(data); builder.AppendPageModeVerticalAbsolutePosition(160); builder.Append(data); builder.AppendPageModeVerticalAbsolutePosition(80); builder.AppendAbsolutePosition(data, 40); builder.EndPageMode(); builder.Append(Encoding.UTF8.GetBytes("\n*Right90*\n")); //rectangle = new Rectangle(0, 0, width, height); //rectangle = new Rectangle(0, 0, height, width); rectangle = new Rectangle(0, 0, width, width); builder.BeginPageMode(rectangle, BitmapConverterRotation.Right90); builder.Append(data); builder.AppendPageModeVerticalAbsolutePosition(160); builder.Append(data); builder.AppendPageModeVerticalAbsolutePosition(80); builder.AppendAbsolutePosition(data, 40); builder.EndPageMode(); //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180*\n")); //rectangle = new Rectangle(0, 0, width, height); //builder.BeginPageMode(rectangle, BitmapConverterRotation.Rotate180); //builder.Append(data); //builder.AppendPageModeVerticalAbsolutePosition(160); //builder.Append(data); //builder.AppendPageModeVerticalAbsolutePosition(80); //builder.AppendAbsolutePosition(data, 40); //builder.EndPageMode(); //builder.Append(Encoding.UTF8.GetBytes("\n*Left90*\n")); //rectangle = new Rectangle(0, 0, width, height); //rectangle = new Rectangle(0, 0, height, width); //builder.BeginPageMode(rectangle, BitmapConverterRotation.Left90); //builder.Append(data); //builder.AppendPageModeVerticalAbsolutePosition(160); //builder.Append(data); //builder.AppendPageModeVerticalAbsolutePosition(80); //builder.AppendAbsolutePosition(data, 40); //builder.EndPageMode(); builder.Append(Encoding.UTF8.GetBytes("\n*Mixed Text*\n")); //rectangle = new Rectangle(0, 0, width, height); rectangle = new Rectangle(0, 0, width, width); builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendAbsolutePosition(data, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Right90); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendAbsolutePosition(data, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Rotate180); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendAbsolutePosition(data, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Left90); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendAbsolutePosition(data, width / 2); builder.EndPageMode(); builder.Append(Encoding.UTF8.GetBytes("\n*Mixed Bitmap*\n")); //rectangle = new Rectangle(0, 0, width, height); rectangle = new Rectangle(0, 0, width, width); builder.BeginPageMode(rectangle, BitmapConverterRotation.Normal); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendBitmapWithAbsolutePosition(starLogoImage, false, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Right90); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Rotate180); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2); builder.AppendPageModeRotation(BitmapConverterRotation.Left90); builder.AppendPageModeVerticalAbsolutePosition(width / 2); builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, width / 2); builder.EndPageMode(); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateBarcodeData(Emulation emulation) { byte[] dataUpcE = Encoding.UTF8.GetBytes("01234500006"); byte[] dataUpcA = Encoding.UTF8.GetBytes("01234567890"); byte[] dataJan8 = Encoding.UTF8.GetBytes("0123456"); byte[] dataJan13 = Encoding.UTF8.GetBytes("012345678901"); byte[] dataCode39 = Encoding.UTF8.GetBytes("0123456789"); byte[] dataItf = Encoding.UTF8.GetBytes("0123456789"); byte[] dataCode128 = Encoding.UTF8.GetBytes("{B0123456789"); byte[] dataCode93 = Encoding.UTF8.GetBytes("0123456789"); byte[] dataNw7 = Encoding.UTF8.GetBytes("A0123456789B"); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(Encoding.UTF8.GetBytes("*UPCE*\n")); builder.AppendBarcode(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*UPCA*\n")); builder.AppendBarcode(dataUpcA, BarcodeSymbology.UPCA, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*JAN8*\n")); builder.AppendBarcode(dataJan8, BarcodeSymbology.JAN8, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*JAN13*\n")); builder.AppendBarcode(dataJan13, BarcodeSymbology.JAN13, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*Code39*\n")); builder.AppendBarcode(dataCode39, BarcodeSymbology.Code39, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*ITF*\n")); builder.AppendBarcode(dataItf, BarcodeSymbology.ITF, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*Code128*\n")); builder.AppendBarcode(dataCode128, BarcodeSymbology.Code128, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*Code93*\n")); builder.AppendBarcode(dataCode93, BarcodeSymbology.Code93, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*NW7*\n")); builder.AppendBarcode(dataNw7, BarcodeSymbology.NW7, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("*HRI:NO*\n")); builder.AppendBarcode(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, false); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("*Mode:1*\n")); builder.AppendBarcode(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("*Mode:2*\n")); builder.AppendBarcode(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode2, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("*Mode:3*\n")); builder.AppendBarcode(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode3, 40, true); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*AbsolutePosition:40*\n")); builder.AppendBarcodeWithAbsolutePosition(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, true, 40); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*Alignment:Center*\n")); builder.AppendBarcodeWithAlignment(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, true, AlignmentPosition.Center); builder.AppendUnitFeed(32); builder.Append(Encoding.UTF8.GetBytes("\n*Alignment:Right*\n")); builder.AppendBarcodeWithAlignment(dataUpcE, BarcodeSymbology.UPCE, BarcodeWidth.Mode1, 40, true, AlignmentPosition.Right); builder.AppendUnitFeed(32); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateCodePageData(Emulation emulation) { byte[] bytes2 = new byte[] { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x0a }; byte[] bytes3 = new byte[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x0a }; byte[] bytes4 = new byte[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x0a }; byte[] bytes5 = new byte[] { 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x0a }; byte[] bytes6 = new byte[] { 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x0a }; byte[] bytes7 = new byte[] { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x0a }; byte[] bytes8 = new byte[] { (byte)0x80, (byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84, (byte)0x85, (byte)0x86, (byte)0x87, (byte)0x88, (byte)0x89, (byte)0x8a, (byte)0x8b, (byte)0x8c, (byte)0x8d, (byte)0x8e, (byte)0x8f, 0x0a }; byte[] bytes9 = new byte[] { (byte)0x90, (byte)0x91, (byte)0x92, (byte)0x93, (byte)0x94, (byte)0x95, (byte)0x96, (byte)0x97, (byte)0x98, (byte)0x99, (byte)0x9a, (byte)0x9b, (byte)0x9c, (byte)0x9d, (byte)0x9e, (byte)0x9f, 0x0a }; byte[] bytesA = new byte[] { (byte)0xa0, (byte)0xa1, (byte)0xa2, (byte)0xa3, (byte)0xa4, (byte)0xa5, (byte)0xa6, (byte)0xa7, (byte)0xa8, (byte)0xa9, (byte)0xaa, (byte)0xab, (byte)0xac, (byte)0xad, (byte)0xae, (byte)0xaf, 0x0a }; byte[] bytesB = new byte[] { (byte)0xb0, (byte)0xb1, (byte)0xb2, (byte)0xb3, (byte)0xb4, (byte)0xb5, (byte)0xb6, (byte)0xb7, (byte)0xb8, (byte)0xb9, (byte)0xba, (byte)0xbb, (byte)0xbc, (byte)0xbd, (byte)0xbe, (byte)0xbf, 0x0a }; byte[] bytesC = new byte[] { (byte)0xc0, (byte)0xc1, (byte)0xc2, (byte)0xc3, (byte)0xc4, (byte)0xc5, (byte)0xc6, (byte)0xc7, (byte)0xc8, (byte)0xc9, (byte)0xca, (byte)0xcb, (byte)0xcc, (byte)0xcd, (byte)0xce, (byte)0xcf, 0x0a }; byte[] bytesD = new byte[] { (byte)0xd0, (byte)0xd1, (byte)0xd2, (byte)0xd3, (byte)0xd4, (byte)0xd5, (byte)0xd6, (byte)0xd7, (byte)0xd8, (byte)0xd9, (byte)0xda, (byte)0xdb, (byte)0xdc, (byte)0xdd, (byte)0xde, (byte)0xdf, 0x0a }; byte[] bytesE = new byte[] { (byte)0xe0, (byte)0xe1, (byte)0xe2, (byte)0xe3, (byte)0xe4, (byte)0xe5, (byte)0xe6, (byte)0xe7, (byte)0xe8, (byte)0xe9, (byte)0xea, (byte)0xeb, (byte)0xec, (byte)0xed, (byte)0xee, (byte)0xef, 0x0a }; byte[] bytesF = new byte[] { (byte)0xf0, (byte)0xf1, (byte)0xf2, (byte)0xf3, (byte)0xf4, (byte)0xf5, (byte)0xf6, (byte)0xf7, (byte)0xf8, (byte)0xf9, (byte)0xfa, (byte)0xfb, (byte)0xfc, (byte)0xfd, (byte)0xfe, (byte)0xff, 0x0a }; ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.AppendCodePage(CodePageType.CP998); builder.Append(Encoding.UTF8.GetBytes("*CP998*\n")); builder.Append(bytes2); builder.Append(bytes3); builder.Append(bytes4); builder.Append(bytes5); builder.Append(bytes6); builder.Append(bytes7); builder.Append(bytes8); builder.Append(bytes9); builder.Append(bytesA); builder.Append(bytesB); builder.Append(bytesC); builder.Append(bytesD); builder.Append(bytesE); builder.Append(bytesF); builder.Append(Encoding.UTF8.GetBytes("\n")); //builder.AppendCodePage(CodePageType.CP437); builder.Append(Encoding.UTF8.GetBytes("*CP437*\n")); //builder.AppendCodePage(CodePageType.CP737); builder.Append(Encoding.UTF8.GetBytes("*CP737*\n")); //builder.AppendCodePage(CodePageType.CP772); builder.Append(Encoding.UTF8.GetBytes("*CP774*\n")); //builder.AppendCodePage(CodePageType.CP774); builder.Append(Encoding.UTF8.GetBytes("*CP774*\n")); //builder.AppendCodePage(CodePageType.CP851); builder.Append(Encoding.UTF8.GetBytes("*CP851*\n")); //builder.AppendCodePage(CodePageType.CP852); builder.Append(Encoding.UTF8.GetBytes("*CP852*\n")); //builder.AppendCodePage(CodePageType.CP855); builder.Append(Encoding.UTF8.GetBytes("*CP855*\n")); //builder.AppendCodePage(CodePageType.CP857); builder.Append(Encoding.UTF8.GetBytes("*CP857*\n")); //builder.AppendCodePage(CodePageType.CP858); builder.Append(Encoding.UTF8.GetBytes("*CP858*\n")); //builder.AppendCodePage(CodePageType.CP860); builder.Append(Encoding.UTF8.GetBytes("*CP860*\n")); //builder.AppendCodePage(CodePageType.CP861); builder.Append(Encoding.UTF8.GetBytes("*CP861*\n")); //builder.AppendCodePage(CodePageType.CP862); builder.Append(Encoding.UTF8.GetBytes("*CP862*\n")); //builder.AppendCodePage(CodePageType.CP863); builder.Append(Encoding.UTF8.GetBytes("*CP863*\n")); //builder.AppendCodePage(CodePageType.CP864); builder.Append(Encoding.UTF8.GetBytes("*CP864*\n")); //builder.AppendCodePage(CodePageType.CP865); builder.Append(Encoding.UTF8.GetBytes("*CP865*\n")); //builder.AppendCodePage(CodePageType.CP866); builder.Append(Encoding.UTF8.GetBytes("*CP866*\n")); //builder.AppendCodePage(CodePageType.CP869); builder.Append(Encoding.UTF8.GetBytes("*CP869*\n")); //builder.AppendCodePage(CodePageType.CP874); builder.Append(Encoding.UTF8.GetBytes("*CP874*\n")); //builder.AppendCodePage(CodePageType.CP928); builder.Append(Encoding.UTF8.GetBytes("*CP928*\n")); builder.AppendCodePage(CodePageType.CP932); builder.Append(Encoding.UTF8.GetBytes("*CP932*\n")); //builder.AppendCodePage(CodePageType.CP998); builder.Append(Encoding.UTF8.GetBytes("*CP998*\n")); //builder.AppendCodePage(CodePageType.CP999); builder.Append(Encoding.UTF8.GetBytes("*CP999*\n")); //builder.AppendCodePage(CodePageType.CP1001); builder.Append(Encoding.UTF8.GetBytes("*CP1001*\n")); //builder.AppendCodePage(CodePageType.CP1250); builder.Append(Encoding.UTF8.GetBytes("*CP1250*\n")); //builder.AppendCodePage(CodePageType.CP1251); builder.Append(Encoding.UTF8.GetBytes("*CP1251*\n")); //builder.AppendCodePage(CodePageType.CP1252); builder.Append(Encoding.UTF8.GetBytes("*CP1252*\n")); //builder.AppendCodePage(CodePageType.CP2001); builder.Append(Encoding.UTF8.GetBytes("*CP2001*\n")); //builder.AppendCodePage(CodePageType.CP3001); builder.Append(Encoding.UTF8.GetBytes("*CP3001*\n")); //builder.AppendCodePage(CodePageType.CP3002); builder.Append(Encoding.UTF8.GetBytes("*CP3002*\n")); //builder.AppendCodePage(CodePageType.CP3011); builder.Append(Encoding.UTF8.GetBytes("*CP3011*\n")); //builder.AppendCodePage(CodePageType.CP3012); builder.Append(Encoding.UTF8.GetBytes("*CP3012*\n")); //builder.AppendCodePage(CodePageType.CP3021); builder.Append(Encoding.UTF8.GetBytes("*CP3021*\n")); //builder.AppendCodePage(CodePageType.CP3041); builder.Append(Encoding.UTF8.GetBytes("*CP3041*\n")); //builder.AppendCodePage(CodePageType.CP3840); builder.Append(Encoding.UTF8.GetBytes("*CP3840*\n")); //builder.AppendCodePage(CodePageType.CP3841); builder.Append(Encoding.UTF8.GetBytes("*CP3841*\n")); //builder.AppendCodePage(CodePageType.CP3843); builder.Append(Encoding.UTF8.GetBytes("*CP3843*\n")); //builder.AppendCodePage(CodePageType.CP3844); builder.Append(Encoding.UTF8.GetBytes("*CP3844*\n")); //builder.AppendCodePage(CodePageType.CP3845); builder.Append(Encoding.UTF8.GetBytes("*CP3845*\n")); //builder.AppendCodePage(CodePageType.CP3846); builder.Append(Encoding.UTF8.GetBytes("*CP3846*\n")); //builder.AppendCodePage(CodePageType.CP3847); builder.Append(Encoding.UTF8.GetBytes("*CP3847*\n")); //builder.AppendCodePage(CodePageType.CP3848); builder.Append(Encoding.UTF8.GetBytes("*CP3848*\n")); //builder.AppendCodePage(CodePageType.UTF8); builder.Append(Encoding.UTF8.GetBytes("*UTF8*\n")); //builder.AppendCodePage(CodePageType.Blank); builder.Append(Encoding.UTF8.GetBytes("*Blank*\n")); builder.Append(bytes2); builder.Append(bytes3); builder.Append(bytes4); builder.Append(bytes5); builder.Append(bytes6); builder.Append(bytes7); builder.Append(bytes8); builder.Append(bytes9); builder.Append(bytesA); builder.Append(bytesB); builder.Append(bytesC); builder.Append(bytesD); builder.Append(bytesE); builder.Append(bytesF); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateBitmapData(Emulation emulation, int width) { Bitmap sphereImage; using (var stream = Properties.Resources.sphere_image) { sphereImage = new Bitmap(stream); } Bitmap starLogoImage; using (var stream = Properties.Resources.star_logo_image) { starLogoImage = new Bitmap(stream); } ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(Encoding.UTF8.GetBytes("*diffusion:true*\n")); builder.AppendBitmap(sphereImage, true); builder.Append(Encoding.UTF8.GetBytes("\n*diffusion:false*\n")); builder.AppendBitmap(sphereImage, false); builder.Append(Encoding.UTF8.GetBytes("\n*Normal*\n")); builder.AppendBitmap(starLogoImage, true); builder.Append(Encoding.UTF8.GetBytes("\n*width:Full, bothScale:true*\n")); builder.AppendBitmap(starLogoImage, true, width, true); builder.Append(Encoding.UTF8.GetBytes("\n*width:Full, bothScale:false*\n")); builder.AppendBitmap(starLogoImage, true, width, false); builder.Append(Encoding.UTF8.GetBytes("\n*Right90*\n")); builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Right90); builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180*\n")); builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Rotate180); //builder.Append(Encoding.UTF8.GetBytes("\n*Left90*\n")); //builder.AppendBitmap(starLogoImage, true, BitmapConverterRotation.Left90); builder.Append(Encoding.UTF8.GetBytes("\n*Normal, AbsolutePosition:40*\n")); builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, 40); //builder.Append(Encoding.UTF8.GetBytes("\n*Right90, AbsolutePosition:40*\n")); //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Right90, 40); //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, AbsolutePosition:40*\n")); //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Rotate180, 40); //builder.Append(Encoding.UTF8.GetBytes("\n*Left90, AbsolutePosition:40*\n")); //builder.AppendBitmapWithAbsolutePosition(starLogoImage, true, BitmapConverterRotation.Left90, 40); builder.Append(Encoding.UTF8.GetBytes("\n*Normal, Alignment:Center*\n")); builder.AppendBitmapWithAlignment(starLogoImage, true, AlignmentPosition.Center); //builder.Append(Encoding.UTF8.GetBytes("\n*Right90, Alignment:Center*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Right90, AlignmentPosition.Center); //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, Alignment:Center*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Rotate180, AlignmentPosition.Center); //builder.Append(Encoding.UTF8.GetBytes("\n*Left90, Alignment:Center*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Left90, AlignmentPosition.Center); builder.Append(Encoding.UTF8.GetBytes("\n*Normal, Alignment:Right*\n")); builder.AppendBitmapWithAlignment(starLogoImage, true, AlignmentPosition.Right); //builder.Append(Encoding.UTF8.GetBytes("\n*Right90, Alignment:Right*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Right90, AlignmentPosition.Right); //builder.Append(Encoding.UTF8.GetBytes("\n*Rotate180, Alignment:Right*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Rotate180, AlignmentPosition.Right); //builder.Append(Encoding.UTF8.GetBytes("\n*Left90, Alignment:Right*\n")); //builder.AppendBitmapWithAlignment(starLogoImage, true, BitmapConverterRotation.Left90, AlignmentPosition.Right); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static byte[] CreateInternationalData(Emulation emulation) { byte[] bytes = new byte[] { 0x23, 0x24, 0x40, 0x58, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x60, 0x7b, 0x7c, 0x7d, 0x7e, 0x0a }; ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.Append(Encoding.UTF8.GetBytes("*USA*\n")); builder.AppendInternational(InternationalType.USA); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*France*\n")); builder.AppendInternational(InternationalType.France); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Germany*\n")); builder.AppendInternational(InternationalType.Germany); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*UK*\n")); builder.AppendInternational(InternationalType.UK); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Denmark*\n")); builder.AppendInternational(InternationalType.Denmark); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Sweden*\n")); builder.AppendInternational(InternationalType.Sweden); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Italy*\n")); builder.AppendInternational(InternationalType.Italy); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Spain*\n")); builder.AppendInternational(InternationalType.Spain); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Japan*\n")); builder.AppendInternational(InternationalType.Japan); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Norway*\n")); builder.AppendInternational(InternationalType.Norway); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Denmark2*\n")); builder.AppendInternational(InternationalType.Denmark2); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Spain2*\n")); builder.AppendInternational(InternationalType.Spain2); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*LatinAmerica*\n")); builder.AppendInternational(InternationalType.LatinAmerica); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Korea*\n")); builder.AppendInternational(InternationalType.Korea); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Ireland*\n")); builder.AppendInternational(InternationalType.Ireland); builder.Append(bytes); builder.Append(Encoding.UTF8.GetBytes("*Legal*\n")); builder.AppendInternational(InternationalType.Legal); builder.Append(bytes); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }