static void printDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                int        SpaceFecha = 95;
                DateTime   time       = DateTime.Now;
                string     format     = "d-MM-yyyy";
                String     Fecha      = time.ToString(format);
                Font       fBody      = new Font("Lucida Console", 8, FontStyle.Bold);
                Font       fBody1     = new Font("Lucida Console", 8, FontStyle.Regular);
                SolidBrush sb         = new SolidBrush(Color.Black);

                BarCodeGeneration bcg      = new BarCodeGeneration();
                string            nro      = "12345678";
                String            imgRoute =
                    string.Format("{0}\\{1}\\{2}.{3}", Directorio, "logos", "logoskc2", "png"); ////--->>>logo skc
                //////String imgRoute =$"{Directorio}\\logos\\logoskc.jpg"; ////--->>>logo skc
                Image logo    = Image.FromFile(imgRoute);
                Image barcode = Image.FromFile(bcg.Get128BarCode(nro));

                Console.WriteLine("Printing...");
                Graphics g = e.Graphics;
                g.DrawImage(logo, 5, 0);
                g.DrawString("Fecha:", fBody, sb, 10, SpaceFecha);
                g.DrawString(Fecha, fBody, sb, 10, SpaceFecha + 15);
                g.DrawImage(barcode, 8, 140);
                g.DrawString(nro, fBody1, sb, 10, 185);
            }
            catch (Exception ex)
            {
                Console.WriteLine("error en la impression...");
            }
        }
Пример #2
0
        public String CreateEmptyImage()
        {
            BarCodeGeneration bc    = new BarCodeGeneration();
            String            token = bc.CreateUniqueToken();
            String            route = string.Format("{0}\\{1}.{2}", Directorio, token, BarCodeGeneration.Tipo.jpg);

            System.Drawing.Image resultImage = new Bitmap(317, 577, PixelFormat.Format24bppRgb);

            using (Graphics grp = Graphics.FromImage(resultImage))
            {
                grp.FillRectangle(
                    Brushes.White, 0, 0, 317, 577);
                resultImage = new Bitmap(317, 577, grp);
                resultImage.Save(route, System.Drawing.Imaging.ImageFormat.Jpeg);
            }

            return(route);
        }
Пример #3
0
        public Boolean GetVoucherFinal333()
        {
            String            barcodeid  = "123456";
            BarCodeGeneration bc         = new BarCodeGeneration();
            String            barcode    = bc.Get128BarCode(barcodeid);
            String            EmptyImage = CreateEmptyImage();

            String token = bc.CreateUniqueToken();
            String route = string.Format("{0}\\{1}.{2}", Directorio, token, BarCodeGeneration.Tipo.png);

            System.Drawing.Image backImg = System.Drawing.Image.FromFile(EmptyImage);
            System.Drawing.Image mrkImg  = System.Drawing.Image.FromFile(barcode);
            Graphics             g       = Graphics.FromImage(backImg);

            g.DrawImage(mrkImg, 317 / 2, 10);
            backImg.Save(route, System.Drawing.Imaging.ImageFormat.Jpeg);

            return(true);
        }
Пример #4
0
        public Boolean GetVoucherFinal()
        {
            int    SPACE = 145;
            String title = string.Format("{0}\\{1}\\{2}.{3}", Directorio, "logos", "skclogo105x125", BarCodeGeneration.Tipo.png); ////--->>>logo skc

            // String route = string.Format("{0}\\{1}.{2}", Directorio, token, BarCodeGeneration.Tipo.png);
            //string title = Application.StartupPath + "\\CBT_Title.png";
            //string barcode = Application.StartupPath + "\\code128bar.jpg";
            System.Drawing.Bitmap finalImage = null;

            String            barcodeid  = "123456";
            BarCodeGeneration bc         = new BarCodeGeneration();
            String            barcode    = bc.Get128BarCode(barcodeid);
            String            EmptyImage = CreateEmptyImage();
            int IntWidth  = 377;
            int IntHeight = 560;

            String token = bc.CreateUniqueToken();
            String route = string.Format("{0}\\{1}.{2}", Directorio, token, BarCodeGeneration.Tipo.png);

            finalImage = new System.Drawing.Bitmap(IntWidth, IntHeight);
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
            {
                g.DrawRectangle(Pens.Black, 5, 5, 420, 450);

                string TType = "S";

                g.DrawImage(System.Drawing.Image.FromFile(title), 50, 7);
                Font       fBody  = new Font("Lucida Console", 15, FontStyle.Bold);
                Font       fBody1 = new Font("Lucida Console", 15, FontStyle.Regular);
                Font       rs     = new Font("Stencil", 25, FontStyle.Bold);
                Font       fTType = new Font("", 150, FontStyle.Bold);
                SolidBrush sb     = new SolidBrush(Color.Black);


                g.DrawString("---------------", fBody1, sb, 10, 120);

                g.DrawString("Date :", fBody, sb, 10, SPACE);
                g.DrawString(DateTime.Now.ToShortDateString(), fBody1, sb, 90, SPACE);

                g.DrawString("Time :", fBody, sb, 10, SPACE + 30);
                g.DrawString(DateTime.Now.ToShortTimeString(), fBody1, sb, 90, SPACE + 30);

                g.DrawString("TicketNo.:", fBody, sb, 10, SPACE + 60);
                g.DrawString("", fBody1, sb, 120, SPACE + 60);

                //g.DrawString("BusNo.:", fBody, sb, 10, SPACE + 90);
                //g.DrawString(txtBusNo.Text, fBody1, sb, 100, SPACE + 90);

                //g.DrawString("DriverName:", fBody, sb, 10, SPACE+120);
                //g.DrawString(txtDriveName.Text, fBody1, sb, 153, SPACE + 120);

                //g.DrawString("Route:", fBody, sb, 10, SPACE + 120);
                //g.DrawString(cbRoute.SelectedItem.ToString(), fBody1, sb, 100, SPACE + 120);

                //g.DrawString("Full:", fBody, sb, 10, SPACE + 150);
                //g.DrawString("1 X 8.00 = 8.00", fBody1, sb, 80, SPACE + 150);

                //g.DrawString("Rs. 8.00", rs, sb, 10, SPACE + 180);

                g.DrawString(TType, fTType, sb, 230, 120);

                //g.DrawImage(Image.FromFile(barcode), 10, SPACE + 240);
                //g.DrawString("Helpline No.: +91 9999999999", fBody, sb, 10, 465);
                return(true);
            }
        }