Exemplo n.º 1
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.º 2
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);
            }
        }