Exemplo n.º 1
0
        private static void TesteGuilhotina()
        {
            if (string.IsNullOrWhiteSpace(PortaCom))
            {
                return;
            }

            using (var printer = new GenericPrinter(PortaCom))
            {
                printer.Reinitialize();

                //Corte guilhotina parcial
                printer.PrintASCIIString($"== [ Start {testCases[testeAtual - 1]} ] ==");
                printer.FormFeed();
                printer.PrintASCIIString("  CORTE PARCIAL ");
                printer.FormFeed();
                printer.PrintASCIIString($"== [ End {testCases[testeAtual - 1]} ] ==");
                printer.FormFeed();
                printer.Cut(Printer.Common.Enums.CutModeEnum.Parcial);

                //Corte guilhotina total
                printer.PrintASCIIString($"== [ Start {testCases[testeAtual - 1]} ] ==");
                printer.FormFeed();
                printer.PrintASCIIString("  CORTE TOTAL ");
                printer.FormFeed();
                printer.PrintASCIIString($"== [ End {testCases[testeAtual - 1]} ] ==");
                printer.FormFeed();
                printer.Cut(Printer.Common.Enums.CutModeEnum.Total);
                printer.FormFeed();

                printer.Reinitialize();
            }
        }
Exemplo n.º 2
0
        private static void TesteImagem()
        {
            var printStatus = new StandardSection()
            {
                Justification = FontAlignment.Left,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w1,
                Font          = ThermalFontsEnum.B,
                AutoNewline   = true,
            };

            var document = new StandardDocument()
            {
                //Não esquecer de setar essa prop
                CodePage = CodePagesEnum.CPSPACE,
            };

            document.Sections.Add(new Placeholder());

            using (var printer = new GenericPrinter(PortaCom))
            {
                var image = new Imaging.PrinterImage((Bitmap)Image.FromFile(@"XING_B24.BMP"));
                image.ApplyDithering(Imaging.AlgorithmsEnum.JarvisJudiceNinke, 128);

                for (int i = 3; i >= 1; i--)
                {
                    printer.SetImage(image, document, 0, (FontAlignment)i);
                    printer.PrintDocument(document);
                }

                printer.FormFeed(5);
                printer.Cut(CutModeEnum.Parcial);
            }
        }
Exemplo n.º 3
0
        private static void TesteTexto()
        {
            if (string.IsNullOrWhiteSpace(PortaCom))
            {
                return;
            }

            using (var printer = new GenericPrinter(PortaCom))
            {
                printer.PrintASCIIString("Texto e um conjunto de palavras e frases encadeadas que permitem interpretacao e transmitem uma mensagem. E qualquer obra escrita em versao original e que constitui um livro ou um documento escrito. Um texto e uma unidade linguistica de extensao superior a frase.");
                printer.SetFont(ThermalFontsEnum.B);
                printer.FormFeed();
                printer.Cut(CutModeEnum.Parcial);
            }
        }
Exemplo n.º 4
0
        private static void TesteCompleto()
        {
            var separador = new StandardSection()
            {
                Justification = FontAlignment.Center,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w1,
                Font          = ThermalFontsEnum.A,
                AutoNewline   = true,
            };

            var separadorUmaLinha = new StandardSection()
            {
                Justification = FontAlignment.Center,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w1,
                Font          = ThermalFontsEnum.A,
                AutoNewline   = true,
            };

            var textoHeader = new StandardSection()
            {
                Justification = FontAlignment.Center,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w2,
                Font          = ThermalFontsEnum.A,
                AutoNewline   = true,
            };

            var textoCabecalho = new StandardSection()
            {
                Justification = FontAlignment.Center,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w1,
                Font          = ThermalFontsEnum.A,
                AutoNewline   = true,
            };

            var textoItens = new StandardSection()
            {
                Justification = FontAlignment.Left,
                HeightScalar  = FontHeighScalarEnum.h1,
                WidthScalar   = FontWidthScalarEnum.w2,
                Font          = ThermalFontsEnum.A,
                AutoNewline   = true,
            };

            var document = new StandardDocument()
            {
                //Não esquecer de setar essa prop
                CodePage = CodePagesEnum.CPSPACE,
            };

            document.Sections.Add(new Placeholder());
            document.Sections.Add(separador);
            document.Sections.Add(textoHeader);
            document.Sections.Add(separadorUmaLinha);
            document.Sections.Add(textoCabecalho);
            document.Sections.Add(separador);
            document.Sections.Add(textoItens);
            document.Sections.Add(separador);

            using (var printer = new GenericPrinter(PortaCom))
            {
                printer.Reinitialize();

                //reader
                var reader = new StringBuilder();
                reader.Append("COZINHA" + Environment.NewLine);
                reader.Append("MESA: 35");

                //Cabeçalho
                var cabecalho = new StringBuilder();
                cabecalho.Append($"Data/Hora: {DateTime.Now}" + Environment.NewLine);
                cabecalho.Append("Atendente: Caixaa" + Environment.NewLine);
                cabecalho.Append("Pdv: 099-COMANDA TESTE");

                //Itens
                var itens = new StringBuilder();
                itens.Append("QTDE  ITEM" + Environment.NewLine);
                itens.Append("1/2  ALMONDEGA CREAMS" + Environment.NewLine);
                itens.Append("     * DIGITADA" + Environment.NewLine);
                itens.Append("     * TESTE SQL");

                separador.Content         = "".PadRight(40, '=');
                textoHeader.Content       = reader.ToString();
                separadorUmaLinha.Content = "".PadRight(40, '-');
                textoCabecalho.Content    = cabecalho.ToString();
                textoItens.Content        = itens.ToString();

                printer.PrintDocument(document);
                printer.FormFeed(5);
                printer.Cut(CutModeEnum.Parcial);
            }
        }
Exemplo n.º 5
0
        private static void TesteCodigoBarras()
        {
            using (var printer = new GenericPrinter(PortaCom))
            {
                //Code128
                Code128 code = new Code128()
                {
                    EncodeThis             = "12321321312",
                    BarcodeWidthMultiplier = 2,
                    BarcodeDotHeight       = 50, //Autura do codigo
                    HriPosition            = Printer.Barcodes.Enums.HRIPositions.Below,
                    Mode        = Code128.Modes.A,
                    BarcodeFont = ThermalFontsEnum.A
                };

                printer.PrintASCIIString("Code 128 - Altura 50");
                printer.FormFeed(1);
                printer.PrintBarCode(code);
                printer.FormFeed(1);
                printer.Reinitialize();


                //Code39
                Code39 code39 = new Code39()
                {
                    EncodeThis             = "12321321312",
                    BarcodeWidthMultiplier = 2,
                    BarcodeDotHeight       = 30, //Autura do codigo
                    BarcodeFont            = ThermalFontsEnum.A
                };

                printer.PrintASCIIString("Code 39 - Altura 30");
                printer.FormFeed(1);
                printer.PrintBarCode(code);
                printer.FormFeed(1);
                printer.Reinitialize();

                //ITF
                ITF itf = new ITF()
                {
                    EncodeThis             = "12321321312",
                    BarcodeDotHeight       = 100, //Autura do codigo
                    BarcodeWidthMultiplier = 2,
                    BarcodeFont            = ThermalFontsEnum.A
                };

                printer.PrintASCIIString("ITF - Altura 100");
                printer.FormFeed(1);
                printer.PrintBarCode(code);
                printer.FormFeed(3);
                printer.Reinitialize();

                //NFCe
                printer.PrintASCIIString("Exemplo QRCode NFCe\n");
                var qrCodeNFCe = new QrCode(4, "http://www.sefaz.mt.gov.br/nfce/consultanfce?chNFe=51131003460900000290650010000000031000000031&nVersao=100&tpAmb=2&cDest=02801244147&dhEmi=323031332D31302D32345431363A32313A30332D30333A3030&vNF=1,00&vICMS=0,00&digVal=78764D34764E2B48586A735657516F653474415A547855547764383D&cIdToken=000001&cHashQRCode=7AF4285DA2D18133BEF9F9370AD4A185B2527AFB");

                printer.PrintBarCode(qrCodeNFCe);
                printer.FormFeed(1);
                printer.Reinitialize();

                //Sat
                printer.PrintASCIIString("Exemplo QRCode SAT\n");
                var qrCodeSat = new QrCode(4, "http://www.sefaz.mt.gov.br/nfce/consultanfce?chNFe=51131003460900000290650010000000031000000031&nVersao=100&tpAmb=2&cDest=02801244147&dhEmi=323031332D31302D32345431363A32313A30332D30333A3030&vNF=1,00&vICMS=0,00&digVal=78764D34764E2B48586A735657516F653474415A547855547764383D&cIdToken=000001&cHashQRCode=7AF4285DA2D18133BEF9F9370AD4A185B2527AFB");

                printer.PrintBarCode(qrCodeNFCe);
                printer.FormFeed(1);

                printer.Cut(CutModeEnum.Parcial);
                printer.Reinitialize();
            }
        }
Exemplo n.º 6
0
        private static void TesteEscalaAltura()
        {
            if (string.IsNullOrWhiteSpace(PortaCom))
            {
                return;
            }

            using (var printer = new GenericPrinter(PortaCom))
            {
                printer.Reinitialize();

                //Font A
                printer.SetFont(ThermalFontsEnum.A);
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Altura 1");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h2);
                printer.PrintASCIIString("Altura 2");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h3);
                printer.PrintASCIIString("Altura 3");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h4);
                printer.PrintASCIIString("Altura 4");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h5);
                printer.PrintASCIIString("Altura 5");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h6);
                printer.PrintASCIIString("Altura 6");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h7);
                printer.PrintASCIIString("Altura 7");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h8);
                printer.PrintASCIIString("Altura 8");
                printer.PrintNewline();

                printer.FormFeed();
                printer.Cut(CutModeEnum.Parcial);

                printer.Reinitialize();

                //Font B
                printer.SetFont(ThermalFontsEnum.B);
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Altura 1");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h2);
                printer.PrintASCIIString("Altura 2");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h3);
                printer.PrintASCIIString("Altura 3");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h4);
                printer.PrintASCIIString("Altura 4");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h5);
                printer.PrintASCIIString("Altura 5");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h6);
                printer.PrintASCIIString("Altura 6");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h7);
                printer.PrintASCIIString("Altura 7");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h8);
                printer.PrintASCIIString("Altura 8");
                printer.PrintNewline();

                printer.FormFeed();
                printer.Cut(CutModeEnum.Parcial);

                printer.Reinitialize();
            }
        }
Exemplo n.º 7
0
        private static void TesteEscalaLargura()
        {
            if (string.IsNullOrWhiteSpace(PortaCom))
            {
                return;
            }

            using (var printer = new GenericPrinter(PortaCom))
            {
                printer.Reinitialize();

                //Font A
                printer.SetFont(ThermalFontsEnum.A);
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 1");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w2, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 2");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w3, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 3");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w4, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 4");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w5, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largu. 5");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w6, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Lar. 6");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w7, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Lar. 7");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w8, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("La. 8");
                printer.PrintNewline();

                printer.FormFeed();
                printer.Cut(CutModeEnum.Parcial);

                printer.Reinitialize();

                //Font B
                printer.SetFont(ThermalFontsEnum.B);
                printer.SetScalars(FontWidthScalarEnum.w1, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 1");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w2, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 2");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w3, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 3");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w4, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largura 4");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w5, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Largu. 5");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w6, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Lar. 6");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w7, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("Lar. 7");
                printer.PrintNewline();
                printer.SetScalars(FontWidthScalarEnum.w8, FontHeighScalarEnum.h1);
                printer.PrintASCIIString("La. 8");
                printer.PrintNewline();

                printer.FormFeed();
                printer.Cut(CutModeEnum.Parcial);

                printer.Reinitialize();
            }
        }