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