public ActionResult BarCodeDisplay(string id, bool showText = true, int thickness = 3, int height = 70) { string barcodesavepath = ConfigurationManager.AppSettings["BarCodeSavePath"]; string filepath = barcodesavepath; var barcode = new Code39BarCode() { BarCodeText = id, Height = height, ShowBarCodeText = showText }; if (thickness == 2) { barcode.BarCodeWeight = BarCodeWeight.Medium; } else if (thickness == 3) { barcode.BarCodeWeight = BarCodeWeight.Large; } ImageResult result = this.Image(barcode.Generate(), "image/gif", id, filepath); //added this hack because the users in mexico were having the travel card display prior to the bar codes being written. return(result); }
protected void rptOrderDetails_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Label lblTrackNo = (Label)e.Item.FindControl("lblTrackNo"); Label lblInvNo = (Label)e.Item.FindControl("lblInvNo"); System.Web.UI.WebControls.Image imgBarcode = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgBarcode"); Code39BarCode barcode = new Code39BarCode(); barcode.BarCodeText = lblTrackNo.Text; barcode.BarCodeWeight = BarCodeWeight.Small; byte[] filecontent = barcode.Generate(); string filepath = Server.MapPath("../Admin/InvoicePdf/" + lblInvNo.Text + ".gif"); if (File.Exists(filepath)) { File.Delete(filepath); } File.WriteAllBytes(filepath, filecontent); imgBarcode.ImageUrl = filepath; //imgBarcode.ImageUrl = string.Format("ShowCode39BarCode.ashx?code={0}&ShowText={1}&Thickness={2}", // lblTrackNo.Text, // 1, // 1); } }
public FileContentResult Barcode(string id) { id = id.GetDigits(); if (!id.HasValue()) { id = "0"; } var code = new Code39BarCode(id); return(new FileContentResult(code.Generate(), "image/png")); }
public FileContentResult Barcode(string id) { try { var code = new Code39BarCode(id) { BarCodePadding = 20 }; return(new FileContentResult(code.Generate(), "image/png")); } catch (Exception) { var code = new Code39BarCode("N/A"); return(new FileContentResult(code.Generate(), "image/png")); } }
private static MemoryStream BarCodeStream(string text, int height, bool showtext = true) { var bc = new Code39BarCode() { ShowBarCodeText = showtext, BarCodePadding = 5, BarCodeText = text, Height = height, ImageFormat = ImageFormat.Png, Weight = Code39BarCode.BarCodeWeight.Small }; var bytes = bc.Generate(); var x = (Bitmap) new ImageConverter().ConvertFrom(bytes); var ms = new MemoryStream(); x.Save(ms, ImageFormat.Png); ms.Position = 0; return(ms); }
public ActionResult TCContinuationBarCodeDisplay(TravelCardPrintViewModel viewModel, string barcodetext, int?opcode, int thispartsetupid, bool isdraft, bool iscontinuationcard, string id, bool showText = true, int thickness = 3, int height = 70) { //first save the travel card record, need the travel card id from the database to build the barcode. int travelcardid = SaveContinuationTravelCards(viewModel, barcodetext, isdraft, opcode, thispartsetupid, iscontinuationcard); string travelcardidvalue = travelcardid.ToString(); //mow save the bar code with the string barcodesavepath = ConfigurationManager.AppSettings["BarCodeSavePath"]; string filepath = barcodesavepath; var barcode = new Code39BarCode() { BarCodeText = barcodetext, Height = height, ShowBarCodeText = showText }; if (thickness == 2) { barcode.BarCodeWeight = BarCodeWeight.Medium; } else if (thickness == 3) { barcode.BarCodeWeight = BarCodeWeight.Large; } id = id + "-" + travelcardid; ImageResult result = this.Image(barcode.Generate(), "image/gif", id, filepath); //added this hack because the users in mexico were having the travel card display prior to the bar codes being written. string BarcodeFilePath = filepath + id + ".gif"; Session["tcbarcodepath"] = BarcodeFilePath; string thissession = Convert.ToString(Session["tcbarcodepath"]); Session["barcodetext"] = id; return(result); }
public FileContentResult Barcode(string id) { var code = new Code39BarCode(id); return(new FileContentResult(code.Generate(), "image/png")); }