public Byte[] getBarcodeImage(string barcode, string file) { try { BarCode39 _barcode = new BarCode39(); int barSize = 16; string fontFile = HttpContext.Current.Server.MapPath("~/fonts/FREE3OF9.TTF"); return(_barcode.Code39(barcode, barSize, true, file, fontFile)); } catch (Exception ex) { //ErrorLog.WriteErrorLog("Barcode", ex.ToString(), ex.Message); } return(null); }
public JsonResult AddBooks(Book book, int noOfBooks) { book.Title_Id = book.Title.Id; book.BookCondition_Id = book.BookCondition.Id; book.IssuedStatus = false; book.DamLostDate = (book.DamLostDate == default(DateTime)) ? null : book.DamLostDate; var barcodeList = new List <String>(); for (int i = 0; i < noOfBooks; i++) { book.Barcode = bookRepository.GetBarcode(book.Title_Id); //book.Barcode = (++barcode).ToString(); bookRepository.CreateMultiple <Book>("Books", book); var barcode = BarCode39.getBarcodeImage(book.Barcode, book.Title.Name); var barcodeUrl = "data:image/jpg;base64," + Convert.ToBase64String(barcode); barcodeList.Add(barcodeUrl); } return(Json(barcodeList, JsonRequestBehavior.AllowGet)); }